From 8e6db550695cf001d39f0bb70f2ef427e220f761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Tue, 12 Mar 2024 00:14:15 +0100 Subject: [PATCH] [WIP] Start reworking target directory logic --- mesonbuild/backend/ninjabackend.py | 7 +++++-- mesonbuild/build.py | 5 ++++- mesonbuild/environment.py | 6 ++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 782b264acc90..2eecadd219c1 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2778,7 +2778,7 @@ def generate_llvm_ir_compile(self, target, src): return (rel_obj, rel_src) @lru_cache(maxsize=None) - def generate_inc_dir(self, compiler: 'Compiler', d: str, basedir: str, is_system: bool) -> \ + def generate_inc_dir(self, compiler: 'Compiler', d: str, basedir: str, is_system: bool, target: build.BuildTarget) -> \ T.Tuple['ImmutableListProtocol[str]', 'ImmutableListProtocol[str]']: # Avoid superfluous '/.' at the end of paths when d is '.' if d not in ('', '.'): @@ -2793,6 +2793,9 @@ def generate_inc_dir(self, compiler: 'Compiler', d: str, basedir: str, is_system # inc = include_directories('foo/bar/baz') # # But never subdir()s into the actual dir. + if target.is_native_clone: + assert expdir.startswith('subprojects') + expdir = 'subprojects-native' + expdir[11:] if os.path.isdir(os.path.join(self.environment.get_build_dir(), expdir)): bargs = compiler.get_include_args(expdir, is_system) else: @@ -2843,7 +2846,7 @@ def _generate_single_compile_target_args(self, target: build.BuildTarget, compil # flags will be added in reversed order. for d in reversed(i.get_incdirs()): # Add source subdir first so that the build subdir overrides it - (compile_obj, includeargs) = self.generate_inc_dir(compiler, d, basedir, i.is_system) + (compile_obj, includeargs) = self.generate_inc_dir(compiler, d, basedir, i.is_system, target) commands += compile_obj commands += includeargs for d in i.get_extra_build_dirs(): diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 3de46e61dac8..144f377b55fa 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -624,7 +624,7 @@ def get_basename(self) -> str: return self.name def get_subdir(self) -> str: - return self.environment.build_output_rpath(self.subdir) + return return self.subdir def get_typename(self) -> str: return self.typename @@ -752,6 +752,7 @@ def __init__( compilers: T.Dict[str, 'Compiler'], kwargs: T.Dict[str, T.Any]): super().__init__(name, subdir, subproject, True, for_machine, environment, install=kwargs.get('install', False)) + self.is_native_clone = environment.coredata.is_native_clone self.all_compilers = compilers self.compilers: OrderedDict[str, Compiler] = OrderedDict() self.objects: T.List[ObjectTypes] = [] @@ -1550,6 +1551,8 @@ def add_pch(self, language: str, pchlist: T.List[str]) -> None: self.pch[language] = pchlist def add_include_dirs(self, args: T.Sequence['IncludeDirs'], set_is_system: T.Optional[str] = None) -> None: + print("\n========= add_include_dirs:", args) + print("\n") ids: T.List['IncludeDirs'] = [] for a in args: if not isinstance(a, IncludeDirs): diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index b5ab241ca48d..abe82af947b3 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -871,9 +871,11 @@ def get_build_dir(self) -> str: return self.build_dir def build_output_rpath(self, subdir: str, *parts: T.Sequence[str]) -> str: - result = subdir if self.coredata.is_native_clone: - result += '-native' + assert subdir.startswith('subprojects') + result = 'subprojects-native' + subdir[11:] + else: + result = subdir return os.path.join(result, *parts) def get_import_lib_dir(self) -> str: