aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-11-10 14:47:35 -0500
committerGitHub <noreply@github.com>2016-11-10 14:47:35 -0500
commite02aaad63286169aebf63109363fed648a185b05 (patch)
treea44ba27d19b09bd0b225a643f496c975007dc5a2
parentfd425d56a5680ab48d1cd03a140c249d90999a09 (diff)
parentb1898fd13959cbd49987efedef68a38ab9abb464 (diff)
downloadmeson-e02aaad63286169aebf63109363fed648a185b05.zip
meson-e02aaad63286169aebf63109363fed648a185b05.tar.gz
meson-e02aaad63286169aebf63109363fed648a185b05.tar.bz2
Merge pull request #1011 from centricular/runtarget-files-rel-builddir
ninja: Pass absolute path of files to run targets
-rw-r--r--mesonbuild/backend/ninjabackend.py6
-rwxr-xr-xrun_unittests.py8
-rwxr-xr-xtest cases/common/58 run target/check_exists.py7
-rw-r--r--test cases/common/58 run target/meson.build4
4 files changed, 20 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 3d378fe..76f47ab 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -515,10 +515,10 @@ int dummy;
arg_strings.append(os.path.join(self.environment.get_build_dir(), relfname))
deps.append(relfname)
elif isinstance(i, mesonlib.File):
- arg_strings.append(i.rel_to_builddir(self.build_to_src))
+ relfname = i.rel_to_builddir(self.build_to_src)
+ arg_strings.append(os.path.join(self.environment.get_build_dir(), relfname))
else:
- mlog.debug(str(i))
- raise MesonException('Unreachable code in generate_run_target.')
+ raise AssertionError('Unreachable code in generate_run_target: ' + str(i))
elem = NinjaBuildElement(self.all_outputs, target.name, 'CUSTOM_COMMAND', [])
cmd = runnerscript + [self.environment.get_source_dir(), self.environment.get_build_dir(), target.subdir]
texe = target.command
diff --git a/run_unittests.py b/run_unittests.py
index cf30276..8df0001 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -73,6 +73,9 @@ class LinuxlikeTests(unittest.TestCase):
def build(self):
self.output += subprocess.check_output(self.ninja_command)
+ def run_target(self, target):
+ self.output += subprocess.check_output(self.ninja_command + [target])
+
def setconf(self, arg):
self.output += subprocess.check_output(self.mconf_command + [arg, self.builddir])
@@ -173,5 +176,10 @@ class LinuxlikeTests(unittest.TestCase):
self.assertEqual(intro[0]['install_filename'], '/usr/local/libtest/libstat.a')
self.assertEqual(intro[1]['install_filename'], '/usr/local/bin/prog')
+ def test_run_target_files_path(self):
+ testdir = os.path.join(self.common_test_dir, '58 run target')
+ self.init(testdir)
+ self.run_target('check_exists')
+
if __name__ == '__main__':
unittest.main()
diff --git a/test cases/common/58 run target/check_exists.py b/test cases/common/58 run target/check_exists.py
new file mode 100755
index 0000000..62cbe23
--- /dev/null
+++ b/test cases/common/58 run target/check_exists.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+import os
+import sys
+
+if not os.path.isfile(sys.argv[1]):
+ raise Exception("Couldn't find {!r}".format(sys.argv[1]))
diff --git a/test cases/common/58 run target/meson.build b/test cases/common/58 run target/meson.build
index 5824c74..0540b80 100644
--- a/test cases/common/58 run target/meson.build
+++ b/test cases/common/58 run target/meson.build
@@ -35,8 +35,8 @@ python3 = find_program('python3')
run_target('py3hi',
command : [python3, '-c', 'print("I am Python3.")'])
-run_target('ct_in_arg',
- command : ['echo', hex, files('helloprinter.c')])
+run_target('check_exists',
+ command : [find_program('check_exists.py'), files('helloprinter.c')])
# What if the output of a custom_target is the command to
# execute. Obviously this will not work as hex is not an