Skip to content

Commit

Permalink
[WIP] Start reworking target directory logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Mar 11, 2024
1 parent 8ad5851 commit 8e6db55
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ('', '.'):
Expand All @@ -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:
Expand Down Expand Up @@ -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():
Expand Down
5 changes: 4 additions & 1 deletion mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] = []
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions mesonbuild/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8e6db55

Please sign in to comment.