From 2487e0a1fbf8ac33b95467f7428afd78a39537ed Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 30 Dec 2018 12:54:25 +0100 Subject: [PATCH] Simplefied absolute path generation --- mesonbuild/backend/backends.py | 2 ++ mesonbuild/backend/ninjabackend.py | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 0291e7e98..5e81d6b48 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -156,6 +156,8 @@ class Backend: self.build = build self.environment = build.environment self.processed_targets = {} + self.build_dir = self.environment.get_build_dir() + self.source_dir = self.environment.get_source_dir() self.build_to_src = mesonlib.relpath(self.environment.get_source_dir(), self.environment.get_build_dir()) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 56e2ac5ae..818c9793a 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -339,7 +339,6 @@ int dummy; } } ''' - build_dir = self.environment.get_build_dir() id = target.get_id() lang = comp.get_language() tgt = self.introspection_data[id] @@ -352,7 +351,7 @@ int dummy; parameters = parameters.to_native(copy=True) for idx, i in enumerate(parameters): if i[:2] == '-I' or i[:2] == '/I' or i[:2] == '-L': - parameters[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:])) + parameters[idx] = i[:2] + os.path.normpath(os.path.join(self.build_dir, i[2:])) if target.is_cross: parameters += comp.get_cross_extra_flags(self.environment, False) # The new entry @@ -366,10 +365,10 @@ int dummy; self._intro_last_index = len(tgt) tgt[id_hash] = src_block # Make source files absolute - sources = [x.rel_to_builddir(self.build_to_src) if isinstance(x, File) else x for x in sources] - sources = [os.path.normpath(os.path.join(build_dir, x)) for x in sources] - generated_sources = [x.rel_to_builddir(self.build_to_src) if isinstance(x, File) else x for x in generated_sources] - generated_sources = [os.path.normpath(os.path.join(build_dir, x)) for x in generated_sources] + sources = [x.absolute_path(self.source_dir, self.build_dir) if isinstance(x, File) else os.path.normpath(os.path.join(self.build_dir, x)) + for x in sources] + generated_sources = [x.absolute_path(self.source_dir, self.build_dir) if isinstance(x, File) else os.path.normpath(os.path.join(self.build_dir, x)) + for x in generated_sources] # Add the source files src_block['sources'] += sources src_block['generated_sources'] += generated_sources