Functions | Variables
srt_nt_example_command Namespace Reference

Functions

def main ()
 MAIN FUNCTION. More...
 
def construct_temp_file_name (source_name)
 

Variables

 result = main()
 

Function Documentation

def srt_nt_example_command.construct_temp_file_name (   source_name)

Definition at line 247 of file srt_nt_example_command.py.

247 def construct_temp_file_name (source_name):
248  #
249  # Strip off the extension...
250  #
251  (base_dir, file_name) = os.path.split (source_name)
252  (basename, ext) = os.path.splitext (file_name)
253  return basename + "_pp.f"
254 
255 
256 #
257 # Execute the routine and let the shell know what happened. We protect it so that
258 # it can be compiled when copied over into the bin area during a release (and, most
259 # importantly, precompiled to speed its use) but not actually be run.
260 #
def construct_temp_file_name(source_name)
def srt_nt_example_command.main ( )

MAIN FUNCTION.

1D plots hits vs w //

Definition at line 38 of file srt_nt_example_command.py.

References srt_ntbashutil.compress_path(), srt_path_util.file_type(), srt_ntf77.translate_command(), and srt_ntbashutil.translate_path().

38 def main():
39 
40  #
41  # I've written (along with everyone else in the world) something to help me
42  # process command line options. You don't have to use it, but it does make
43  # life simpler. I think the python library has something too, but I've not
44  # had a chance to look at it yet.
45  #
46 
47  cmd_options = srt_options_line.options_line (sys.argv[1:])
48 
49  #
50  # If no arguments were handed to us, whine. If there is an error, make sure
51  # to return a non-zero value from main. This is so that gmake and the other
52  # things invoking this can quickly see that a command has failed and halt
53  # the build process.
54  #
55 
56  if cmd_options.length() == 0:
57  sys.stderr.write("Usage: " + sys.argv[0] + " <arguments>\n")
58  return 1
59 
60  #
61  # Init some vars we use to build up the real command that we are going to
62  # be executing. cmd_line will contain the final command line.
63  #
64 
65  cmd_line = ""
66  output_file = ""
67 
68  #
69  # If the environment var IDE_DUMP is defined, then we are in the middle of
70  # an ntide_build command. The value of IDE_DUMP is the filename where all
71  # the text is being written (usually ide_dump.txt at the local_release top
72  # level directory -- read this file to see what is going on). Because the
73  # filename is created in UNIX, it must be put into a path form that python
74  # can hack (the translate_path function).
75  #
76 
77  do_ide_dump = 0
78  if os.environ.has_key("IDE_DUMP"):
79  f_name = srt_ntbashutil.translate_path(os.environ["IDE_DUMP"])
80  sys.stdout = open (f_name, "a+")
81  do_ide_dump = 1
82 
83  #
84  # If we are doing a dump, indicate we are starting a new command (the "*"
85  # line).
86  #
87  # working_dir is the location we are running from. If the dump processor has
88  # to calculate relative paths, it will do so relative to this working_dir
89  # directory.
90  #
91 
92  if do_ide_dump:
93  print "->IDE<- *compile_special_command"
94  print "->IDE<- working_dir " + os.getcwd()
95 
96  #
97  # Now, loop over all the arguments in the command line.
98  #
99 
100  while cmd_options.has_more_options():
101  option = cmd_options.get_next_option ("this should never fail!")
102 
103  #
104  # A standard UNIX flag begins with a "-" (-I /gtwd0/include_dir for example).
105  #
106 
107  if option[0] == "-":
108  option = option[1:]
109 
110  #
111  # I -- An include directory. This gets a little tricky because the include
112  # directory may contain a whole slew of symbolic links. If linked against
113  # ms libraries, this just won't fly. Soooo, we have to expand the list.
114  # The resolve_bash_aliases routine does just that.
115  #
116  # compress_path makes sure that there aren't funning things like
117  # double "/"s in the path (not likely at this point).
118  #
119 
120  if option[0] == "I":
121  translated_path = srt_ntbashutil.translate_path (option[1:])
122  nt_path_list = srt_ntbashutil.resolve_bash_aliases (translated_path)
123 
124  for path in nt_path_list:
125  c_path = srt_ntbashutil.compress_path(path)
126  cmd_line = cmd_line + "/I " + c_path + " "
127 
128  #
129  # D -- Deifne a C macro symbol
130  #
131 
132  elif option[0] == "D":
133  cmd_line = gcc_cmd_line + "/D" + option[1:] + " "
134 
135  #
136  # o -- The output file. Once you know the location of the file, you
137  # write "build_file" to the IDE log to specify it. You can have as many
138  # of these as you want for one command.
139  #
140 
141  elif option[0] == "o":
142  unix_output_file = cmd_options.get_next_option("output file name")
143  output_file = srt_ntbashutil.translate_path(unix_output_file)
144  if do_ide_dump:
145  print "->IDE<- build_file " + output_file
146 
147  #
148  # Sometimes it is useful to specify some NT specific options someplace
149  # in your .mk file (like arc_speck.mk's NT section) and pass them directly
150  # through. The following code does that for you.
151  #
152 
153  elif option[0:2] == "NT":
154  cmd_line = cmd_line + "/" + option[2:] + " "
155  if do_ide_dump:
156  print "->IDE<- option " + option[2:]
157 
158  #
159  # Game over. Wonder what this option was supposed to be?
160  #
161 
162  else:
163  sys.stderr.write("**\n");
164  sys.stderr.write("**WARNING: Unkown gcc option in ntf77.py!!: -" + option + "\n")
165  sys.stderr.write("**\n");
166 
167  #
168  # Ok, come here if it wasn't an option
169  #
170 
171  else:
172 
173  nt_path = srt_ntbashutil.translate_path (option)
174 
175  #
176  # There are some tricks when dealing with files -- not that .a files
177  # aren't valid here -- they are .lib files. A .a file does exist, but it
178  # is just a dummy. So watch for that if you expect library files to
179  # be passed to you. Example below.
180  #
181 
182  file_type = srt_path_util.file_type(nt_path)
183  if file_type == "a":
184  nt_path = srt_path_util.change_to_type (nt_path, "lib")
185 
186  #
187  # Tell the ide about a source file. You can have more than one of
188  # these, of course. These files will be listed as the things your output
189  # file depends upon...
190  #
191 
192  cmd_line = cmd_line + " " + nt_path
193  if do_ide_dump:
194  print "->IDE<- source_file " + nt_path
195 
196  #
197  # Done with the processing of the command line. cmd_line how has a valid command
198  # in it.
199  #
200  # First question, if this is a IDE build and an output file is expected by
201  # make (i.e., it won't function without it), then we need to build a dummy
202  # output file.
203  #
204 
205  if do_ide_dump:
206  if output_file == "":
207  sys.stderr.write("*** ERROR: No output file specified!\n")
208  sys.stderr.flush()
209  return 2
210  f_handle = open (output_file, "w")
211  f_handle.write ("Temp File")
212  f_handle.close()
213 
214  #
215  # Run the commands. If we are doing an IDE file, only make sure they
216  # get into the IDE text file. Replace the various strings that need to
217  # be replaced...
218  #
219  # You can write out as many of these special_commands as you need (see
220  # the routine below for generating temp filenames). Be aware that NT doesn't
221  # like having a command line more than 5K charachters long. To get around this
222  # you'll have to put command line options in a file. Unfortunately, there is
223  # no automatic way to do this yet. Sorry.
224  #
225 
226  result = 0
227  full_df_command = "my_cmd " + cmd_line + " " + input_file_name
228  if do_ide_dump:
229  print "->IDE<- special_command " + full_df_command
230  else:
231  result = os.system(translate_command(full_df_command,sub_dict))
232 
233  #
234  # Make sure to return the result of trying to run those commands so that
235  # we transmit our status back to the shell!
236  #
237 
238  return result
239 
240 #
241 # construct_temp_file_name
242 #
243 # Build a temp filename outta the given name. The temp filename will end with
244 # _pp.f. Use a routine like this if you want to create a temp file internal
245 # to the command. If you don't need it, you can get rid of it.
246 #
def file_type(the_path)
def translate_command(string, sub_dict)
Definition: srt_ntf77.py:279
def translate_path(bash_path)
def compress_path(nt_path)
def main()
MAIN FUNCTION.

Variable Documentation

srt_nt_example_command.result = main()

Definition at line 262 of file srt_nt_example_command.py.