parent
848e360450
commit
3990754bf5
10 changed files with 73 additions and 12 deletions
@ -0,0 +1,14 @@ |
||||
## `meson.add_dist_script()` allowd in subprojects |
||||
|
||||
`meson.add_dist_script()` can now be invoked from a subproject, it was a hard |
||||
error in earlier versions. Subproject dist scripts will only be executed |
||||
when running `meson dist --include-subprojects`. `MESON_PROJECT_SOURCE_ROOT`, |
||||
`MESON_PROJECT_BUILD_ROOT` and `MESON_PROJECT_DIST_ROOT` environment variables |
||||
are set when dist scripts are run. They are identical to `MESON_SOURCE_ROOT`, |
||||
`MESON_BUILD_ROOT` and `MESON_DIST_ROOT` for main project scripts, but for |
||||
subproject scripts they have the path to the root of the subproject appended, |
||||
usually `subprojects/<subproject-name>`. |
||||
|
||||
Note that existing dist scripts likely need to be modified to use those new |
||||
environment variables instead of `MESON_DIST_ROOT` to work properly when used |
||||
from a subproject. |
@ -0,0 +1,12 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
import os |
||||
import pathlib |
||||
import sys |
||||
|
||||
assert sys.argv[1] == 'success' |
||||
|
||||
source_root = pathlib.Path(os.environ['MESON_PROJECT_DIST_ROOT']) |
||||
modfile = source_root / 'prog.c' |
||||
with modfile.open('w') as f: |
||||
f.write('int main(){return 0;}') |
@ -0,0 +1,11 @@ |
||||
project('sub') |
||||
|
||||
if get_option('broken_dist_script') |
||||
# Make sure we can add a dist script in a subproject, but it won't be run |
||||
# if not using --include-subprojects. |
||||
meson.add_dist_script('dist-script.py', 'broken') |
||||
else |
||||
# The dist script replace prog.c with something that actually build. |
||||
meson.add_dist_script('dist-script.py', 'success') |
||||
executable('prog', 'prog.c') |
||||
endif |
@ -0,0 +1 @@ |
||||
option('broken_dist_script', type: 'boolean', value: true) |
@ -0,0 +1 @@ |
||||
#error This should be replaced by a program during dist |
Loading…
Reference in new issue