diff options
Diffstat (limited to 'meson/test cases/common/182 find override')
11 files changed, 120 insertions, 0 deletions
diff --git a/meson/test cases/common/182 find override/meson.build b/meson/test cases/common/182 find override/meson.build new file mode 100644 index 000000000..8dcbac76b --- /dev/null +++ b/meson/test cases/common/182 find override/meson.build @@ -0,0 +1,25 @@ +project('find program override', 'c') + +gencodegen = find_program('gencodegen', required : false) +six_prog = find_program('six_meson_exe', required : false) + +assert(not gencodegen.found(), 'gencodegen is an internal program, should not be found') +assert(not six_prog.found(), 'six_meson_exe is an internal program, should not be found') + +# Test the check-if-found-else-override workflow +if not gencodegen.found() + subdir('subdir') +endif + +subdir('otherdir') + +tool = find_program('sometool') +assert(tool.found()) +assert(tool.full_path() != '') +assert(tool.full_path() == tool.path()) + +# six_meson_exe is an overritten project executable +six_prog = find_program('six_meson_exe') +assert(six_prog.found()) +assert(six_prog.full_path() != '') +assert(six_prog.full_path() == six_prog.path()) diff --git a/meson/test cases/common/182 find override/otherdir/main.c b/meson/test cases/common/182 find override/otherdir/main.c new file mode 100644 index 000000000..5fb6371b8 --- /dev/null +++ b/meson/test cases/common/182 find override/otherdir/main.c @@ -0,0 +1,5 @@ +int be_seeing_you(void); + +int main(void) { + return be_seeing_you() == 6 ? 0 : 1; +} diff --git a/meson/test cases/common/182 find override/otherdir/main2.c b/meson/test cases/common/182 find override/otherdir/main2.c new file mode 100644 index 000000000..80a30091e --- /dev/null +++ b/meson/test cases/common/182 find override/otherdir/main2.c @@ -0,0 +1,5 @@ +int number_returner(void); + +int main(void) { + return number_returner() == 100 ? 0 : 1; +} diff --git a/meson/test cases/common/182 find override/otherdir/meson.build b/meson/test cases/common/182 find override/otherdir/meson.build new file mode 100644 index 000000000..7deff4035 --- /dev/null +++ b/meson/test cases/common/182 find override/otherdir/meson.build @@ -0,0 +1,30 @@ +gen = find_program('codegen') # Should use overridden value set in "subdir". + +src = custom_target('arrival', + input : 'source.desc', + output : 'file.c', + command : [gen, '@INPUT@', '@OUTPUT@'] + ) + +e = executable('six', 'main.c', src) + +test('six', e) + +# Override stuff with an executables +meson.override_find_program('six_meson_exe', e) + + +# The same again, but this time with a program that was generated +# with configure_file. + +gen = find_program('gencodegen') + +src = custom_target('hundred', + input : 'source2.desc', + output : 'file2.c', + command : [gen, '@INPUT@', '@OUTPUT@'] + ) + +e = executable('hundred', 'main2.c', src) + +test('hundred', e) diff --git a/meson/test cases/common/182 find override/otherdir/source.desc b/meson/test cases/common/182 find override/otherdir/source.desc new file mode 100644 index 000000000..8b19c9c2f --- /dev/null +++ b/meson/test cases/common/182 find override/otherdir/source.desc @@ -0,0 +1 @@ +be_seeing_you diff --git a/meson/test cases/common/182 find override/otherdir/source2.desc b/meson/test cases/common/182 find override/otherdir/source2.desc new file mode 100644 index 000000000..965f868df --- /dev/null +++ b/meson/test cases/common/182 find override/otherdir/source2.desc @@ -0,0 +1 @@ +number_returner diff --git a/meson/test cases/common/182 find override/subdir/converter.py b/meson/test cases/common/182 find override/subdir/converter.py new file mode 100755 index 000000000..efe04649d --- /dev/null +++ b/meson/test cases/common/182 find override/subdir/converter.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import sys +import pathlib + +[ifilename, ofilename] = sys.argv[1:3] + +ftempl = '''int %s(void) { + return 6; +} +''' + +d = pathlib.Path(ifilename).read_text().split('\n')[0].strip() + +pathlib.Path(ofilename).write_text(ftempl % d) diff --git a/meson/test cases/common/182 find override/subdir/gencodegen.py.in b/meson/test cases/common/182 find override/subdir/gencodegen.py.in new file mode 100755 index 000000000..78ebb2f4e --- /dev/null +++ b/meson/test cases/common/182 find override/subdir/gencodegen.py.in @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import sys +import pathlib + +[ifilename, ofilename] = sys.argv[1:3] + +ftempl = '''int %s(void) { + return @NUMBER@; +} +''' + +d = pathlib.Path(ifilename).read_text().split('\n')[0].strip() + +pathlib.Path(ofilename).write_text(ftempl % d) diff --git a/meson/test cases/common/182 find override/subdir/meson.build b/meson/test cases/common/182 find override/subdir/meson.build new file mode 100644 index 000000000..e5de34dde --- /dev/null +++ b/meson/test cases/common/182 find override/subdir/meson.build @@ -0,0 +1,14 @@ +x = find_program('converter.py') + +meson.override_find_program('codegen', x) + +# Override a command with a generated script + +cdata = configuration_data() + +cdata.set('NUMBER', 100) +numprog = configure_file(input : 'gencodegen.py.in', + output : 'gencodegen.py', + configuration : cdata) + +meson.override_find_program('gencodegen', numprog) diff --git a/meson/test cases/common/182 find override/subprojects/sub.wrap b/meson/test cases/common/182 find override/subprojects/sub.wrap new file mode 100644 index 000000000..17aa3323f --- /dev/null +++ b/meson/test cases/common/182 find override/subprojects/sub.wrap @@ -0,0 +1,5 @@ +[wrap-file] +directory = sub + +[provide] +program_names = sometool diff --git a/meson/test cases/common/182 find override/subprojects/sub/meson.build b/meson/test cases/common/182 find override/subprojects/sub/meson.build new file mode 100644 index 000000000..640f2704c --- /dev/null +++ b/meson/test cases/common/182 find override/subprojects/sub/meson.build @@ -0,0 +1,4 @@ +project('tools') + +exe = find_program('gencodegen') +meson.override_find_program('sometool', exe) |