def main(argv=None): # Default to not being verbose with error messages # If debug is true, then when an error occurs during parsing, # the Python backtrace will be shown in addition to the XML location # where the error occurred. debug = False verbose = False # degs is off by default # If degs is true then the output in case of error is formatted for parsing by DEGS degs = False compileScript = True noVersionInformation = False # Import version information from Preferences import versionString from Version import subversionRevisionString print "xmds2 version %(versionString)s (%(subversionRevisionString)s)" % locals() print "Copyright 2000-2014 Graham Dennis, Joseph Hope, Mattias Johnsson" print " and the xmds team" if not os.path.isdir(xpdeintUserDataPath): os.mkdir(xpdeintUserDataPath) # Attempt to parse command line arguments if argv is None: argv = sys.argv try: try: opts, args = getopt.gnu_getopt( argv[1:], "gvhno:", [ "debug", "verbose", "help", "no-compile", "output=", "no-version", "configure", "reconfigure", "include-path=", "lib-path=", "waf-verbose", "degs" # This option is not documented and is intended only for use by DEGS, a Mac GUI for XMDS ] ) del sys.argv[1:] except getopt.error, msg: raise Usage(msg) includePaths = [] libPaths = [] run_config = False run_reconfig = False sourceFilename = None # option processing for option, value in opts: if option in ("-g", "--debug"): debug = verbose = True elif option in ('-v', '--verbose'): verbose = True elif option in ('--degs'): degs = True elif option == "--waf-verbose": Configuration.Logs.verbose = 3 elif option in ("-h", "--help"): raise Usage(help_message) elif option in ("-o", "--output"): sourceFilename = value elif option in ("-n", "--no-compile"): compileScript = False elif option == "--no-version": # This option is here for the test suite so that the generated source files don't # contain version information. This makes it easier to check if the source for a script # has changed as otherwise it would change every time the subversison revision number # increased noVersionInformation = True elif option == "--configure": run_config = True elif option == '--reconfigure': run_reconfig = True elif option == '--include-path': includePaths.append(value) elif option == '--lib-path': libPaths.append(value) if run_config: return Configuration.run_config(includePaths, libPaths) elif run_reconfig or includePaths or libPaths: return Configuration.run_reconfig(includePaths, libPaths) # argument processing if len(args) == 1: scriptName = args[0] else: raise Usage(help_message)
except Usage, err: print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg) print >> sys.stderr, "\t for help use --help" return 2 wscript_path = resource_filename(__name__, 'support/wscript') wscript_userdata_path = os.path.join(xpdeintUserDataPath, 'wscript') waf_build_cache_path = os.path.join(xpdeintUserDataPath, 'waf_configure/c4che/_cache.py') if not os.path.isfile(wscript_userdata_path) or \ fileContentsHash(wscript_userdata_path) != fileContentsHash(wscript_path) or \ not os.path.exists(waf_build_cache_path): print "Reconfiguring xmds2 (updated config script)..." Configuration.run_reconfig() # globalNameSpace is a dictionary of variables that are available in all # templates globalNameSpace = {'scriptName': scriptName, 'simulationName': os.path.splitext(scriptName)[0]} if noVersionInformation: versionString = "VERSION_PLACEHOLDER" subversionRevisionString = "SUBVERSION_REVISION_PLACEHOLDER" # Open the script file try: scriptFile = file(scriptName) except Exception, err: print >> sys.stderr, "Exception raised while trying to read xmds script:", err return -1