Skip to content

Commit

Permalink
IncludeDirs store build-only-subproject
Browse files Browse the repository at this point in the history
The builddir will not mirror the subdir in this case, and we need to
track that.
  • Loading branch information
dcbaker committed Sep 22, 2023
1 parent 4e5e617 commit 0bb0ef4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ class IncludeDirs(HoldableObject):
# actually exist.
extra_build_dirs: T.List[str] = field(default_factory=list)

# We need to know this for stringifying correctly
is_build_only_subproject: bool = False

def __repr__(self) -> str:
r = '<{} {}/{}>'
return r.format(self.__class__.__name__, self.curdir, self.incdirs)
Expand Down Expand Up @@ -1598,7 +1601,7 @@ def add_include_dirs(self, args: T.Sequence['IncludeDirs'], set_is_system: T.Opt
set_is_system = 'preserve'
if set_is_system != 'preserve':
is_system = set_is_system == 'system'
ids = [IncludeDirs(x.get_curdir(), x.get_incdirs(), is_system, x.get_extra_build_dirs()) for x in ids]
ids = [IncludeDirs(x.get_curdir(), x.get_incdirs(), is_system, x.get_extra_build_dirs(), x.is_build_only_subproject) for x in ids]
self.include_dirs += ids

def add_compiler_args(self, language: str, args: T.List['FileOrString']) -> None:
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2890,7 +2890,8 @@ def build_incdir_object(self, incdir_strings: T.List[str], is_system: bool = Fal
absdir_build = os.path.join(absbase_build, a)
if not os.path.isdir(absdir_src) and not os.path.isdir(absdir_build):
raise InvalidArguments(f'Include dir {a} does not exist.')
i = build.IncludeDirs(self.subdir, incdir_strings, is_system)
i = build.IncludeDirs(
self.subdir, incdir_strings, is_system, is_build_only_subproject=self.build.is_build_only)
return i

@typed_pos_args('add_test_setup', str)
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/interpreter/interpreterobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,8 @@ def found_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> bool:
@noPosargs
@noKwargs
def private_dir_include_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> build.IncludeDirs:
return build.IncludeDirs('', [], False, [self.interpreter.backend.get_target_private_dir(self._target_object)])
return build.IncludeDirs('', [], False, [self.interpreter.backend.get_target_private_dir(self._target_object)],
self.interpreter.build.is_build_only)

@noPosargs
@noKwargs
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,8 @@ def generate_vapi(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'Gener
# - link with the correct library
# - include the vapi and dependent vapi files in sources
# - add relevant directories to include dirs
incs = [build.IncludeDirs(state.subdir, ['.'] + vapi_includes, False)]
incs = [build.IncludeDirs(state.subdir, ['.'] + vapi_includes, False,
is_build_only_subproject=state.is_build_only_subproject)]
sources = [vapi_target] + vapi_depends
rv = InternalDependency(None, incs, [], [], link_with, [], sources, [], [], {}, [], [], [])
created_values.append(rv)
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/modules/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ def compile_resources(self, state: 'ModuleState',
for d in wrc_depends:
if isinstance(d, build.CustomTarget):
extra_args += state.get_include_args([
build.IncludeDirs('', [], False, [os.path.join('@BUILD_ROOT@', self.interpreter.backend.get_target_dir(d))])
build.IncludeDirs('', [], False, [os.path.join('@BUILD_ROOT@', self.interpreter.backend.get_target_dir(d))],
state.is_build_only_subproject)
])
extra_args += state.get_include_args(kwargs['include_directories'])

Expand Down

0 comments on commit 0bb0ef4

Please sign in to comment.