aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorPhilipp Ittershagen <pit@shgn.de>2017-04-03 21:01:50 +0200
committerPhilipp Ittershagen <pit@shgn.de>2017-04-03 21:09:31 +0200
commitadebed8ec87364cd8ae1a38597ae99e1b5a92a01 (patch)
tree6f082acb073634434aca7d4c805692cbc2f07122 /mesonbuild/interpreter.py
parent64e8f2c7bf781def278332ce665215ba79827297 (diff)
downloadmeson-adebed8ec87364cd8ae1a38597ae99e1b5a92a01.zip
meson-adebed8ec87364cd8ae1a38597ae99e1b5a92a01.tar.gz
meson-adebed8ec87364cd8ae1a38597ae99e1b5a92a01.tar.bz2
Enable File() objects as an input parameter to configure_file
The configure_file command raised an exception when an input was specified as a File, because os.path.join does not take File objects directly. This patch converts a File object to a string and adjusts the subsequent os.path.join calls.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 0c6d980..af2c17d 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2290,7 +2290,11 @@ class Interpreter(InterpreterBase):
inputfile = inputfile[0]
if not isinstance(inputfile, (str, mesonlib.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']:
raise InterpreterException('@INPUT@ used as command argument, but no input file specified.')
# Validate output
@@ -2309,7 +2313,7 @@ class Interpreter(InterpreterBase):
if inputfile is not None:
# Normalize the path of the conffile to avoid duplicates
# 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:
self.build_def_files.append(conffile)
os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True)