Public Member Functions | Private Attributes | List of all members
srt_ntide_target.ide_target Class Reference

Public Member Functions

def __init__ (self, ide_file_handle="", newrel_dir="")
 
def reset_target_files (self)
 
def reset_libraries (self)
 
def parse_from_file (self, ide_file_handle)
 
def set_compile_only (self, do_it)
 
def get_target_name (self)
 
def set_build_obj (self, filename)
 
def get_target_type (self)
 
def get_target_name_root (self)
 
def get_target_root_file (self)
 
def combine (self, other_target)
 
def get_project_file (self)
 
def get_header_files (self)
 
def get_project_file_dir (self)
 
def create_ide_directory (self, dir_name)
 
def get_package_name (self)
 
def get_working_dir_rel (self)
 
def get_project_ide_name (self)
 
def has_special_commands (self)
 
def get_special_commands (self)
 
def get_dependent_on_projects (self, all_project_objects)
 
def traverse_source_files (self, helper_obj, target_list)
 
def do_traverse_source_files (self, done_list, helper_obj, target_list)
 
def get_source_files (self, target_list)
 
def get_target_source_file_list (self)
 
def set_source_file_list (self, new_list)
 
def add_source_file (self, new_file)
 
def get_non_project_targets (self, target_list)
 
def get_options_list (self)
 
def are_options_compatible (self, option_list)
 
def get_include_list (self)
 
def get_unix_include_list (self)
 
def get_macro_define_list (self)
 
def get_link_libraries (self)
 
def get_link_options (self)
 
def set_link_libraries (self, new_list)
 
def get_library_search_paths (self)
 

Private Attributes

 _option_list
 
 _macro_definitions
 
 _include_paths
 
 _unix_include_paths
 
 _source_files
 
 _header_files
 
 _forced_cpp_files
 
 _lib_files_to_add
 
 _newrel_directory
 
 _bfarch
 
 _special_commands
 
 _working_dir
 
 _package_name
 
 _link_options
 
 _build_file
 
 _library_file
 
 _exe_name
 
 _link_library_files
 
 _library_search_paths
 

Detailed Description

Definition at line 41 of file srt_ntide_target.py.

Constructor & Destructor Documentation

def srt_ntide_target.ide_target.__init__ (   self,
  ide_file_handle = "",
  newrel_dir = "" 
)

Definition at line 43 of file srt_ntide_target.py.

43  def __init__ (self, ide_file_handle = "", newrel_dir = ""):
44  self._option_list = []
46  self._include_paths = []
48  self._source_files = [] # Can contain only source_file_types
49  self._header_files = []
51  self._lib_files_to_add = [] # Contains all other types.
52  self._newrel_directory = newrel_dir
53  self._bfarch = os.environ["BFARCH"]
55  self._working_dir = ""
56  self._package_name = ""
57  self._link_options = []
58 
59  self.reset_target_files ()
60  self.reset_libraries ()
61 
62  if ide_file_handle != "":
63  self.parse_from_file (ide_file_handle)
64 
65 
def parse_from_file(self, ide_file_handle)
def __init__(self, ide_file_handle="", newrel_dir="")

Member Function Documentation

def srt_ntide_target.ide_target.add_source_file (   self,
  new_file 
)

Definition at line 482 of file srt_ntide_target.py.

Referenced by srt_ntide_target.ide_target.parse_from_file().

482  def add_source_file (self, new_file):
483  t_type = srt_path_util.file_type (new_file)
484  if t_type in source_file_types:
485  self._source_files.append (new_file)
486  else:
487  self._lib_files_to_add.append (new_file)
488 
def add_source_file(self, new_file)
def srt_ntide_target.ide_target.are_options_compatible (   self,
  option_list 
)

Definition at line 532 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._option_list.

532  def are_options_compatible (self, option_list):
533  for option in option_list:
534  if option not in self._option_list:
535  return 0
536  return 1
537 
def are_options_compatible(self, option_list)
def srt_ntide_target.ide_target.combine (   self,
  other_target 
)

Definition at line 256 of file srt_ntide_target.py.

References srt_ntide_target.ide_target.get_target_name_root(), and srt_ntide_target.ide_target.get_target_type().

256  def combine (self, other_target):
257 
258  if self.get_target_type() != "lib":
259  str_ing = "Can only combine library targets (type: " + self.get_target_type() + "; target: " + self.get_target_name_root() + ")"
260  raise str_ing
261 
262  for a_file in other_target._lib_files_to_add:
263  self._lib_files_to_add.append (a_file)
264 
def combine(self, other_target)
def srt_ntide_target.ide_target.create_ide_directory (   self,
  dir_name 
)

Definition at line 296 of file srt_ntide_target.py.

References srt_ntide_target.ide_target.get_project_file_dir().

296  def create_ide_directory (self, dir_name):
297  dir_path = self.get_project_file_dir() + "\\" + dir_name
298  if not os.path.exists (dir_path):
299  os.mkdir (dir_path)
300 
def create_ide_directory(self, dir_name)
def srt_ntide_target.ide_target.do_traverse_source_files (   self,
  done_list,
  helper_obj,
  target_list 
)

Definition at line 407 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._lib_files_to_add, srt_ntide_target.ide_target._newrel_directory, srt_ntide_target.ide_target._source_files, srt_ntide_target.ide_target._working_dir, and srt_ntide_target.ide_target.get_target_type().

Referenced by srt_ntide_target.ide_target.traverse_source_files().

407  def do_traverse_source_files (self, done_list, helper_obj, target_list):
408 
409  list_1 = self._source_files
410  for a_file in self._lib_files_to_add:
411  list_1.append (a_file)
412 
413  for a_file in list_1:
414  if target_list.has_key(a_file):
415  if not is_a_project (target_list[a_file].get_target_type()):
416  helper_obj = target_list[a_file].do_traverse_source_files (done_list, helper_obj, target_list)
417  else:
418  if not os.path.isabs (a_file):
419  the_file = self._newrel_directory + "\\" + self._working_dir + "\\" + a_file
420  else:
421  the_file = a_file
422  if the_file not in done_list:
423  helper_obj.source_file (the_file, self)
424  done_list.append(the_file)
425  return helper_obj
426 
def do_traverse_source_files(self, done_list, helper_obj, target_list)
def srt_ntide_target.ide_target.get_dependent_on_projects (   self,
  all_project_objects 
)

Definition at line 376 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._lib_files_to_add, and srt_ntide_target.ide_target._source_files.

376  def get_dependent_on_projects (self, all_project_objects):
377  list_1 = find_dependent_projects (self._source_files, all_project_objects)
378  list_2 = find_dependent_projects (self._lib_files_to_add, all_project_objects)
379 
380  for duh in list_2:
381  list_1.append(duh)
382 
383  return list_1
384 
def get_dependent_on_projects(self, all_project_objects)
def srt_ntide_target.ide_target.get_header_files (   self)
def srt_ntide_target.ide_target.get_include_list (   self)
def srt_ntide_target.ide_target.get_library_search_paths (   self)

Definition at line 604 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._library_search_paths.

605  return self._library_search_paths
606 
607 #
608 # find_dependent_projects
609 #
610 # This guy will search through a list of files and extract those that are dependent
611 # projects. That is, this is a list of dependents. Some of them are going to be made into
612 # a project... which ones so we can establish project dependencies.
613 #
614 # NOTE that at the moment I don't take into account library search paths, so that could
615 # lead to some problems with links! I suspect this should be handled some other place in
616 # this script, not here, however.
617 #
def srt_ntide_target.ide_target.get_link_libraries (   self)

Definition at line 568 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._library_search_paths, and srt_ntide_target.ide_target._link_library_files.

568  def get_link_libraries (self):
569  list_of_libs = []
570  for a_lib in self._link_library_files:
571  lib_file = a_lib
572  if not os.path.exists (a_lib):
573  for search_path in self._library_search_paths:
574  temp = search_path + "\\" + a_lib
575  if os.path.exists (temp):
576  lib_file = temp
577  break
578 
579  list_of_libs.append(lib_file)
580 
581  return self._link_library_files
582 
def srt_ntide_target.ide_target.get_link_options (   self)
def srt_ntide_target.ide_target.get_macro_define_list (   self)
def srt_ntide_target.ide_target.get_non_project_targets (   self,
  target_list 
)

Definition at line 494 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._lib_files_to_add, srt_ntide_target.ide_target._source_files, and srt_ntide_target.ide_target.get_target_type().

494  def get_non_project_targets (self, target_list):
495  found_targets = []
496 
497  list_1 = self._source_files
498  for a_file in self._lib_files_to_add:
499  list_1.append(a_file)
500 
501  for a_file in list_1:
502  if target_list.has_key(a_file):
503  if not is_a_project (target_list[a_file].get_target_type()):
504  found_targets.append(a_file)
505 
506  target_source_list = target_list[a_file].get_source_files (target_list)
507  for more_files in target_source_list:
508  if more_files not in list_1:
509  list_1.append (more_files)
510 
511  return found_targets
512 
def get_non_project_targets(self, target_list)
def srt_ntide_target.ide_target.get_options_list (   self)

Definition at line 518 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._option_list, and srt_ntide_target.ide_target._source_files.

518  def get_options_list (self):
519  if self._forced_cpp_files.has_key(self._source_files[0]):
520  temp = self._option_list
521  temp.append("TP")
522  return temp
523  else:
524  return self._option_list
525 
def srt_ntide_target.ide_target.get_package_name (   self)

Definition at line 315 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._package_name, and srt_ntide_target.ide_target._working_dir.

Referenced by srt_ntide_target.ide_target.get_project_file_dir(), and srt_ntide_target.ide_target.get_project_ide_name().

315  def get_package_name (self):
316  if self._package_name == "":
317  print "Warning: will attempt to guess the package name (compile commands should have given it)..."
318  if regex.search("^tmp.*$", self._working_dir) == 0:
319  pkg_finder = regex.compile ("^tmp\\\\[^\\]*\\\\\([^\\]*\).*$")
320  if pkg_finder.match (self._working_dir) != -1:
321  self._package_name = pkg_finder.group(1)
322  else:
323  raise "Working dir dosen't look right!"
324  else:
325  old_root = ""
326  root = self._working_dir
327  while root != "":
328  old_root = root
329  (root, stuff) = os.path.split (root)
330  self._package_name = old_root
331  print " Guessed " + self._package_name
332  return self._package_name
333 
334 
def srt_ntide_target.ide_target.get_project_file (   self)

Definition at line 270 of file srt_ntide_target.py.

References srt_ntide_target.ide_target.get_project_file_dir(), and srt_ntide_target.ide_target.get_target_name_root().

270  def get_project_file (self):
271  (target_name, type) = os.path.splitext (self.get_target_name_root())
272  return self.get_project_file_dir() + "\\" + target_name + ".dsp"
273 
def srt_ntide_target.ide_target.get_project_file_dir (   self)
def srt_ntide_target.ide_target.get_project_ide_name (   self)

Definition at line 351 of file srt_ntide_target.py.

References srt_ntide_target.ide_target.get_package_name(), and srt_ntide_target.ide_target.get_target_root_file().

352  temp = self.get_package_name() + "/" + self.get_target_root_file()
353  return regsub.gsub ("-", "_", temp)
354 
def srt_ntide_target.ide_target.get_source_files (   self,
  target_list 
)

Definition at line 434 of file srt_ntide_target.py.

References srt_ntide_target.ide_target.traverse_source_files().

434  def get_source_files (self, target_list):
435  src_helper = get_source_file_helper()
436  self.traverse_source_files (src_helper, target_list)
437  return src_helper.source_list()
438 
def traverse_source_files(self, helper_obj, target_list)
def get_source_files(self, target_list)
def srt_ntide_target.ide_target.get_special_commands (   self)
def srt_ntide_target.ide_target.get_target_name (   self)

Definition at line 196 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._build_file, srt_ntide_target.ide_target._exe_name, and srt_ntide_target.ide_target._library_file.

Referenced by srt_ntide_target.ide_target.get_target_name_root().

196  def get_target_name (self):
197  if (self._library_file != "") and (self._build_file != ""):
198  raise "Both library and build are non-zero!"
199  if self._build_file != "":
200  return self._build_file
201  if self._library_file != "":
202  return self._library_file
203  if self._exe_name != "":
204  return self._exe_name
205 
206  raise "Should never get here!"
207 
def srt_ntide_target.ide_target.get_target_name_root (   self)
def srt_ntide_target.ide_target.get_target_root_file (   self)

Definition at line 244 of file srt_ntide_target.py.

References srt_ntide_target.ide_target.get_target_name_root().

Referenced by srt_ntide_target.ide_target.get_project_ide_name().

245  (name, exten) = os.path.splitext (self.get_target_name_root())
246  return name
247 
def srt_ntide_target.ide_target.get_target_source_file_list (   self)
def srt_ntide_target.ide_target.get_target_type (   self)

Definition at line 223 of file srt_ntide_target.py.

References srt_ntide_target.ide_target.get_target_name_root().

Referenced by srt_ntide_target.ide_target.combine(), srt_ntide_target.ide_target.do_traverse_source_files(), and srt_ntide_target.ide_target.get_non_project_targets().

223  def get_target_type (self):
224  fname = self.get_target_name_root()
225  pos = regex.search ("\.[^\.]*$", fname)
226  if pos == -1:
227  t_type = "exe"
228  else:
229  t_type = fname[pos+1:]
230 
231  if t_type in exe_file_types:
232  return "exe"
233  return t_type
234 
235 
def srt_ntide_target.ide_target.get_unix_include_list (   self)
def srt_ntide_target.ide_target.get_working_dir_rel (   self)
def srt_ntide_target.ide_target.has_special_commands (   self)

Definition at line 360 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._special_commands.

361  return len(self._special_commands) > 0
362 
def srt_ntide_target.ide_target.parse_from_file (   self,
  ide_file_handle 
)

Definition at line 90 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._build_file, srt_ntide_target.ide_target._exe_name, srt_ntide_target.ide_target._forced_cpp_files, srt_ntide_target.ide_target._library_file, srt_ntide_target.ide_target._newrel_directory, srt_ntide_target.ide_target._package_name, srt_ntide_target.ide_target._working_dir, and srt_ntide_target.ide_target.add_source_file().

90  def parse_from_file (self, ide_file_handle):
91 
92  star_line = ide_file_handle.get_line()
93 
94  ide_file_handle.load_buffer()
95  while ide_file_handle.there_is_more() and (not ide_file_handle.is_star_line()):
96  line = ide_file_handle.get_line()
97 
98  line_word_list = string.split (line, " ", 1)
99  command = line_word_list[0]
100  option = ""
101  if len(line_word_list) == 2:
102  option = line_word_list[1]
103 
104  if command == "option":
105  self._option_list.append(option)
106  elif command == "link_option":
107  self._link_options.append(option)
108  elif command == "define_macro":
109  self._macro_definitions.append(option)
110  elif command == "include_file_path":
111  if (option != ".") and (option != ""):
112  self._include_paths.append(option)
113  elif command == "unix_include_file_path":
114  if (option != ".") and (option != ""):
115  self._unix_include_paths.append(option)
116  elif command == "do_compile_only":
117  self._option_list.append("c")
118  elif command == "h_filename":
119  self._header_files.append(option)
120  elif command == "source_file":
121  self.add_source_file (option)
122  elif command == "source_file_cpp":
123  self.add_source_file (option)
124  self._forced_cpp_files[option] = "cpp"
125  elif command == "special_command":
126  self._special_commands.append(option)
127  elif command == "add_and_create":
128  i = 10
129  elif command == "build_obj":
130  if self._build_file != "":
131  raise "Cannot build more than one output file per target!"
132  self._build_file = option
133  elif command == "build_file":
134  if self._build_file != "":
135  raise "Cannot build more than one output file per target!"
136  self._build_file = option
137  elif command == "library_file":
138  if self._library_file != "":
139  raise "Cannot build more than one library file per target!"
140  self._library_file = option
141  elif command == "library":
142  self._link_library_files.append (option)
143  elif command == "add_file":
144  self._lib_files_to_add.append (option)
145  elif command == "library_search_path":
146  self._library_search_paths.append (option)
147  elif command == "build_app":
148  if self._exe_name != "":
149  raise "Cannot build more than one exe per target!"
150  self._exe_name = option
151  elif command == "working_dir":
152  common_prefix = os.path.commonprefix ([option, self._newrel_directory])
153  if common_prefix != self._newrel_directory:
154  raise "Working directory must be subdir of newrelease directory!"
155  self._working_dir = option[len(self._newrel_directory)+1:]
156  elif command == "package_name":
157  self._package_name = option
158  else:
159  print "Unknown IDE Make file option: " + command
160  raise "Could not parse the file"
161 
162  ide_file_handle.load_buffer()
163 
164  target_count = 0
165  if self._build_file != "":
166  target_count = target_count + 1
167  if self._library_file != "":
168  target_count = target_count + 1
169  if self._exe_name != "":
170  target_count = target_count + 1
171 
172  if target_count == 0:
173  raise "No targets found for file!"
174  if target_count > 1:
175  raise "Too many targets found for file!"
176 
def parse_from_file(self, ide_file_handle)
def add_source_file(self, new_file)
def srt_ntide_target.ide_target.reset_libraries (   self)
def srt_ntide_target.ide_target.reset_target_files (   self)
def srt_ntide_target.ide_target.set_build_obj (   self,
  filename 
)

Definition at line 213 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._build_file.

213  def set_build_obj (self, filename):
214  self._build_file = filename
215 
def set_build_obj(self, filename)
def srt_ntide_target.ide_target.set_compile_only (   self,
  do_it 
)

Definition at line 183 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._option_list.

183  def set_compile_only (self, do_it):
184  if do_it:
185  if "c" not in self._option_list:
186  self._option_list.append ("c")
187  else:
188  raise "Don't know how to remove the C option yet!"
189 
def set_compile_only(self, do_it)
def srt_ntide_target.ide_target.set_link_libraries (   self,
  new_list 
)

Definition at line 596 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._link_library_files.

596  def set_link_libraries (self, new_list):
597  self._link_library_files = new_list
598 
def set_link_libraries(self, new_list)
def srt_ntide_target.ide_target.set_source_file_list (   self,
  new_list 
)

Definition at line 474 of file srt_ntide_target.py.

References srt_ntide_target.ide_target._source_files.

474  def set_source_file_list (self, new_list):
475  self._source_files = new_list
476 
def set_source_file_list(self, new_list)
def srt_ntide_target.ide_target.traverse_source_files (   self,
  helper_obj,
  target_list 
)

Definition at line 397 of file srt_ntide_target.py.

References srt_ntide_target.ide_target.do_traverse_source_files().

Referenced by srt_ntide_target.ide_target.get_source_files().

397  def traverse_source_files (self, helper_obj, target_list):
398  done_list = []
399  result = self.do_traverse_source_files (done_list, helper_obj, target_list)
400  return result
401 
def do_traverse_source_files(self, done_list, helper_obj, target_list)
def traverse_source_files(self, helper_obj, target_list)

Member Data Documentation

srt_ntide_target.ide_target._bfarch
private
srt_ntide_target.ide_target._build_file
private
srt_ntide_target.ide_target._exe_name
private
srt_ntide_target.ide_target._forced_cpp_files
private

Definition at line 50 of file srt_ntide_target.py.

Referenced by srt_ntide_target.ide_target.parse_from_file().

srt_ntide_target.ide_target._header_files
private

Definition at line 49 of file srt_ntide_target.py.

Referenced by srt_ntide_target.ide_target.get_header_files().

srt_ntide_target.ide_target._include_paths
private

Definition at line 46 of file srt_ntide_target.py.

Referenced by srt_ntide_target.ide_target.get_include_list().

srt_ntide_target.ide_target._lib_files_to_add
private
srt_ntide_target.ide_target._library_file
private
srt_ntide_target.ide_target._library_search_paths
private
srt_ntide_target.ide_target._link_library_files
private
srt_ntide_target.ide_target._link_options
private

Definition at line 57 of file srt_ntide_target.py.

Referenced by srt_ntide_target.ide_target.get_link_options().

srt_ntide_target.ide_target._macro_definitions
private
srt_ntide_target.ide_target._newrel_directory
private
srt_ntide_target.ide_target._option_list
private
srt_ntide_target.ide_target._package_name
private
srt_ntide_target.ide_target._source_files
private
srt_ntide_target.ide_target._special_commands
private
srt_ntide_target.ide_target._unix_include_paths
private
srt_ntide_target.ide_target._working_dir
private

The documentation for this class was generated from the following file: