I need this for windows.compile_resources to be able to use configure_file results, but it may have other benefits.pull/1257/head
parent
eea0670872
commit
78b030cf19
10 changed files with 57 additions and 6 deletions
@ -0,0 +1 @@ |
||||
@VALUE@ |
@ -0,0 +1,6 @@ |
||||
cdata = configuration_data() |
||||
cdata.set('VALUE', '42') |
||||
|
||||
cfile = configure_file(input : 'confdata.in', |
||||
output : 'confdata', |
||||
configuration : cdata) |
@ -0,0 +1,4 @@ |
||||
project('conf file in generator', 'c') |
||||
|
||||
subdir('inc') |
||||
subdir('src') |
@ -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, )) |
@ -0,0 +1,17 @@ |
||||
#include<stdio.h> |
||||
|
||||
#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; |
||||
} |
@ -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) |
@ -0,0 +1 @@ |
||||
23 |
Loading…
Reference in new issue