diff options
| author | Xavier Claessens <xclaessens@netflix.com> | 2025-10-11 15:23:49 -0400 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2025-10-15 12:15:39 -0400 |
| commit | 1826cba8d8f1316b83bb5864b9a61d756fe7f0ea (patch) | |
| tree | 163093278f92446292b8136c40ad90c8fbd0d5a8 /test cases | |
| parent | e0fc33dce2511c60c070064ffd86c746676dd302 (diff) | |
| download | meson-1826cba8d8f1316b83bb5864b9a61d756fe7f0ea.tar.gz | |
Add local_program() function
Diffstat (limited to 'test cases')
| -rw-r--r-- | test cases/common/285 local program/meson.build | 40 | ||||
| -rwxr-xr-x | test cases/common/285 local program/prog.py | 5 | ||||
| -rw-r--r-- | test cases/common/285 local program/pymod.py.in | 2 |
3 files changed, 47 insertions, 0 deletions
diff --git a/test cases/common/285 local program/meson.build b/test cases/common/285 local program/meson.build new file mode 100644 index 000000000..e7a4a98e9 --- /dev/null +++ b/test cases/common/285 local program/meson.build @@ -0,0 +1,40 @@ +project('local program', version: '2.0') + +python3 = find_program('python3') + +# A module imported by prog but only available at build time. +pymod = custom_target( + input: 'pymod.py.in', + output: 'pymod.py', + command: [python3, '-c', 'import shutil,sys;shutil.copy(sys.argv[1], sys.argv[2])', '@INPUT@', '@OUTPUT@'], + build_by_default: false, +) + +# Copy into builddir to have the same location as pymod.py +prog = configure_file( + input: 'prog.py', + output: 'prog.py', + copy: true, +) + +# Without the dependency it can't be run, but it should have the project version. +prog1 = local_program(prog) +assert(prog1.version() == '2.0') +assert(prog1.found()) + +prog2 = local_program(prog, depends: pymod) +assert(prog2.version() == '2.0') +assert(prog2.found()) + +meson.override_find_program('prog', prog2) +prog3 = find_program('prog') +assert(prog3.version() == '2.0') +assert(prog3.found()) + +# This should have the pymod dependency +custom_target( + output: 'out.txt', + command: [prog3], + capture: true, + build_by_default: true, +) diff --git a/test cases/common/285 local program/prog.py b/test cases/common/285 local program/prog.py new file mode 100755 index 000000000..bd1042a2f --- /dev/null +++ b/test cases/common/285 local program/prog.py @@ -0,0 +1,5 @@ +#! /usr/bin/env python3 + +import pymod + +raise SystemExit(pymod.foo()) diff --git a/test cases/common/285 local program/pymod.py.in b/test cases/common/285 local program/pymod.py.in new file mode 100644 index 000000000..3cc1da0c3 --- /dev/null +++ b/test cases/common/285 local program/pymod.py.in @@ -0,0 +1,2 @@ +def foo() -> None: + return 0 |
