diff options
-rw-r--r-- | mesonbuild/backend/backends.py | 6 | ||||
-rw-r--r-- | mesonbuild/build.py | 1 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 12 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 1 | ||||
-rw-r--r-- | test cases/common/107 postconf/meson.build | 5 | ||||
-rw-r--r-- | test cases/common/107 postconf/postconf.py | 11 | ||||
-rw-r--r-- | test cases/common/107 postconf/prog.c | 5 | ||||
-rw-r--r-- | test cases/common/107 postconf/raw.dat | 1 | ||||
-rw-r--r-- | test cases/common/108 postconf with args/meson.build | 5 | ||||
-rw-r--r-- | test cases/common/108 postconf with args/postconf.py | 13 | ||||
-rw-r--r-- | test cases/common/108 postconf with args/prog.c | 5 | ||||
-rw-r--r-- | test cases/common/108 postconf with args/raw.dat | 1 |
12 files changed, 66 insertions, 0 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index b869008..311e16c 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -17,6 +17,7 @@ from .. import build from .. import dependencies from .. import mesonlib import json +import subprocess from ..coredata import MesonException class InstallData(): @@ -435,3 +436,8 @@ class Backend(): cmd.append(i) cmd = [i.replace('\\', '/') for i in cmd] return (srcs, ofilenames, cmd) + + def run_postconf_scripts(self): + for s in self.build.postconf_scripts: + 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/build.py b/mesonbuild/build.py index c96a69f..315e4bc 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -98,6 +98,7 @@ class Build: self.pot = [] self.subprojects = {} self.install_scripts = [] + self.postconf_scripts = [] self.install_dirs = [] self.dep_manifest_name = None self.dep_manifest = {} diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index ffd4689..62b7fc0 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -795,6 +795,7 @@ class MesonMain(InterpreterObject): 'source_root' : self.source_root_method, 'build_root' : self.build_root_method, 'add_install_script' : self.add_install_script_method, + 'add_postconf_script' : self.add_postconf_script_method, 'install_dependency_manifest': self.install_dependency_manifest_method, 'project_version': self.project_version_method, }) @@ -810,6 +811,17 @@ class MesonMain(InterpreterObject): raise InterpreterException('Can not find install script %s.' % scriptbase) self.build.install_scripts.append(build.InstallScript([scriptfile])) + def add_postconf_script_method(self, args, kwargs): + if len(args) < 1: + raise InterpreterException('Not enough arguments') + check_stringlist(args, 'add_postconf_script arguments must be strings.') + scriptbase = args[0] + search_dir = os.path.join(self.interpreter.environment.source_dir, + self.interpreter.subdir) + exe = dependencies.ExternalProgram(scriptbase, search_dir=search_dir) + extras = args[1:] + self.build.postconf_scripts.append({'exe': exe, 'args': extras}) + def current_source_dir_method(self, args, kwargs): src = self.interpreter.environment.source_dir sub = self.interpreter.subdir diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 543a31f..95e6731 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -168,6 +168,7 @@ itself as required.''' intr.run() env.dump_coredata() g.generate(intr) + g.run_postconf_scripts() dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat') pickle.dump(b, open(dumpfile, 'wb')) diff --git a/test cases/common/107 postconf/meson.build b/test cases/common/107 postconf/meson.build new file mode 100644 index 0000000..12b3c5b --- /dev/null +++ b/test cases/common/107 postconf/meson.build @@ -0,0 +1,5 @@ +project('postconf script', 'c') + +meson.add_postconf_script('postconf.py') + +test('post', executable('prog', 'prog.c')) diff --git a/test cases/common/107 postconf/postconf.py b/test cases/common/107 postconf/postconf.py new file mode 100644 index 0000000..d185f94 --- /dev/null +++ b/test cases/common/107 postconf/postconf.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import sys, os + +template = '''#pragma once + +#define THE_NUMBER {} +''' + +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)) diff --git a/test cases/common/107 postconf/prog.c b/test cases/common/107 postconf/prog.c new file mode 100644 index 0000000..1e5d4cb --- /dev/null +++ b/test cases/common/107 postconf/prog.c @@ -0,0 +1,5 @@ +#include"generated.h" + +int main(int argc, char **argv) { + return THE_NUMBER != 9; +} diff --git a/test cases/common/107 postconf/raw.dat b/test cases/common/107 postconf/raw.dat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/test cases/common/107 postconf/raw.dat @@ -0,0 +1 @@ +9 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 0000000..8510c5b --- /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', '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 0000000..b229d62 --- /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 0000000..0e63a8c --- /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 0000000..ec63514 --- /dev/null +++ b/test cases/common/108 postconf with args/raw.dat @@ -0,0 +1 @@ +9 |