add args support for add_postconf_script

pull/426/head
Nicolas Schneider 9 years ago
parent 92187501ed
commit 9f9f73fa52
  1. 2
      mesonbuild/backend/backends.py
  2. 3
      mesonbuild/interpreter.py
  3. 5
      test cases/common/108 postconf with args/meson.build
  4. 13
      test cases/common/108 postconf with args/postconf.py
  5. 5
      test cases/common/108 postconf with args/prog.c
  6. 1
      test cases/common/108 postconf with args/raw.dat

@ -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)

@ -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

@ -0,0 +1,5 @@
project('postconf script', 'c')
meson.add_postconf_script('postconf.py', args: ['5', '33'])
test('post', executable('prog', 'prog.c'))

@ -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]))

@ -0,0 +1,5 @@
#include"generated.h"
int main(int argc, char **argv) {
return THE_NUMBER != 9 || THE_ARG1 != 5 || THE_ARG2 != 33;
}
Loading…
Cancel
Save