aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-04-29 13:00:41 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-04-30 10:01:14 -0700
commitc239ce31f55579cfe1e29b769a8bda97deca2166 (patch)
tree662fd0261ff22bc0856a0f0ad6e249526f96de64
parent2c0eaf5c4f4493146355eeb8521c17a3c2ef5acd (diff)
downloadmeson-c239ce31f55579cfe1e29b769a8bda97deca2166.zip
meson-c239ce31f55579cfe1e29b769a8bda97deca2166.tar.gz
meson-c239ce31f55579cfe1e29b769a8bda97deca2166.tar.bz2
allow postconf and dist scripts to use Files, ExternalPrograms, and
ConfigureFiles These things are all known to be ready when these scripts are run, and thus they can safely consume them.
-rw-r--r--mesonbuild/interpreter.py14
-rw-r--r--test cases/common/104 postconf with args/meson.build7
-rw-r--r--test cases/unit/35 dist script/meson.build1
3 files changed, 15 insertions, 7 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 2b699f8..b525690 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1920,7 +1920,7 @@ class MesonMain(InterpreterObject):
str, mesonlib.File, CustomTargetHolder,
CustomTargetIndexHolder, ConfigureFileHolder,
ExternalProgramHolder, ExecutableHolder,
- ]]) -> T.List[str]:
+ ]], allow_built: bool = False) -> T.List[str]:
script_args = [] # T.List[str]
new = False
for a in args:
@@ -1931,6 +1931,8 @@ class MesonMain(InterpreterObject):
new = True
script_args.append(a.rel_to_builddir(self.interpreter.environment.source_dir))
elif isinstance(a, (build.BuildTarget, build.CustomTarget, build.CustomTargetIndex)):
+ if not allow_built:
+ raise InterpreterException('Arguments to {} cannot be built'.format(name))
new = True
script_args.extend([os.path.join(a.get_subdir(), o) for o in a.get_outputs()])
@@ -1961,7 +1963,7 @@ class MesonMain(InterpreterObject):
def add_install_script_method(self, args: 'T.Tuple[T.Union[str, ExecutableHolder], T.Union[str, mesonlib.File, CustomTargetHolder, CustomTargetIndexHolder, ConfigureFileHolder], ...]', kwargs):
if len(args) < 1:
raise InterpreterException('add_install_script takes one or more arguments')
- script_args = self._process_script_args('add_install_script', args[1:])
+ script_args = self._process_script_args('add_install_script', args[1:], allow_built=True)
script = self._find_source_script(args[0], script_args)
self.build.install_scripts.append(script)
@@ -1969,8 +1971,8 @@ class MesonMain(InterpreterObject):
def add_postconf_script_method(self, args, kwargs):
if len(args) < 1:
raise InterpreterException('add_postconf_script takes one or more arguments')
- check_stringlist(args, 'add_postconf_script arguments must be strings')
- script = self._find_source_script(args[0], args[1:])
+ script_args = self._process_script_args('add_postconf_script', args[1:], allow_built=True)
+ script = self._find_source_script(args[0], script_args)
self.build.postconf_scripts.append(script)
@permittedKwargs(set())
@@ -1979,10 +1981,10 @@ class MesonMain(InterpreterObject):
raise InterpreterException('add_dist_script takes one or more arguments')
if len(args) > 1:
FeatureNew('Calling "add_dist_script" with multiple arguments', '0.49.0').use(self.interpreter.subproject)
- check_stringlist(args, 'add_dist_script argumetn must be a string')
if self.interpreter.subproject != '':
raise InterpreterException('add_dist_script may not be used in a subproject.')
- script = self._find_source_script(args[0], args[1:])
+ script_args = self._process_script_args('add_dist_script', args[1:], allow_built=True)
+ script = self._find_source_script(args[0], script_args)
self.build.dist_scripts.append(script)
@noPosargs
diff --git a/test cases/common/104 postconf with args/meson.build b/test cases/common/104 postconf with args/meson.build
index 8510c5b..a34502c 100644
--- a/test cases/common/104 postconf with args/meson.build
+++ b/test cases/common/104 postconf with args/meson.build
@@ -1,5 +1,10 @@
project('postconf script', 'c')
-meson.add_postconf_script('postconf.py', '5', '33')
+conf = configure_file(
+ configuration : configuration_data(),
+ output : 'out'
+)
+
+meson.add_postconf_script(find_program('postconf.py'), '5', '33', conf)
test('post', executable('prog', 'prog.c'))
diff --git a/test cases/unit/35 dist script/meson.build b/test cases/unit/35 dist script/meson.build
index fd672a9..2ae9438 100644
--- a/test cases/unit/35 dist script/meson.build
+++ b/test cases/unit/35 dist script/meson.build
@@ -5,3 +5,4 @@ exe = executable('comparer', 'prog.c')
test('compare', exe)
meson.add_dist_script('replacer.py', '"incorrect"', '"correct"')
+meson.add_dist_script(find_program('replacer.py'), '"incorrect"', '"correct"')