Can set build targets as arguments to run_target. Closes #270.

pull/272/head
Jussi Pakkanen 9 years ago
parent d23e59ed5f
commit d4a922c21a
  1. 8
      interpreter.py
  2. 7
      ninjabackend.py
  3. 1
      test cases/common/58 run target/helloprinter.c

@ -1466,6 +1466,7 @@ class Interpreter():
def func_run_target(self, node, args, kwargs):
if len(args) < 2:
raise InterpreterException('Incorrect number of arguments')
cleaned_args = []
for i in args:
try:
i = i.held_object
@ -1474,9 +1475,10 @@ class Interpreter():
if not isinstance(i, (str, build.BuildTarget)):
mlog.debug('Wrong type:', str(i))
raise InterpreterException('Invalid argument to run_target.')
name = args[0]
command = args[1]
cmd_args = args[2:]
cleaned_args.append(i)
name = cleaned_args[0]
command = cleaned_args[1]
cmd_args = cleaned_args[2:]
tg = RunTargetHolder(name, command, cmd_args, self.subdir)
self.add_target(name, tg.held_object)
return tg

@ -345,8 +345,11 @@ class NinjaBackend(backends.Backend):
if isinstance(i, str):
arg_strings.append(i)
elif isinstance(i, build.BuildTarget):
deps.append(self.get_target_filename(i))
relfname = self.get_target_filename(i)
deps.append(relfname)
arg_strings.append(os.path.join(self.environment.get_build_dir(), relfname))
else:
mlog.debug(str(i))
raise MesonException('Unreachable code.')
elem = NinjaBuildElement(target.name, 'CUSTOM_COMMAND', deps)
cmd = [sys.executable, runnerscript, self.environment.get_source_dir(), self.environment.get_build_dir(), target.subdir]
@ -364,7 +367,7 @@ class NinjaBackend(backends.Backend):
cmd.append(abs_exe)
else:
cmd.append(target.command)
cmd += target.args
cmd += arg_strings
elem.add_item('COMMAND', cmd)
elem.add_item('description', 'Running external command %s.' % target.name)
elem.add_item('pool', 'console')

@ -3,6 +3,7 @@
int main(int argc, char **argv) {
if(argc != 2) {
printf("I can not haz argument.\n");
return 1;
} else {
printf("I can haz argument: %s\n", argv[1]);
}

Loading…
Cancel
Save