Functions | Variables
srt_ntlib Namespace Reference

Functions

def main ()
 MAIN FUNCTION. More...
 

Variables

 result = main()
 

Function Documentation

def srt_ntlib.main ( )

MAIN FUNCTION.

1D plots hits vs w //

Definition at line 35 of file srt_ntlib.py.

References srt_ntbashutil.translate_path().

35 def main():
36  #
37  # Get the command line up and going
38  #
39 
40  cmd_options = srt_options_line.options_line (sys.argv[1:])
41 
42  if cmd_options.length() == 0:
43  print "Usage: " + sys.argv[0] + " <arguments>"
44  return 1
45 
46  nt_cmd_line = "/nologo "
47  ar_cmd_line = ""
48 
49  temp_files = [];
50  if os.environ.has_key("temp"):
51  temp_dir = os.environ["temp"]
52  else:
53  temp_dir = os.environ["TEMP"]
54 
55  #
56  # Are we dumping for IDE stuff, or actually executing the command?
57  #
58 
59  do_ide_dump = 0
60  if os.environ.has_key("IDE_DUMP"):
61  sys.stdout = open (srt_ntbashutil.translate_path(os.environ["IDE_DUMP"]), "a+")
62  do_ide_dump = 1
63 
64  #
65  # Init some flags
66  #
67 
68  execute_commands = 1
69 
70  #
71  # The lib command first has an option, which determines its overall behavior.
72  #
73 
74  master_options = cmd_options.get_next_option ("LIB Command Option")
75  while master_options[0] == "-":
76  option = master_options[1:]
77  if option == "NTNoRun":
78  execute_commands = 0
79  else:
80  sys.stderr.write ("***ERROR: Unknown option " + option + ".\n");
81  return 1
82  master_options = cmd_options.get_next_option ("LIB Command Option")
83 
84  master_directive = master_options[0]
85 
86  #
87  # Dump out for the IDE?
88  #
89 
90  if do_ide_dump:
91  print "->IDE<- *library"
92  print "->IDE<- working_dir " + os.getcwd()
93  if os.environ.has_key("CURPKG"):
94  print "->IDE<- package_name " + os.environ["CURPKG"]
95 
96  #
97  # Now, start in for sure!
98  #
99 
100  if master_directive == "r":
101 
102  if do_ide_dump:
103  print "->IDE<- add_and_create"
104 
105  #
106  # Update. Make sure the library is an input file if it already exists!
107  #
108 
109  lib_file_raw = cmd_options.get_next_option ("Library filename")
110  ar_lib_file = srt_ntbashutil.translate_path (lib_file_raw)
111  nt_lib_file = srt_path_util.change_to_type (ar_lib_file, "lib")
112 
113  nt_cmd_line = nt_cmd_line + "/out:" + nt_lib_file + " "
114  ar_cmd_line = "r " + lib_file_raw + " "
115 
116  if do_ide_dump:
117  print "->IDE<- library_file " + nt_lib_file
118 
119  #
120  # It should never be the case that we have a .a file but no .lib file. If we do, then
121  # get rid of the .a file and crash. If we have no .a file but a .lib file, just delete
122  # the .lib file.
123  #
124 
125  nt_exists = os.path.exists (nt_lib_file)
126  ar_exists = os.path.exists (ar_lib_file)
127 
128  if nt_exists and (not ar_exists):
129  os.remove (nt_lib_file)
130  nt_exists = 0
131 
132  if (not nt_exists) and ar_exists:
133  os.remove (ar_lib_file)
134  print "*** ERROR: .a file exists but there is no matching .lib file! Restart build!"
135  return 100
136 
137  #
138  # If the .lib file is there, we need to make sure that the NT lib utility reads it as input
139  # so the output files is really just the input + a new module!
140  #
141 
142  if nt_exists:
143  nt_cmd_line = nt_cmd_line + nt_lib_file + " "
144 
145  #
146  # Now, process all the extra files on the command line to add them to the library.
147  # Into the ar archive put a dummy text file.
148  #
149 
150  while cmd_options.has_more_options():
151  file_to_add_raw = cmd_options.get_next_option ("File to insert")
152  file_to_add = srt_ntbashutil.translate_path (file_to_add_raw)
153 
154  #(base_dir, fname) = os.path.split (file_to_add_raw)
155  #temp_file_name = os.path.join (temp_dir, fname)
156  #temp_files.append (temp_file_name)
157  #t_handle = open (temp_file_name, "w")
158  #t_handle.write ("This is a dummy file")
159  #t_handle.close ()
160 
161  nt_cmd_line = nt_cmd_line + file_to_add + " "
162  ar_cmd_line = ar_cmd_line + file_to_add_raw + " "
163 
164  if do_ide_dump:
165  if regex.search("^/.*$", file_to_add_raw) == 0:
166  print "->IDE<- add_file " + file_to_add
167  else:
168  print "->IDE<- add_file " + os.getcwd() + "\\" + file_to_add
169 
170  else:
171  print "*** WARNING: Unrecognized option to the ntlib command!"
172  return 1;
173 
174  #
175  # If this is only a dummy, only do the ar command, not the lib
176  #
177 
178  result = 0
179  if not do_ide_dump:
180  if execute_commands:
181  result = os.system ("lib " + nt_cmd_line)
182  else:
183  print "Execute: lib " + nt_cmd_line
184  else:
185  if not nt_exists:
186  n_lib_handle = open (nt_lib_file, "w")
187  n_lib_handle.write ("this is a test")
188  n_lib_handle.close()
189  srt_ntide_dummy_files.record_temp_file (nt_lib_file)
190 
191  if (result == 0):
192  if execute_commands:
193  result = os.system ("ar " + ar_cmd_line)
194  else:
195  print "Execute: ar " + ar_cmd_line
196 
197  #
198  # Get rid of any of the temporary files that were created!
199  #
200 
201  for temp_name in temp_files:
202  if os.path.exists (temp_name):
203  os.remove (temp_name)
204 
205  #
206  # Flush the output stream. Have to do this due to a possible bug in cygwin (b18)'s bash shell
207  # in which gmake's output is redirected to a file... this guy's output seems to dissapear.
208  #
209 
210  sys.stdout.close()
211 
212  return result
213 
214 #
215 # Execute the routine and let the shell know what happened.
216 #
def translate_path(bash_path)
def main()
MAIN FUNCTION.
Definition: srt_ntlib.py:35

Variable Documentation

srt_ntlib.result = main()

Definition at line 218 of file srt_ntlib.py.