From adebed8ec87364cd8ae1a38597ae99e1b5a92a01 Mon Sep 17 00:00:00 2001 From: Philipp Ittershagen Date: Mon, 3 Apr 2017 21:01:50 +0200 Subject: 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. --- mesonbuild/interpreter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mesonbuild/interpreter.py') 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) -- cgit v1.1