Enable variables for output in configure_file

pull/1857/head
Bálint Aradi 8 years ago
parent 4828b46b73
commit e79b602298
  1. 4
      mesonbuild/interpreter.py
  2. 2
      test cases/common/16 configure file/config4a.h.in
  3. 2
      test cases/common/16 configure file/config4b.h.in
  4. 12
      test cases/common/16 configure file/meson.build
  5. 6
      test cases/common/16 configure file/prog4.c

@ -2344,6 +2344,10 @@ class Interpreter(InterpreterBase):
output = kwargs['output']
if not isinstance(output, str):
raise InterpreterException('Output file name must be a string')
if ifile_abs:
values = mesonlib.get_filenames_templates_dict([ifile_abs], None)
outputs = mesonlib.substitute_values([output], values)
output = outputs[0]
if os.path.split(output)[0] != '':
raise InterpreterException('Output file name must not contain a subdirectory.')
(ofile_path, ofile_fname) = os.path.split(os.path.join(self.subdir, output))

@ -0,0 +1,2 @@
/* Dummy file */
#define RESULTA @ZERO@

@ -0,0 +1,2 @@
/* Dummy file */
#define RESULTB @ZERO@

@ -74,3 +74,15 @@ configure_file(output : 'config3.h',
configuration : dump)
test('Configless.', executable('dumpprog', 'dumpprog.c'))
# Config file generation in a loop with @BASENAME@ substitution
dump = configuration_data()
dump.set('ZERO', 0)
config_templates = files(['config4a.h.in', 'config4b.h.in'])
foreach config_template : config_templates
configure_file(input : config_template, output : '@BASENAME@',
configuration : dump)
endforeach
test('Substituted', executable('prog4', 'prog4.c'))

@ -0,0 +1,6 @@
#include <config4a.h>
#include <config4b.h>
int main(int argc, char **argv) {
return RESULTA + RESULTB;
}
Loading…
Cancel
Save