mirror of
https://github.com/mesonbuild/meson.git
synced 2026-11-06 05:16:42 +00:00
build: differentiate build directory according to a subproject's build machine
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
1 parent
3cba9ee127
commit
499f73da17
5 files changed
+26
-13
No files matched your search
+19
-9
@@ -309,6 +309,10 @@ class BuildProject:
|
||||
project_args: PerMachine[T.Dict[Language, T.List[str]]] = field(default_factory=lambda: PerMachine({}, {}))
|
||||
project_link_args: PerMachine[T.Dict[Language, T.List[str]]] = field(default_factory=lambda: PerMachine({}, {}))
|
||||
|
||||
@lazy_property
|
||||
def prefix(self) -> str:
|
||||
return 'build.' if self.for_machine is MachineChoice.BUILD else ''
|
||||
|
||||
|
||||
# literally everything isn't dataclass stuff
|
||||
class Build:
|
||||
@@ -491,6 +495,7 @@ class IncludeDirs(HoldableObject):
|
||||
curdir: str
|
||||
incdirs: T.List[str]
|
||||
is_system: bool
|
||||
build_project: BuildProject
|
||||
extra_build_dirs: T.List[str] = field(default_factory=list)
|
||||
|
||||
def abs_string_list(self, sourcedir: str, builddir: str) -> T.List[str]:
|
||||
@@ -501,12 +506,14 @@ class IncludeDirs(HoldableObject):
|
||||
be added if this is unset
|
||||
:returns: A list of strings (without compiler argument)
|
||||
"""
|
||||
bsubdir = self.build_project.prefix + self.curdir
|
||||
|
||||
strlist: T.List[str] = []
|
||||
for idir in self.incdirs:
|
||||
strlist.append(os.path.join(sourcedir, self.curdir, idir))
|
||||
strlist.append(os.path.join(builddir, self.curdir, idir))
|
||||
strlist.append(os.path.join(builddir, bsubdir, idir))
|
||||
for idir in self.extra_build_dirs:
|
||||
strlist.append(os.path.join(builddir, self.curdir, idir))
|
||||
strlist.append(os.path.join(builddir, bsubdir, idir))
|
||||
return strlist
|
||||
|
||||
def rel_string_list(self, build_to_src: str, build_root: T.Optional[str] = None) -> T.List[str]:
|
||||
@@ -518,13 +525,15 @@ class IncludeDirs(HoldableObject):
|
||||
:return: A list if strings (without compiler argument)
|
||||
"""
|
||||
strlist: T.List[str] = []
|
||||
bsubdir = self.build_project.prefix + self.curdir
|
||||
|
||||
for idirs, add_src in [(self.incdirs, True), (self.extra_build_dirs, False)]:
|
||||
for idir in idirs:
|
||||
dir = os.path.normpath(os.path.join(self.curdir, idir))
|
||||
if build_root is None or os.path.isdir(os.path.join(build_root, dir)):
|
||||
strlist.append(dir)
|
||||
bld_dir = os.path.normpath(os.path.join(bsubdir, idir))
|
||||
if build_root is None or os.path.isdir(os.path.join(build_root, bld_dir)):
|
||||
strlist.append(bld_dir)
|
||||
if add_src:
|
||||
strlist.append(os.path.normpath(os.path.join(build_to_src, dir)))
|
||||
strlist.append(os.path.normpath(os.path.join(build_to_src, self.curdir, idir)))
|
||||
|
||||
return strlist
|
||||
|
||||
@@ -651,9 +660,9 @@ class Target(HoldableObject, metaclass=SimpleABC):
|
||||
Target "{self.name}" has a path separator in its name.
|
||||
This is not supported, it can cause unexpected failures and will become
|
||||
a hard error in the future.'''))
|
||||
self.builddir = self.subdir
|
||||
self.builddir = self.build_project.prefix + self.subdir
|
||||
if self.build_subdir:
|
||||
self.builddir = os.path.join(self.subdir, self.build_subdir)
|
||||
self.builddir = os.path.join(self.builddir, self.build_subdir)
|
||||
|
||||
# dataclass comparators?
|
||||
def __lt__(self, other: object) -> bool:
|
||||
@@ -1586,7 +1595,8 @@ class BuildTarget(Target):
|
||||
def add_include_dirs(self, args: T.Sequence['IncludeDirs'], set_is_system: str = 'preserve') -> None:
|
||||
if set_is_system != 'preserve':
|
||||
is_system = set_is_system == 'system'
|
||||
self.include_dirs.extend([IncludeDirs(x.curdir, x.incdirs, is_system, x.extra_build_dirs) for x in args])
|
||||
self.include_dirs.extend([IncludeDirs(x.curdir, x.incdirs, is_system, x.build_project,
|
||||
x.extra_build_dirs) for x in args])
|
||||
else:
|
||||
self.include_dirs.extend(args)
|
||||
|
||||
|
||||
@@ -2994,7 +2994,7 @@ class Interpreter(InterpreterBase, HoldableObject):
|
||||
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, self.current_build_project())
|
||||
return i
|
||||
|
||||
@typed_pos_args('add_test_setup', str)
|
||||
|
||||
@@ -1013,7 +1013,8 @@ class BuildTargetHolder(ObjectHolder[_BuildTarget]):
|
||||
@noKwargs
|
||||
@InterpreterObject.method('private_dir_include')
|
||||
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.current_build_project(),
|
||||
[self.interpreter.backend.get_target_private_dir(self._target_object)])
|
||||
|
||||
@noPosargs
|
||||
@noKwargs
|
||||
|
||||
@@ -2314,7 +2314,8 @@ class GnomeModule(ExtensionModule):
|
||||
# - 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,
|
||||
state.current_build_project)]
|
||||
sources = [vapi_target] + vapi_depends
|
||||
rv = InternalDependency(None, incs, [], [], link_with, [], sources, [], [], {}, [], [], [])
|
||||
created_values.append(rv)
|
||||
|
||||
@@ -124,7 +124,8 @@ class WindowsModule(ExtensionModule):
|
||||
for d in wrc_depends:
|
||||
if isinstance(d, build.CustomTarget):
|
||||
extra_args += state.get_include_args([
|
||||
build.IncludeDirs('', [], False, [self.interpreter.backend.get_target_dir(d)])
|
||||
build.IncludeDirs('', [], False, state.current_build_project,
|
||||
[self.interpreter.backend.get_target_dir(d)])
|
||||
])
|
||||
extra_args += state.get_include_args(kwargs['include_directories'], kwargs['implicit_include_directories'])
|
||||
|
||||
|
||||
Reference in new issue
Block a user