From 9f9f73fa5208bdabed5fae59af0b0b0e7d177dec Mon Sep 17 00:00:00 2001 From: Nicolas Schneider Date: Tue, 1 Mar 2016 14:31:37 +0100 Subject: [PATCH] add args support for add_postconf_script --- mesonbuild/backend/backends.py | 2 +- mesonbuild/interpreter.py | 3 ++- .../common/108 postconf with args/meson.build | 5 +++++ .../common/108 postconf with args/postconf.py | 13 +++++++++++++ test cases/common/108 postconf with args/prog.c | 5 +++++ test cases/common/108 postconf with args/raw.dat | 1 + 6 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 test cases/common/108 postconf with args/meson.build create mode 100644 test cases/common/108 postconf with args/postconf.py create mode 100644 test cases/common/108 postconf with args/prog.c create mode 100644 test cases/common/108 postconf with args/raw.dat diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 9b3cef4f3..311e16cb1 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -439,5 +439,5 @@ class Backend(): def run_postconf_scripts(self): for s in self.build.postconf_scripts: - cmd = s.get_command() + [self.environment.get_source_dir(), self.environment.get_build_dir()] + cmd = s['exe'].get_command() + [self.environment.get_source_dir(), self.environment.get_build_dir()] + s['args'] subprocess.check_call(cmd) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 81bb768c9..6f6579018 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -819,7 +819,8 @@ class MesonMain(InterpreterObject): search_dir = os.path.join(self.interpreter.environment.source_dir, self.interpreter.subdir) exe = dependencies.ExternalProgram(scriptbase, search_dir=search_dir) - self.build.postconf_scripts.append(exe) + extras = mesonlib.stringlistify(kwargs.get('args', [])) + self.build.postconf_scripts.append({'exe': exe, 'args': extras}) def current_source_dir_method(self, args, kwargs): src = self.interpreter.environment.source_dir diff --git a/test cases/common/108 postconf with args/meson.build b/test cases/common/108 postconf with args/meson.build new file mode 100644 index 000000000..74006f46d --- /dev/null +++ b/test cases/common/108 postconf with args/meson.build @@ -0,0 +1,5 @@ +project('postconf script', 'c') + +meson.add_postconf_script('postconf.py', args: ['5', '33']) + +test('post', executable('prog', 'prog.c')) diff --git a/test cases/common/108 postconf with args/postconf.py b/test cases/common/108 postconf with args/postconf.py new file mode 100644 index 000000000..b229d62e2 --- /dev/null +++ b/test cases/common/108 postconf with args/postconf.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys, os + +template = '''#pragma once + +#define THE_NUMBER {} +#define THE_ARG1 {} +#define THE_ARG2 {} +''' + +data = open(os.path.join(sys.argv[1], 'raw.dat')).readline().strip() +open(os.path.join(sys.argv[2], 'generated.h'), 'w').write(template.format(data, sys.argv[3], sys.argv[4])) diff --git a/test cases/common/108 postconf with args/prog.c b/test cases/common/108 postconf with args/prog.c new file mode 100644 index 000000000..0e63a8c5c --- /dev/null +++ b/test cases/common/108 postconf with args/prog.c @@ -0,0 +1,5 @@ +#include"generated.h" + +int main(int argc, char **argv) { + return THE_NUMBER != 9 || THE_ARG1 != 5 || THE_ARG2 != 33; +} diff --git a/test cases/common/108 postconf with args/raw.dat b/test cases/common/108 postconf with args/raw.dat new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/test cases/common/108 postconf with args/raw.dat @@ -0,0 +1 @@ +9