diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index e6f82d104..218e1284c 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1557,7 +1557,7 @@ rule FORTRAN_DEP_HACK else: sole_output = '' curfile = infilelist[i] - infilename = os.path.join(self.build_to_src, curfile) + infilename = curfile.rel_to_builddir(self.build_to_src) outfiles = genlist.get_outputs_for(curfile) outfiles = [os.path.join(self.get_target_private_dir(target), of) for of in outfiles] if generator.depfile is None: diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 7e6831ae4..137e9aeab 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -121,7 +121,7 @@ class Vs2010Backend(backends.Backend): else: sole_output = '' curfile = infilelist[i] - infilename = os.path.join(self.environment.get_source_dir(), curfile) + infilename = os.path.join(down, curfile.rel_to_builddir(self.build_to_src)) outfiles_rel = genlist.get_outputs_for(curfile) outfiles = [os.path.join(target_private_dir, of) for of in outfiles_rel] generator_output_files += outfiles diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 8fa6ada78..cc33d39d7 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -918,9 +918,11 @@ class Generator(): def process_files(self, name, files, state, extra_args=[]): output = GeneratedList(self, extra_args=extra_args) for f in files: - if not isinstance(f, str): - raise InvalidArguments('{} arguments must be strings.'.format(name)) - output.add_file(os.path.join(state.subdir, f)) + if isinstance(f, str): + f = File.from_source_file(state.environment.source_dir, state.subdir, f) + elif not isinstance(f, File): + raise InvalidArguments('{} arguments must be strings or files not {!r}.'.format(name, f)) + output.add_file(f) return output @@ -938,7 +940,7 @@ class GeneratedList(): def add_file(self, newfile): self.infilelist.append(newfile) - outfiles = self.generator.get_base_outnames(newfile) + outfiles = self.generator.get_base_outnames(newfile.fname) self.outfilelist += outfiles self.outmap[newfile] = outfiles diff --git a/test cases/common/133 configure file in generator/inc/confdata.in b/test cases/common/133 configure file in generator/inc/confdata.in new file mode 100644 index 000000000..e44cdea20 --- /dev/null +++ b/test cases/common/133 configure file in generator/inc/confdata.in @@ -0,0 +1 @@ +@VALUE@ diff --git a/test cases/common/133 configure file in generator/inc/meson.build b/test cases/common/133 configure file in generator/inc/meson.build new file mode 100644 index 000000000..05d2dcb8a --- /dev/null +++ b/test cases/common/133 configure file in generator/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/133 configure file in generator/meson.build b/test cases/common/133 configure file in generator/meson.build new file mode 100644 index 000000000..e1c26b6d1 --- /dev/null +++ b/test cases/common/133 configure file in generator/meson.build @@ -0,0 +1,4 @@ +project('conf file in generator', 'c') + +subdir('inc') +subdir('src') diff --git a/test cases/common/133 configure file in generator/src/gen.py b/test cases/common/133 configure file in generator/src/gen.py new file mode 100755 index 000000000..99b7cddb9 --- /dev/null +++ b/test cases/common/133 configure file in generator/src/gen.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys + +ifile = sys.argv[1] +ofile = sys.argv[2] + +with open(ifile, 'r') as f: + resval = f.readline().strip() + +templ = '#define RESULT (%s)\n' +with open(ofile, 'w') as f: + f.write(templ % (resval, )) diff --git a/test cases/common/133 configure file in generator/src/main.c b/test cases/common/133 configure file in generator/src/main.c new file mode 100644 index 000000000..54f4f57c6 --- /dev/null +++ b/test cases/common/133 configure file in generator/src/main.c @@ -0,0 +1,17 @@ +#include + +#include"confdata.h" +#if RESULT != 42 +#error Configuration RESULT is not defined correctly +#endif + +#undef RESULT + +#include"source.h" +#if RESULT != 23 +#error Source RESULT is not defined correctly +#endif + +int main(int argc, char **argv) { + return 0; +} diff --git a/test cases/common/133 configure file in generator/src/meson.build b/test cases/common/133 configure file in generator/src/meson.build new file mode 100644 index 000000000..2fb804eec --- /dev/null +++ b/test cases/common/133 configure file in generator/src/meson.build @@ -0,0 +1,7 @@ +compiler = find_program('gen.py') +gen = generator(compiler, + output: '@BASENAME@.h', + arguments : ['@INPUT@', '@OUTPUT@']) +hs = gen.process(cfile, files('source')) + +executable('proggie', 'main.c', hs) diff --git a/test cases/common/133 configure file in generator/src/source b/test cases/common/133 configure file in generator/src/source new file mode 100644 index 000000000..409940768 --- /dev/null +++ b/test cases/common/133 configure file in generator/src/source @@ -0,0 +1 @@ +23