From 88aafd363e3b63184b42d66b9307ec701670b529 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Tue, 19 Jul 2016 22:40:57 +0530 Subject: [PATCH] Normalize the path of a configured file to avoid dupes (#640) --- mesonbuild/backend/ninjabackend.py | 2 +- mesonbuild/environment.py | 8 +++++--- mesonbuild/interpreter.py | 4 +++- run_cross_test.py | 2 +- run_tests.py | 3 ++- .../common/114 multiple dir configure file/meson.build | 7 +++++++ .../114 multiple dir configure file/subdir/meson.build | 4 ++++ .../114 multiple dir configure file/subdir/someinput.in | 0 8 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 test cases/common/114 multiple dir configure file/meson.build create mode 100644 test cases/common/114 multiple dir configure file/subdir/meson.build create mode 100644 test cases/common/114 multiple dir configure file/subdir/someinput.in diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index c2ccc6c89..ab5bc4902 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1821,7 +1821,7 @@ rule FORTRAN_DEP_HACK ninja_command = environment.detect_ninja() if ninja_command is None: - raise MesonException('Could not detect ninja command') + raise MesonException('Could not detect Ninja v1.6 or newer)') elem = NinjaBuildElement(self.all_outputs, 'clean', 'CUSTOM_COMMAND', 'PHONY') elem.add_item('COMMAND', [ninja_command, '-t', 'clean']) elem.add_item('description', 'Cleaning') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index b9552a969..98ce93311 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -45,11 +45,13 @@ def find_valgrind(): def detect_ninja(): for n in ['ninja', 'ninja-build']: try: - p = subprocess.Popen([n, '--version'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + p = subprocess.Popen([n, '--version'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) except FileNotFoundError: continue - p.communicate() - if p.returncode == 0: + version = p.communicate()[0].decode(errors='ignore') + # Perhaps we should add a way for the caller to know the failure mode + # (not found or too old) + if p.returncode == 0 and mesonlib.version_compare(version, ">=1.6"): return n def detect_cpu_family(): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 2fd835f30..51c40c900 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1993,7 +1993,9 @@ class Interpreter(): raise InterpreterException('Argument "configuration" is not of type configuration_data') ofile_abs = os.path.join(self.environment.build_dir, self.subdir, output) if inputfile is not None: - conffile = os.path.join(self.subdir, inputfile) + # 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)) 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) diff --git a/run_cross_test.py b/run_cross_test.py index a7888507a..3abd28861 100755 --- a/run_cross_test.py +++ b/run_cross_test.py @@ -34,7 +34,7 @@ meson_command = './meson.py' extra_flags = ['--cross-file', sys.argv[1]] ninja_command = environment.detect_ninja() if ninja_command is None: - raise RuntimeError('Could not find Ninja executable.') + raise RuntimeError('Could not find Ninja v1.6 or newer') compile_commands = [ninja_command] test_commands = [ninja_command, 'test'] install_commands = [ninja_command, 'install'] diff --git a/run_tests.py b/run_tests.py index 0919d847a..b0d666fc1 100755 --- a/run_tests.py +++ b/run_tests.py @@ -116,11 +116,12 @@ def setup_commands(backend): backend_flags = [] ninja_command = environment.detect_ninja() if ninja_command is None: - raise RuntimeError('Could not find Ninja executable.') + raise RuntimeError('Could not find Ninja v1.6 or newer') if print_debug: compile_commands = [ninja_command, '-v'] else: compile_commands = [ninja_command] + compile_commands += ['-w', 'dupbuild=err'] test_commands = [ninja_command, 'test', 'benchmark'] install_commands = [ninja_command, 'install'] diff --git a/test cases/common/114 multiple dir configure file/meson.build b/test cases/common/114 multiple dir configure file/meson.build new file mode 100644 index 000000000..180227c15 --- /dev/null +++ b/test cases/common/114 multiple dir configure file/meson.build @@ -0,0 +1,7 @@ +project('multiple dir configure file', 'c') + +subdir('subdir') + +configure_file(input : 'subdir/someinput.in', + output : 'outputhere', + configuration : configuration_data()) diff --git a/test cases/common/114 multiple dir configure file/subdir/meson.build b/test cases/common/114 multiple dir configure file/subdir/meson.build new file mode 100644 index 000000000..a8f731d94 --- /dev/null +++ b/test cases/common/114 multiple dir configure file/subdir/meson.build @@ -0,0 +1,4 @@ +configure_file(input : 'someinput.in', + output : 'outputsubdir', + install : false, + configuration : configuration_data()) diff --git a/test cases/common/114 multiple dir configure file/subdir/someinput.in b/test cases/common/114 multiple dir configure file/subdir/someinput.in new file mode 100644 index 000000000..e69de29bb