diff --git a/interpreter.py b/interpreter.py index 5da6d8b35..b6e98ddb0 100644 --- a/interpreter.py +++ b/interpreter.py @@ -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 diff --git a/ninjabackend.py b/ninjabackend.py index 01223abcf..b9eef193b 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -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') diff --git a/test cases/common/58 run target/helloprinter.c b/test cases/common/58 run target/helloprinter.c index 7f94b19fa..4a6e0ac5d 100644 --- a/test cases/common/58 run target/helloprinter.c +++ b/test cases/common/58 run target/helloprinter.c @@ -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]); }