diff options
author | David Robillard <d@drobilla.net> | 2019-03-17 00:25:11 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-03-17 00:31:46 +0100 |
commit | 2696f818c530261b76cafa233fcd5fa65aeacec9 (patch) | |
tree | 9731bfc9a7a012523d996b702e1f62c91b17ead4 | |
parent | 902c176fd827226e03f4313582077413d24b2556 (diff) | |
download | autowaf-test-rewrite.tar.gz autowaf-test-rewrite.tar.bz2 autowaf-test-rewrite.zip |
Add command for running executables from the build directorytest-rewrite
-rw-r--r-- | extras/autowaf.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/extras/autowaf.py b/extras/autowaf.py index 297ca0b..4267c68 100644 --- a/extras/autowaf.py +++ b/extras/autowaf.py @@ -94,6 +94,11 @@ def set_options(opt, debug_by_default=False): dest='test_wrapper', help='command prefix for tests (e.g. valgrind)') + # Run options + run_opts = opt.add_option_group('Run options') + run_opts.add_option('--cmd', type='string', dest='cmd', + help='command to run from build directory') + class ConfigureContext(Configure.ConfigurationContext): """configures the project""" @@ -779,6 +784,25 @@ class ExecutionEnvironment: def __exit__(self, type, value, traceback): os.environ = self.original_environ +class RunContext(Build.BuildContext): + "runs an executable from the build directory" + cmd = 'run' + + def execute(self): + self.restore() + if not self.all_envs: + self.load_envs() + + with ExecutionEnvironment(self.env.AUTOWAF_RUN_ENV) as env: + if Options.options.verbose: + Logs.pprint('GREEN', str(env) + '\n') + + if Options.options.cmd: + Logs.pprint('GREEN', 'Running %s' % Options.options.cmd) + subprocess.call(Options.options.cmd, shell=True) + else: + Logs.error("error: Missing --cmd option for run command") + def show_diff(from_lines, to_lines, from_filename, to_filename): import difflib import sys |