From 94bc5f40334a1339d611812fbd853bde45942135 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Thu, 26 Mar 2015 18:01:14 +0200 Subject: Shameful hack to get configure files working with custom targets. Needs to be fixed properly during file object refactoring. --- interpreter.py | 10 ++++++++++ .../common/76 configure file in custom target/inc/confdata.in | 1 + .../common/76 configure file in custom target/inc/meson.build | 6 ++++++ .../common/76 configure file in custom target/meson.build | 4 ++++ .../common/76 configure file in custom target/src/meson.build | 4 ++++ .../76 configure file in custom target/src/mycompiler.py | 8 ++++++++ 6 files changed, 33 insertions(+) create mode 100644 test cases/common/76 configure file in custom target/inc/confdata.in create mode 100644 test cases/common/76 configure file in custom target/inc/meson.build create mode 100644 test cases/common/76 configure file in custom target/meson.build create mode 100644 test cases/common/76 configure file in custom target/src/meson.build create mode 100644 test cases/common/76 configure file in custom target/src/mycompiler.py diff --git a/interpreter.py b/interpreter.py index 832233f..d387542 100644 --- a/interpreter.py +++ b/interpreter.py @@ -1402,6 +1402,10 @@ class Interpreter(): raise InterpreterException('Required keyword argument "output" not defined.') inputfile = kwargs['input'] output = kwargs['output'] + if not isinstance(inputfile, str): + raise InterpreterException('Input must be a string.') + if not isinstance(output, str): + raise InterpreterException('Output must be a string.') if 'configuration' in kwargs: conf = kwargs['configuration'] if not isinstance(conf, ConfigurationDataHolder): @@ -1421,6 +1425,12 @@ class Interpreter(): raise InterpreterException('Configure_file must have either "configuration" or "command".') if isinstance(kwargs.get('install_dir', None), str): self.build.data.append(Data(False, self.subdir, [output], kwargs)) + # FIXME, HORROR, this is a massive hack to get this working. The correct + # solution is to finally do the refactoring where source files are no + # longer strings but actual objects. This is a major undertaking + # and will only be done after the next release. + outputfile = os.path.join(self.environment.build_dir, self.subdir, output) + return outputfile 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/76 configure file in custom target/inc/confdata.in b/test cases/common/76 configure file in custom target/inc/confdata.in new file mode 100644 index 0000000..e44cdea --- /dev/null +++ b/test cases/common/76 configure file in custom target/inc/confdata.in @@ -0,0 +1 @@ +@VALUE@ diff --git a/test cases/common/76 configure file in custom target/inc/meson.build b/test cases/common/76 configure file in custom target/inc/meson.build new file mode 100644 index 0000000..05d2dcb --- /dev/null +++ b/test cases/common/76 configure file in custom target/inc/meson.build @@ -0,0 +1,6 @@ +cdata = configuration_data() +cdata.set('VALUE', '42') + +cfile = configure_file(input : 'confdata.in', +output : 'confdata', +configuration : cdata) diff --git a/test cases/common/76 configure file in custom target/meson.build b/test cases/common/76 configure file in custom target/meson.build new file mode 100644 index 0000000..0a850a1 --- /dev/null +++ b/test cases/common/76 configure file in custom target/meson.build @@ -0,0 +1,4 @@ +project('conf file in custom target', 'c') + +subdir('inc') +subdir('src') diff --git a/test cases/common/76 configure file in custom target/src/meson.build b/test cases/common/76 configure file in custom target/src/meson.build new file mode 100644 index 0000000..b049e95 --- /dev/null +++ b/test cases/common/76 configure file in custom target/src/meson.build @@ -0,0 +1,4 @@ +custom_target('thing', +output : 'final.dat', +input : cfile, +command : [find_program('mycompiler.py'), '@INPUT@', '@OUTPUT@']) diff --git a/test cases/common/76 configure file in custom target/src/mycompiler.py b/test cases/common/76 configure file in custom target/src/mycompiler.py new file mode 100644 index 0000000..d5dcab5 --- /dev/null +++ b/test cases/common/76 configure file in custom target/src/mycompiler.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys + +ifile = open(sys.argv[1]) +if ifile.readline().strip() != '42': + print('Incorrect input') +open(sys.argv[2], 'w').write('Success\n') -- cgit v1.1