Skip to content

Commit

Permalink
build: Move build subdir logic into compute_build_subdir()
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Mar 18, 2024
1 parent e990499 commit 6b1f73f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def to_string_list(self, sourcedir: str, builddir: str) -> T.List[str]:
be added if this is unset
:returns: A list of strings (without compiler argument)
"""
bsubdir = f'build.{self.curdir}' if self.is_build_only_subproject else self.curdir
bsubdir = compute_build_subdir(self.curdir, self.is_build_only_subproject)

strlist: T.List[str] = []
for idir in self.incdirs:
Expand Down Expand Up @@ -672,9 +672,7 @@ def get_source_subdir(self) -> str:
return self.subdir

def get_output_subdir(self) -> str:
if self.build_only_subproject:
return f'build.{self.subdir}'
return self.get_source_subdir()
return compute_build_subdir(self.subdir, self.build_only_subproject)

def get_typename(self) -> str:
return self.typename
Expand Down Expand Up @@ -2005,9 +2003,7 @@ def get_source_subdir(self) -> str:
return self.subdir

def get_output_subdir(self) -> str:
if self.is_build_only_subproject:
return f'build.{self.subdir}'
return self.get_source_subdir()
return compute_build_subdir(self.subdir, self.is_build_only_subproject)


class Executable(BuildTarget):
Expand Down Expand Up @@ -3186,6 +3182,11 @@ def get_sources_string_names(sources, backend):
raise AssertionError(f'Unknown source type: {s!r}')
return names

def compute_build_subdir(subdir: str, build_only_subproject: bool) -> str:
if build_only_subproject:
return f'build.{subdir}'
return subdir

def load(build_dir: str) -> Build:
filename = os.path.join(build_dir, 'meson-private', 'build.dat')
try:
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ def _do_subproject_meson(self, subp_name: SubProject, subdir: str,
ast.accept(printer)
printer.post_process()
bsubdir = os.path.join(self.build.environment.get_build_dir(),
subdir if not new_build.environment.coredata.is_build_only else f'build.{subdir}')
build.compute_build_subdir(subdir, new_build.environment.coredata.is_build_only))
os.makedirs(bsubdir, exist_ok=True)
meson_filename = os.path.join(bsubdir, 'meson.build')
with open(meson_filename, "w", encoding='utf-8') as f:
Expand Down

0 comments on commit 6b1f73f

Please sign in to comment.