gcc_path = 'gcc'
gcc_interaspect_lib = None
gcc_interaspect_src = None
+tests_dir = None
verbose = False
# Note that \ _must_ be first in this list, or else \s added for the
self.current_cdata += chars
+# If the tests_dir is set, prepend the tests_dir directory to the name
+# of the source file.
+def formatSourceFile(source_file):
+ if (tests_dir is not None):
+ return '{0:s}/{1:s}'.format(tests_dir, source_file)
+ else:
+ return source_file
+
# Run GCC with the given arguments. On failure, print an appropriate
# error and return False.
# If the compile fails because of an error in the C file, runGCC also
plugin_lib_name = '{0:s}/{1:s}.so.1.0.0'.format(working_dir,
plugin_base_name)
-
+ plugin_source = formatSourceFile(plugin_source)
include_flag = '-I{0:s}/src'.format(gcc_interaspect_src)
cmd_args = ['-Wall', '-Werror', include_flag, '-fPIC', '-shared',
'-Wl,-soname,{0:s}.so.1'.format(plugin_base_name), '-o',
# executable (which will be in working_dir). On failure, the return
# value is None.
def compileTestcase(working_dir, target_source, hooks_source, plugin_libs):
+ hooks_source = formatSourceFile(hooks_source)
test_include = '-I{0:s}/test'.format(gcc_interaspect_src)
hook_o_file = working_dir + '/hooks.o'
cmd_args = ['-Wall', '-Werror', test_include, '-c', '-o', hook_o_file,
return None
# Compile the target itself.
+ target_source = formatSourceFile(target_source)
target_o_file = working_dir + '/target.o'
cmd_args = ['-fplugin={0:s}'.format(lib) for lib in plugin_libs]
cmd_args += ['-Wall', '-Werror', '-c', '-o', target_o_file, target_source]
--with-gcc: Path to gcc to compile the tests with
--with-ia-lib-dir: Directory with InterAspect library file
--with-ia-src-dir: Directory with InterAspect source
+ --with-tests-dir: Directory with test C files (. by default)
""")
# End function usage()
# Deal with command line arguments
try:
long_switches = ["verbose", "with-gcc=", "with-ia-lib-dir=",
- "with-ia-src-dir="]
+ "with-ia-src-dir=", "with-tests-dir="]
opts, args = getopt.gnu_getopt(sys.argv[1:], "v", long_switches)
except getopt.GetoptError:
usage()
gcc_interaspect_lib = arg + '/libinteraspect.a'
elif (opt == "--with-ia-src-dir"):
gcc_interaspect_src = arg
+ elif (opt == "--with-tests-dir"):
+ tests_dir = arg
elif (opt == "--verbose" or opt == "-v"):
verbose = True
else: