diff options
-rw-r--r-- | interpreter.py | 39 | ||||
-rw-r--r-- | test cases/common/16 configure file/dummy.dat | 0 | ||||
-rwxr-xr-x | test cases/common/16 configure file/generator.py | 13 | ||||
-rw-r--r-- | test cases/common/16 configure file/meson.build | 12 | ||||
-rw-r--r-- | test cases/common/16 configure file/prog2.c | 5 | ||||
-rw-r--r-- | test cases/common/55 file grabber/meson.build | 2 |
6 files changed, 57 insertions, 14 deletions
diff --git a/interpreter.py b/interpreter.py index 7940c94..f6ae8bb 100644 --- a/interpreter.py +++ b/interpreter.py @@ -549,6 +549,7 @@ class MesonMain(InterpreterObject): 'has_exe_wrapper' : self.has_exe_wrapper_method, 'is_unity' : self.is_unity_method, 'current_source_dir' : self.current_source_dir_method, + 'current_build_dir' : self.current_build_dir_method, }) def current_source_dir_method(self, args, kwargs): @@ -558,6 +559,13 @@ class MesonMain(InterpreterObject): return src return os.path.join(src, sub) + def current_build_dir_method(self, args, kwargs): + src = self.interpreter.environment.build_dir + sub = self.interpreter.subdir + if sub == '': + return src + return os.path.join(src, sub) + def has_exe_wrapper_method(self, args, kwargs): if self.is_cross_build_method(None, None): return 'exe_wrap' in self.build.environment.cross_info @@ -1092,19 +1100,24 @@ class Interpreter(): raise InterpreterException('Required keyword argument "input" not defined.') if not 'output' in kwargs: raise InterpreterException('Required keyword argument "output" not defined.') - if not 'configuration' in kwargs: - raise InterpreterException('Required keyword argument "configuration" not defined.') - inputfile = kwargs['input'] - output = kwargs['output'] - conf = kwargs['configuration'] - if not isinstance(conf, ConfigurationDataHolder): - raise InterpreterException('Argument "configuration" is not of type configuration_data') - - conffile = os.path.join(self.subdir, inputfile) - self.build_def_files.append(conffile) - c = ConfigureFileHolder(self.subdir, inputfile, output, conf.held_object) - self.build.configure_files.append(c.held_object) - conf.mark_used() + if 'configuration' in kwargs: + inputfile = kwargs['input'] + output = kwargs['output'] + conf = kwargs['configuration'] + if not isinstance(conf, ConfigurationDataHolder): + raise InterpreterException('Argument "configuration" is not of type configuration_data') + + conffile = os.path.join(self.subdir, inputfile) + self.build_def_files.append(conffile) + c = ConfigureFileHolder(self.subdir, inputfile, output, conf.held_object) + self.build.configure_files.append(c.held_object) + conf.mark_used() + elif 'command' in kwargs: + res = self.func_run_command(node, kwargs['command'], {}) + if res.returncode != 0: + raise InterpreterException('Running configure command failed.') + else: + raise InterpreterException('Configure_file must have either "configuration" or "command".') def func_include_directories(self, node, args, kwargs): absbase = os.path.join(self.environment.get_source_dir(), self.subdir) diff --git a/test cases/common/16 configure file/dummy.dat b/test cases/common/16 configure file/dummy.dat new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/common/16 configure file/dummy.dat diff --git a/test cases/common/16 configure file/generator.py b/test cases/common/16 configure file/generator.py new file mode 100755 index 0000000..de9a423 --- /dev/null +++ b/test cases/common/16 configure file/generator.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys + +if len(sys.argv) != 3: + print("Wrong amount of parameters.") + +# Just test that it exists. +ifile = open(sys.argv[1], 'r') + +ofile = open(sys.argv[2], 'w') +ofile.write("#define ZERO_RESULT 0\n") +ofile.close() diff --git a/test cases/common/16 configure file/meson.build b/test cases/common/16 configure file/meson.build index 98dfd48..281e0b3 100644 --- a/test cases/common/16 configure file/meson.build +++ b/test cases/common/16 configure file/meson.build @@ -13,3 +13,15 @@ configuration : conf) e = executable('inctest', 'prog.c', include_dirs : include_directories('.')) test('inctest', e) + +# Now generate a header file with an external script. +genprog = find_program('generator.py') +ifile = '@0@/dummy.dat'.format(meson.current_source_dir()) +ofile = '@0@/config2.h'.format(meson.current_build_dir()) + +configure_file(input : 'dummy.dat', +output : 'config2.h', +command : [genprog, ifile, ofile]) + +test('inctest2', executable('prog2', 'prog2.c', +include_dirs : include_directories('.'))) diff --git a/test cases/common/16 configure file/prog2.c b/test cases/common/16 configure file/prog2.c new file mode 100644 index 0000000..be85033 --- /dev/null +++ b/test cases/common/16 configure file/prog2.c @@ -0,0 +1,5 @@ +#include"config2.h" + +int main(int argc, char **argv) { + return ZERO_RESULT; +} diff --git a/test cases/common/55 file grabber/meson.build b/test cases/common/55 file grabber/meson.build index 88e5861..c32af07 100644 --- a/test cases/common/55 file grabber/meson.build +++ b/test cases/common/55 file grabber/meson.build @@ -11,7 +11,7 @@ project('grabber', 'c') if build.name() == 'windows' c = run_command('grabber.bat') - grabber = find_program('grabber') + grabber = find_program('grabber.bat') else c = run_command('grabber.sh') grabber = find_program('grabber.sh') |