gcc_path = 'gcc'
gcc_interaspect_lib = None
gcc_interaspect_src = None
+verbose = False
+
+# Note that \ _must_ be first in this list, or else \s added for the
+# purpose of escaping will themselves get escaped.
+BASH_ESCAPED_CHARS = """\ *~"&`$';!|#<>"""
+
+def escapeBashArg(arg):
+ for char in BASH_ESCAPED_CHARS:
+ arg = arg.replace(char, "\\" + char)
+ return arg
# A whole host of specialized exceptions for things that can go
# horribly wrong with the input XML test case.
# If the compile fails because of an error in the C file, runGCC also
# prints compile_fail_msg.
def runGCC(args, compile_fail_msg):
+ # Print the GCC command before running it when verbose mode is on.
+ if verbose:
+ print escapeBashArg(gcc_path),
+ for arg in args:
+ print escapeBashArg(arg),
+ print
+
args = [gcc_path] + args
try:
gcc_proc = subprocess.Popen(args, stderr = subprocess.PIPE)
if __name__ == '__main__':
# Deal with command line arguments
try:
- long_switches = ["with-gcc=", "with-ia-lib-dir=", "with-ia-src-dir="]
- opts, args = getopt.gnu_getopt(sys.argv[1:], "", long_switches)
+ long_switches = ["verbose", "with-gcc=", "with-ia-lib-dir=",
+ "with-ia-src-dir="]
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "v", long_switches)
except getopt.GetoptError:
usage()
sys.exit(1)
gcc_interaspect_lib = arg + '/libinteraspect.a'
elif (opt == "--with-ia-src-dir"):
gcc_interaspect_src = arg
+ elif (opt == "--verbose" or opt == "-v"):
+ verbose = True
else:
assert(1)