Functions | Variables
srt_ntcc Namespace Reference

Functions

def main ()
 MAIN FUNCTION. More...
 
def fixup_no_conformist_includes (include_list)
 

Variables

 result = main()
 

Function Documentation

def srt_ntcc.fixup_no_conformist_includes (   include_list)

Definition at line 398 of file srt_ntcc.py.

398 def fixup_no_conformist_includes (include_list):
399  result = []
400  locator = regex.compile ("^\(.*\)\\\\\(.+\)\\\\\(.+\)\\\\\(.+\)\\\\\.\.$")
401  for item in include_list:
402  ritem = item
403  if locator.match(item) != -1:
404  if (locator.group(3) != locator.group(4)) and (locator.group(2) != locator.group(4)):
405  ritem = locator.group(1) + "\\" + locator.group(2) + "\\" + locator.group(3) + "\\" + locator.group(4)
406  result.append(item)
407  result.append(ritem)
408  return result
409 
410 #
411 # Execute the routine and let the shell know what happened.
412 #
def fixup_no_conformist_includes(include_list)
Definition: srt_ntcc.py:398
def srt_ntcc.main ( )

MAIN FUNCTION.

1D plots hits vs w //

Definition at line 38 of file srt_ntcc.py.

References srt_ntbashutil.compress_path(), srt_path_util.file_type(), srt_ntbashutil.is_absolute_path(), and srt_ntbashutil.translate_path().

38 def main():
39 
40  #
41  # Setup and make sure command line stuff is there and cool.
42  #
43 
44  cmd_options = srt_options_line.options_line (sys.argv[1:])
45 
46  if cmd_options.length() == 0:
47  sys.stderr.write("Usage: " + sys.argv[0] + " <arguments>\n")
48  return 1
49 
50  cmd_line = ""
51  link_line = ""
52  link_line_valid = 1
53 
54  nt_output_file = ""
55 
56  #
57  # By default we will be executing this hole thing!
58  #
59 
60  no_run = 0
61 
62  #
63  # The local path cache varriable
64  #
65 
66  local_path = ""
67 
68  #
69  # Keep track of source files and link files. If we have no source files, then we had better just invoke the
70  # link command!
71  #
72 
73  n_source_files = 0
74  n_link_files = 0
75 
76  #
77  # Are we dumping for IDE stuff, or something else?
78  #
79 
80  do_ide_dump = 0
81  if os.environ.has_key("IDE_DUMP"):
82  f_name = srt_ntbashutil.translate_path(os.environ["IDE_DUMP"])
83  sys.stdout = open (f_name, "a+")
84  do_ide_dump = 1
85 
86  #
87  # Now, loop over all the arguments in the command line.
88  #
89 
90  if do_ide_dump:
91  print "->IDE<- *compile"
92  print "->IDE<- working_dir " + os.getcwd()
93  current_package = ""
94  if os.environ.has_key("CURPKG"):
95  current_package = os.environ["CURPKG"]
96  print "->IDE<- package_name " + current_package
97 
98  while cmd_options.has_more_options():
99  option = cmd_options.get_next_option ("this should never fail!")
100  if option[0] == "-":
101  option = option[1:]
102  #
103  # I -- An include file
104  #
105 
106  if option[0] == "I":
107  raw_path = option[1:]
108  if not srt_ntbashutil.is_absolute_path(raw_path):
109  if local_path == "":
110  local_path_h = os.popen("pwd", "r")
111  buffer = local_path_h.readline()
112  local_path = buffer[:-1]
113  local_path_h.close()
114  raw_path = local_path + "/" + raw_path
115  translated_path = srt_ntbashutil.translate_path (raw_path)
116  nt_path_list = srt_ntbashutil.resolve_bash_aliases (translated_path)
117  nt_path_list = fixup_no_conformist_includes (nt_path_list)
118  if do_ide_dump:
119  print "->IDE<- unix_include_file_path " + option[1:]
120  for path in nt_path_list:
121  c_path = srt_ntbashutil.compress_path(path)
122  if c_path[-1] == "\\":
123  c_path = c_path[:-1]
124  cmd_line = cmd_line + "/I\"" + c_path + "\" "
125  if do_ide_dump:
126  print "->IDE<- include_file_path " + c_path
127 
128  #
129  # D -- Deifne a C macro symbol. This is a little touchy here.
130  # Add a quote mark in the correct places in this guy.
131  #
132 
133  elif option[0] == "D":
134  eq_pat=regex.compile("^\([^\=]*\)\=\(.*\)$")
135  if eq_pat.match(option[1:]) == -1:
136  good_opt = option[1:]
137  else:
138  good_opt = eq_pat.group(1) + "=\"" + eq_pat.group(2) + "\""
139  cmd_line = cmd_line + "/D" + good_opt + " "
140  if do_ide_dump:
141  print "->IDE<- define_macro " + good_opt
142 
143  #
144  # c -- Don't link, only compile (defualt for cl).
145  #
146 
147  elif option[0] == "c":
148  cmd_line = cmd_line + "/c" + " "
149  link_line_valid = 0
150  if do_ide_dump:
151  print "->IDE<- do_compile_only"
152 
153  #
154  # g -- ignore the debug flag for now
155  #
156 
157  elif option[0] == "g":
158  #print "**"
159  #print "** WARNING: Ignoring the debug 'g' flag."
160  #print "**"
161  stuff_place = 0
162 
163  #
164  # o -- Remember the output file. Later, after we are done processing the
165  # link line we can append it to the correct flag depending upon weather or
166  # not this is just a compile or a compile and link.
167  #
168 
169  elif option[0] == "o":
170  raw_nt_output_file = cmd_options.get_next_option("output file name")
171  nt_output_file = srt_ntbashutil.translate_path(raw_nt_output_file)
172 
173  #
174  # Fd is the program database. Basically, pass right through, along with
175  # a full blown filename translation. In the case of a IDE build, however,
176  # this option gets ignored. The reason is that the IDE bases where to put the
177  # db on its own internal temp directory, which is set as part of the build
178  # process.
179  #
180 
181  elif option[0:2] == "Fd":
182  pdb_filename = option[2:]
183  nt_pdb_filename = srt_ntbashutil.translate_path(pdb_filename)
184  cmd_line = cmd_line + "/Fd" + nt_pdb_filename + " "
185 
186  elif option[0:2] == "FI":
187  fi_filename = option[2:]
188  nt_fi_filename = srt_ntbashutil.translate_path(fi_filename)
189  cmd_line = cmd_line + "/FI" + nt_fi_filename + " "
190 
191 
192  #
193  # Pass through options -- these are really NT options, but we have to
194  # use "-" instead of "/" when talking to them!
195  #
196 
197  elif option[0:3] == "NTL":
198  link_line = link_line + "/" + option[3:] + " "
199  if do_ide_dump:
200  print "->IDE<- link_option " + option[3:]
201 
202  elif option[0:2] == "NT":
203  if option[2:] == "NoRun":
204  no_run = 1
205  else:
206  cmd_line = cmd_line + "/" + option[2:] + " "
207  if do_ide_dump:
208  print "->IDE<- option " + option[2:]
209 
210  elif option[0:1] == "L":
211  link_line = link_line + "/libpath:" + srt_ntbashutil.translate_path(option[1:]) + " "
212  link_line_valid = 1
213  if do_ide_dump:
214  print "->IDE<- library_search_path " + srt_ntbashutil.translate_path(option[1:])
215 
216  #
217  # A library -- add it on to the list. If it is one of the default libraries
218  # just remove it from the link list (like the math library).
219  #
220  elif option[0:1] == "l":
221  library_name = option[1:]
222  if library_name != "m":
223  link_line = link_line + "lib" + library_name + ".lib "
224  link_line_valid = 1
225  if do_ide_dump:
226  print "->IDE<- library lib" + library_name + ".lib"
227 
228  #
229  # Game over. Wonder what this option was supposed to be?
230  #
231 
232  else:
233  sys.stderr.write("WARNING: Unkown gcc option in srt_ntcc.py!!: -" + option + "\n")
234  return 1
235  else:
236  #
237  # Got a plain file. If it is a .a file, change it to a .lib file. NT, of course,
238  # uses .lib, while UNIX (dark ages) uses .a
239  #
240 
241  nt_path = srt_ntbashutil.translate_path (option)
242  if srt_path_util.file_type(nt_path) == "a":
243  nt_path = srt_path_util.change_to_type (nt_path, "lib")
244 
245  file_type = srt_path_util.file_type(nt_path)
246  force_cpp = 0
247  if file_type == "cc":
248  force_cpp = 1
249  cmd_line = cmd_line + "/Tp " + nt_path + " "
250  n_source_files = n_source_files + 1
251  elif (file_type == "o") | (file_type == "obj") | (file_type == "lib"):
252  link_line_valid = 1
253  link_line = link_line + nt_path + " "
254  n_link_files = n_link_files + 1
255  else:
256  cmd_line = cmd_line + nt_path + " "
257  n_source_files = n_source_files + 1
258 
259  #
260  # We do something a little different here if it is
261  # a library -- we make sure mark a lib as a library.
262  #
263  if do_ide_dump:
264  if file_type == "lib":
265  print "->IDE<- library " + nt_path
266  else:
267  if force_cpp == 1:
268  print "->IDE<- source_file_cpp " + nt_path
269  else:
270  print "->IDE<- source_file " + nt_path
271 
272  #
273  # Do the output file correctly. This depends upon weather or not the link line
274  # is valid
275  #
276 
277  if nt_output_file != "":
278  if link_line_valid:
279  link_line = link_line + "/out:" + nt_output_file + " "
280  if do_ide_dump:
281  print "->IDE<- build_app " + nt_output_file
282  else:
283  cmd_line = cmd_line + "/Fo" + nt_output_file + " "
284  if do_ide_dump:
285  print "->IDE<- build_obj " + nt_output_file
286 
287  #
288  # If we are building the file, make sure that any .d files that are
289  # out there have their info put into the log file
290  #
291 
292  if do_ide_dump:
293  if (current_package != "") and (os.environ.has_key("SRT_TOP")):
294  (dir, name) = os.path.split (nt_output_file)
295  new_name = srt_path_util.change_to_type (name, "d")
296  d_filename = os.environ["SRT_TOP"] + "/tmp/" + os.environ["BFARCH"] + "/" + current_package + "/" + new_name
297  nt_d_filename = srt_ntbashutil.translate_path(d_filename)
298  if os.path.exists(nt_d_filename):
299  d_list = parse_dependency_file.parse_dependency_file (nt_d_filename, "/" + current_package + "/")
300  for fname in d_list:
301  if regex.match (".*/tmp/.*", fname) == -1:
302  print "->IDE<- h_filename " + srt_ntbashutil.compress_path(srt_ntbashutil.translate_path (fname))
303 
304  #
305  # If there were no source files and no link files, then we have a problem! If there were no source
306  # files but there were link files, then we will be wanting to do a link command, no a C++ compile
307  # command and the command options for the c++ compiler should be ignored!
308  #
309 
310  if (n_source_files == 0) and (n_link_files == 0):
311  sys.stderr.write("*** ERROR: No object or C/C++ source files specified!!!\n")
312  sys.stderr.flush()
313  return 2
314 
315  build_command = "cl"
316  if n_source_files == 0:
317  build_command = "link"
318  cmd_line = ""
319  link_line = "/nologo " + link_line
320  else:
321  link_line = "/link " + link_line
322 
323  #
324  # If a link is involved here, then add the various commands into the command line.
325  #
326 
327  if link_line_valid:
328  cmd_line = cmd_line + link_line
329 
330  #
331  # The nologo needs to appear first on some CL commands (don't totally understand why).
332  # However, when this is done, in ctbuild at least, the options don't come spilling out.
333  #
334 
335  have_nologo = 0
336  if string.find (cmd_line, "nologo") != -1:
337  cmd_line = "/nologo " + cmd_line
338 
339  #
340  # If we are dumping the IDE, don't really do anything here (afterall, we might crash cause the
341  # input files are dummy files also!!); just create the output files. Otherwise, execute the
342  # command, making sure to remember the result.
343  #
344 
345  result = 0
346  if do_ide_dump:
347  if nt_output_file == "":
348  sys.stderr.write("*** ERROR: No output file specified!\n")
349  sys.stderr.flush()
350  return 2
351  f_handle = open (nt_output_file, "w")
352  f_handle.write ("Temp File")
353  f_handle.close()
354  srt_ntide_dummy_files.record_temp_file (nt_output_file)
355  else:
356  if no_run == 0:
357  #
358  # Running a command line. Because the command line can get _very_ long, we have to write
359  # the command line to a temp file.
360  #
361  cmd_filename = tempfile.mktemp()
362  cmd_file_handle = open (cmd_filename, "w")
363  cmd_file_handle.write (cmd_line + "\n")
364  cmd_file_handle.close()
365  cmd_line_filename = tempfile.mktemp() + ".bat"
366  cmd_line_handle = open (cmd_line_filename, "w")
367  cmd_line_handle.write ("@ECHO OFF\n")
368  cmd_line_handle.write ("set LIB=%LIBNT%\n")
369  cmd_line_handle.write (build_command + " @" + cmd_filename + "\n")
370  cmd_line_handle.close()
371  sys.stdout.flush()
372  result = os.system(cmd_line_filename)
373  #os.unlink (cmd_filename)
374  #os.unlink (cmd_line_filename)
375  #
376  # The last thing to do is make sure that the execute bit set set on the
377  # output file if this was an executable
378  #
379  if link_line_valid:
380  os.system ("bash -c \"if [ -r " + raw_nt_output_file + " ]; then chmod a+x " + raw_nt_output_file + "; fi\"")
381  else:
382  print "Command was: " + build_command + " " + cmd_line + "\n"
383 
384  #
385  # Make sure to flush the output. This seems to be required under certian circumstances
386  # when running the b18 version of cygwin's bash util and piping the output of this script
387  # to a file from the gmake command line. :-)
388  #
389 
390  return result
391 
392 #
393 # fixup_no_conformist_includes
394 #
395 # Given a list of includes, look through them. If the modules are done correctly, then
396 # they should look like "modulename/modulename/..". That is fine. However, if they don't look
397 # like that, then remove the trailing ..s on them.
def main()
MAIN FUNCTION.
Definition: srt_ntcc.py:38
def file_type(the_path)
def translate_path(bash_path)
def is_absolute_path(path_name)
def compress_path(nt_path)

Variable Documentation

srt_ntcc.result = main()

Definition at line 414 of file srt_ntcc.py.