Merge pull request #1557 from pitti/fix/configure_data-files-input

Fix configure_data files input
pull/1440/merge
Jussi Pakkanen 8 years ago committed by GitHub
commit 14579ed9c5
  1. 1
      authors.txt
  2. 8
      mesonbuild/interpreter.py
  3. 12
      mesonbuild/mesonlib.py
  4. 5
      test cases/common/16 configure file/meson.build

@ -73,3 +73,4 @@ Joe Baldino
Peter Harris Peter Harris
Roger Boerdijk Roger Boerdijk
melak47 melak47
Philipp Ittershagen

@ -2290,7 +2290,11 @@ class Interpreter(InterpreterBase):
inputfile = inputfile[0] inputfile = inputfile[0]
if not isinstance(inputfile, (str, mesonlib.File)): if not isinstance(inputfile, (str, mesonlib.File)):
raise InterpreterException('Input must be a string or a file') raise InterpreterException('Input must be a string or a file')
ifile_abs = os.path.join(self.environment.source_dir, self.subdir, inputfile) if isinstance(inputfile, str):
inputfile = os.path.join(self.subdir, inputfile)
else:
inputfile = inputfile.relative_name()
ifile_abs = os.path.join(self.environment.source_dir, inputfile)
elif 'command' in kwargs and '@INPUT@' in kwargs['command']: elif 'command' in kwargs and '@INPUT@' in kwargs['command']:
raise InterpreterException('@INPUT@ used as command argument, but no input file specified.') raise InterpreterException('@INPUT@ used as command argument, but no input file specified.')
# Validate output # Validate output
@ -2309,7 +2313,7 @@ class Interpreter(InterpreterBase):
if inputfile is not None: if inputfile is not None:
# Normalize the path of the conffile to avoid duplicates # Normalize the path of the conffile to avoid duplicates
# This is especially important to convert '/' to '\' on Windows # This is especially important to convert '/' to '\' on Windows
conffile = os.path.normpath(os.path.join(self.subdir, inputfile)) conffile = os.path.normpath(inputfile)
if conffile not in self.build_def_files: if conffile not in self.build_def_files:
self.build_def_files.append(conffile) self.build_def_files.append(conffile)
os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True) os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True)

@ -125,14 +125,14 @@ class File:
assert(isinstance(self.fname, str)) assert(isinstance(self.fname, str))
def __str__(self): def __str__(self):
return os.path.join(self.subdir, self.fname) return self.relative_name()
def __repr__(self): def __repr__(self):
ret = '<File: {0}' ret = '<File: {0}'
if not self.is_built: if not self.is_built:
ret += ' (not built)' ret += ' (not built)'
ret += '>' ret += '>'
return ret.format(os.path.join(self.subdir, self.fname)) return ret.format(self.relative_name())
@staticmethod @staticmethod
def from_source_file(source_root, subdir, fname): def from_source_file(source_root, subdir, fname):
@ -150,15 +150,15 @@ class File:
def rel_to_builddir(self, build_to_src): def rel_to_builddir(self, build_to_src):
if self.is_built: if self.is_built:
return os.path.join(self.subdir, self.fname) return self.relative_name()
else: else:
return os.path.join(build_to_src, self.subdir, self.fname) return os.path.join(build_to_src, self.subdir, self.fname)
def absolute_path(self, srcdir, builddir): def absolute_path(self, srcdir, builddir):
absdir = srcdir
if self.is_built: if self.is_built:
return os.path.join(builddir, self.subdir, self.fname) absdir = builddir
else: return os.path.join(absdir, self.relative_name())
return os.path.join(srcdir, self.subdir, self.fname)
def endswith(self, ending): def endswith(self, ending):
return self.fname.endswith(ending) return self.fname.endswith(ending)

@ -22,6 +22,11 @@ e = executable('inctest', 'prog.c',
cfile) cfile)
test('inctest', e) test('inctest', e)
# Test if we can also pass files() as input
configure_file(input : files('config.h.in'),
output : 'config2.h',
configuration : conf)
# Now generate a header file with an external script. # Now generate a header file with an external script.
genprog = import('python3').find_python() genprog = import('python3').find_python()
scriptfile = '@0@/generator.py'.format(meson.current_source_dir()) scriptfile = '@0@/generator.py'.format(meson.current_source_dir())

Loading…
Cancel
Save