Functions
srt_make_ntide_files Namespace Reference

Functions

def parse_ide_dump (filename, newrel_dir)
 
def combine_targets (target_list)
 
def find_project_targets (target_dict)
 
def create_project_workspace (newrel_dir, project_list, target_list)
 
def split_targets (target_list)
 
def auto_link_libs (target_map)
 
def main ()
 MAIN FUNCTION. More...
 

Function Documentation

def srt_make_ntide_files.auto_link_libs (   target_map)

Definition at line 219 of file srt_make_ntide_files.py.

219 def auto_link_libs (target_map):
220  #
221  # First, get a list of all the .lib projects we are going to build
222  #
223 
224  project_lib_map = {}
225  for t_key in target_map.keys():
226  if target_map[t_key].get_target_type() == "lib":
227  project_lib_map[target_map[t_key].get_target_root_file()] = target_map[t_key]
228 
229  #
230  # Next job is to loop through all the targets and find all
231  # the .lib files they are leaning on. If their name matches
232  # any of the names of the above list, then we alter it so that
233  # we can create a dependancy later.
234  #
235 
236  for t_key in target_map.keys():
237  link_lib_list = target_map[t_key].get_link_libraries()
238  new_link_lib_list = []
239  for library in link_lib_list:
240  basename = os.path.basename (library)
241  (lib_name, exten) = os.path.splitext (basename)
242 
243  if project_lib_map.has_key(lib_name):
244  target_map[t_key].add_source_file (project_lib_map[lib_name].get_target_name())
245  else:
246  new_link_lib_list.append (library)
247 
248  target_map[t_key].set_link_libraries (new_link_lib_list)
249 
250  return target_map
251 
252 #
253 # main
254 #
255 # Drive this whole thing
256 #
def auto_link_libs(target_map)
def srt_make_ntide_files.combine_targets (   target_list)

Definition at line 47 of file srt_make_ntide_files.py.

47 def combine_targets (target_list):
48  target_dict = {}
49 
50  for a_file in target_list:
51  t_name = a_file.get_target_name()
52  if target_dict.has_key(t_name):
53  target_dict[t_name].combine(a_file)
54  else:
55  target_dict[t_name] = a_file
56  return target_dict
57 
58 #
59 # find_project_targets
60 #
61 # Return a string list of those guys that should be individual projects
62 #
def combine_targets(target_list)
def srt_make_ntide_files.create_project_workspace (   newrel_dir,
  project_list,
  target_list 
)

Definition at line 77 of file srt_make_ntide_files.py.

77 def create_project_workspace (newrel_dir, project_list, target_list):
78  newrel_name = os.path.basename (newrel_dir)
79 
80  newrel_dsw = open (newrel_dir + "\\" + newrel_name + ".dsw", "w")
81 
82  newrel_dsw.write("Microsoft Developer Studio Workspace File, Format Version 5.00\n")
83  newrel_dsw.write("# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n")
84 
85  for a_project_name in project_list:
86  newrel_dsw.write ("###############################################################################\n\n")
87 
88  project_ide_name = target_list[a_project_name].get_project_ide_name()
89 
90  project_file = target_list[a_project_name].get_project_file()
91  project_file = srt_path_util.get_relative_path (project_file, newrel_dir)
92  newrel_dsw.write ('Project: "' + project_ide_name + '"=.\\' + project_file + " - Package Owner=<4>\n\n")
93  newrel_dsw.write ("Package=<5>\n{{{\n}}}\n\n")
94 
95  #
96  # Do the project dependancies
97  #
98 
99  newrel_dsw.write ("Package=<4>\n{{{\n")
100 
101  dep_list = target_list[a_project_name].get_dependent_on_projects(target_list)
102  for a_dep_name in dep_list:
103  newrel_dsw.write (" Begin Project Dependency\n")
104  newrel_dsw.write (" Project_Dep_Name " + target_list[a_dep_name].get_project_ide_name() + "\n")
105  newrel_dsw.write (" End Project Dependency\n")
106 
107  newrel_dsw.write ("}}}\n\n")
108 
109  #
110  # Write out the global project properties
111  #
112 
113  newrel_dsw.write ("###############################################################################\n\n")
114  newrel_dsw.write ("Global:\n\n")
115  newrel_dsw.write ("Package=<5>\n{{{\n}}}\n\n")
116  newrel_dsw.write ("Package=<3>\n{{{\n")
117  newrel_dsw.write ("}}}\n\n")
118  newrel_dsw.close()
119 
120 #
121 # split_targets
122 #
123 # Loop over all the targets looking for guys that need to be split. If they do,
124 # create the two new targets. Keep doing this till no more splits are needed.
125 #
def create_project_workspace(newrel_dir, project_list, target_list)
def srt_make_ntide_files.find_project_targets (   target_dict)

Definition at line 63 of file srt_make_ntide_files.py.

63 def find_project_targets (target_dict):
64  the_list = []
65  for a_target_name in target_dict.keys():
66  t_type = target_dict[a_target_name].get_target_type()
67  if srt_ntide_target.is_a_project (t_type):
68  the_list.append (a_target_name)
69 
70  return the_list
71 
72 #
73 # create_project_workspace
74 #
75 # Create the .dsw file at the root of the newrel directory
76 #
def find_project_targets(target_dict)
def srt_make_ntide_files.main ( )

MAIN FUNCTION.

1D plots hits vs w //

Definition at line 257 of file srt_make_ntide_files.py.

References srt_ntbashutil.translate_path().

257 def main():
258 
259  #
260  # Do a few sanity checks!
261  #
262 
263  if len(sys.argv) < 3:
264  print "Usage: " + sys.argv[0] + " <ide-dump-file> <slt-newrel-directory>"
265  return 1
266 
267  ide_dump_file = srt_ntbashutil.translate_path(sys.argv[1])
268  if not os.path.exists (ide_dump_file):
269  print "File '" + sys.argv[1] + "' does not exist!"
270  return 1
271 
272  newrel_dir = srt_ntbashutil.translate_path(sys.argv[2])
273  if not os.path.exists (newrel_dir):
274  print "newrel directory '" + newrel_dir + "' does not exist!"
275  return 1
276 
277  build_workspace = 1
278  if len(sys.argv) == 4:
279  options_line = sys.argv[3]
280  if options_line == "noworkspace":
281  build_workspace = 0;
282  elif options_line == "workspace":
283  build_workspace = 1;
284  else:
285  raise "Unknown option (workspace, noworkspace allowed): " + options_line
286 
287  #
288  # Now, parse the file. This will create a bunch of file objects.
289  #
290 
291  file_objects = parse_ide_dump (ide_dump_file, newrel_dir)
292 
293  #
294  # Some of the targets may actually be several steps all wrapped into one.
295  # For example, a .cpp file as input, a .exe as output. Needs to be converted
296  # to two bits.
297  #
298 
299  file_objects = split_targets (file_objects)
300 
301  #
302  # Next, turn them into a dictonary, keyed by their targets. This also means that
303  # if there is more than one of the same target it will be combined.
304  #
305 
306  target_dict = combine_targets (file_objects)
307 
308  #
309  # Next, see if there are project .lib's in there that are also project
310  # targets of ours... we have to do this because there are several ways
311  # to specify how to link in libraries.
312  #
313 
314  target_dict = auto_link_libs (target_dict)
315 
316  #
317  # Now, find the list of targets which should each be a project in the IDE
318  #
319 
320  project_target_list = find_project_targets (target_dict)
321 
322  #
323  # Next, create the project workspace in the newrel directory
324  #
325 
326  if build_workspace:
327  create_project_workspace (newrel_dir, project_target_list, target_dict)
328 
329  #
330  # Now, for each of these guys, create a new project file!
331  #
332 
333  for project in project_target_list:
334  srt_ntide_project_file.create_project_file (target_dict[project], target_dict, newrel_dir)
335  if not build_workspace:
336  print "*** You MUST add the file " + target_dict[project].get_project_file() + " to your workspace!"
337 
338 #
339 # If we are just being imported, do nothing
340 #
def translate_path(bash_path)
def main()
MAIN FUNCTION.
def srt_make_ntide_files.parse_ide_dump (   filename,
  newrel_dir 
)

Definition at line 27 of file srt_make_ntide_files.py.

27 def parse_ide_dump (filename, newrel_dir):
28  ide_file = srt_ntide_dump_file.ide_dump_file (filename)
29 
30  file_list = []
31 
32  while ide_file.there_is_more():
33  ide_file.load_buffer()
34  if not ide_file.is_star_line():
35  raise "Badly formatted ide dump file!"
36 
37  new_target = srt_ntide_target.ide_target (ide_file, newrel_dir)
38  file_list.append (new_target)
39 
40  return file_list
41 
42 #
43 # combine_targets
44 #
45 # Given a list of targets, construct a dictonary keyed off the target names
46 #
def parse_ide_dump(filename, newrel_dir)
def srt_make_ntide_files.split_targets (   target_list)

Definition at line 126 of file srt_make_ntide_files.py.

References srt_path_util.change_to_type().

126 def split_targets (target_list):
127  #
128  # First task is to split all the targets so that each has only one source
129  # file.
130  #
131 
132  new_target_list = []
133  for target in target_list:
134  source_list = target.get_target_source_file_list()
135  if len(source_list) <= 1:
136  new_target_list.append(target)
137  else:
138  for source_file in source_list:
139  new_target = copy.deepcopy(target)
140  new_target.set_source_file_list ([ source_file ])
141  new_target_list.append(new_target)
142 
143  target_list = new_target_list
144 
145  #
146  # Now, make sure that each target is really only one step
147  #
148 
149  number_split = 1
150  while number_split != 0:
151  #
152  # Init the loop
153  #
154 
155  number_split = 0
156  new_target_list = []
157 
158  for target in target_list:
159  #
160  #
161  #
162  # There is most likely a general way to do this (make certianly has one),
163  # but I don't know how to do it.
164  #
165 
166  source_file_list = target.get_target_source_file_list()
167  if len(source_file_list) > 1:
168  raise "Error: bad number of sources in " + target.get_target_name_root() + " (" + `len(source_file_list)` + ")."
169 
170  if len(source_file_list) == 0:
171  source_file_type = "null_source"
172  else:
173  source_file_type = srt_path_util.file_type (source_file_list[0])
174  dest_file_type = target.get_target_type()
175 
176  #
177  # If the source file type is part of the "compiled source list", then
178  # the target of this guy had better be a ".o" object file. If not, then
179  # this guy has to be made into two projects.
180  #
181 
182  did_split = 0
183  if source_file_type in srt_ntide_target.source_file_types:
184  if dest_file_type != "o":
185 
186  obj_file = srt_path_util.change_to_type(source_file_list[0], "o")
187 
188  object_target = copy.deepcopy(target)
189  object_target.reset_target_files()
190  object_target.reset_libraries()
191  object_target.set_compile_only (1)
192  object_target.set_build_obj (obj_file)
193  new_target_list.append (object_target)
194 
195  new_final_target = copy.deepcopy(target)
196  new_final_target.set_source_file_list ([ obj_file ])
197  new_target_list.append (new_final_target)
198  did_split = 1
199 
200  if did_split:
201  number_split = number_split + 1
202  else:
203  new_target_list.append (target)
204 
205  #
206  # Have a new target list. Lets try the loop again.
207  #
208 
209  target_list = new_target_list
210  return target_list
211 
212 #
213 # auto_link_libs
214 #
215 # Find all the included library files that are also targets. Some
216 # libraries just exist, others we have to build. We want the ones we
217 # have to build to become project dependencies.
218 #
def split_targets(target_list)
def change_to_type(old_path, new_type)