summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-17 00:25:11 +0100
committerDavid Robillard <d@drobilla.net>2019-03-17 10:42:22 +0100
commit8280f9de69f93624896b8875caf039066cac0314 (patch)
treee63cbd3f7bb8c0765390f8150e94487af9184ba3
parent8073c1adcb7eaf23de38abd44b4d76d57747f86b (diff)
downloadautowaf-8280f9de69f93624896b8875caf039066cac0314.tar.gz
autowaf-8280f9de69f93624896b8875caf039066cac0314.tar.bz2
autowaf-8280f9de69f93624896b8875caf039066cac0314.zip
Add command for running executables from the build directory
-rw-r--r--extras/autowaf.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/extras/autowaf.py b/extras/autowaf.py
index cc6e780..51077d1 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