The same substitutions and rules as custom_target(). Also generally fix it to actually work when run in a subdir and with anything other than absolute paths for input and output files. We now also log a message when configuring files. Includes tests for all this.pull/1403/head
parent
1f0319c288
commit
cb0aa6a83a
6 changed files with 72 additions and 22 deletions
@ -0,0 +1,6 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
import os |
||||
import sys |
||||
|
||||
assert(os.path.exists(sys.argv[1])) |
@ -1,15 +1,17 @@ |
||||
#!/usr/bin/env python |
||||
#!/usr/bin/env python3 |
||||
|
||||
# On some platforms "python" points to Python 2 |
||||
# on others to Python 3. Work with both. |
||||
|
||||
from __future__ import print_function |
||||
import sys, os |
||||
from pathlib import Path |
||||
|
||||
if len(sys.argv) != 3: |
||||
print("Wrong amount of parameters.") |
||||
|
||||
assert(os.path.exists(sys.argv[1])) |
||||
build_dir = Path(os.environ['MESON_BUILD_ROOT']) |
||||
subdir = Path(os.environ['MESON_SUBDIR']) |
||||
inputf = Path(sys.argv[1]) |
||||
outputf = Path(sys.argv[2]) |
||||
|
||||
assert(inputf.exists()) |
||||
|
||||
with open(sys.argv[2], 'w') as ofile: |
||||
with outputf.open('w') as ofile: |
||||
ofile.write("#define ZERO_RESULT 0\n") |
||||
|
@ -1 +1,3 @@ |
||||
usr/share/appdir/config2.h |
||||
usr/share/appdireh/config2-1.h |
||||
usr/share/appdirok/config2-2.h |
||||
|
@ -0,0 +1,19 @@ |
||||
# Configure in subdir with absolute paths for input and relative for output |
||||
configure_file(input : '../dummy.dat', |
||||
output : 'config2-1.h', |
||||
command : [genprog, scriptfile, ifile, 'config2-1.h'], |
||||
install_dir : 'share/appdireh') |
||||
run_command(check_file, join_paths(meson.current_build_dir(), 'config2-1.h')) |
||||
|
||||
# Configure in subdir with files() for input and relative for output |
||||
configure_file(input : '../dummy.dat', |
||||
output : 'config2-2.h', |
||||
command : [genprog, scriptfile, files('../dummy.dat'), 'config2-2.h'], |
||||
install_dir : 'share/appdirok') |
||||
run_command(check_file, join_paths(meson.current_build_dir(), 'config2-2.h')) |
||||
|
||||
# Configure in subdir with string templates for input and output |
||||
configure_file(input : '../dummy.dat', |
||||
output : 'config2-3.h', |
||||
command : [found_script, '@INPUT@', '@OUTPUT@']) |
||||
run_command(check_file, join_paths(meson.current_build_dir(), 'config2-3.h')) |
Loading…
Reference in new issue