Skip to content

Commit

Permalink
Fix unity issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Aug 23, 2024
1 parent bc93e22 commit 40b0a6b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,8 @@ def compile_target_to_generator(self, target: build.CompileTarget) -> build.Gene
target.output_templ, target.depends)

def is_unity(self, target: build.BuildTarget) -> bool:
if isinstance(target, build.CompileTarget):
return False
val = self.get_target_option(target, 'unity')
if val == 'on':
return True
Expand Down
8 changes: 6 additions & 2 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ def process_link_depends(self, sources):
'Link_depends arguments must be strings, Files, '
'or a Custom Target, or lists thereof.')

def extract_objects(self, srclist: T.List[T.Union['FileOrString', 'GeneratedTypes']]) -> ExtractedObjects:
def extract_objects(self, srclist: T.List[T.Union['FileOrString', 'GeneratedTypes']], is_unity: bool) -> ExtractedObjects:
sources_set = set(self.sources)
generated_set = set(self.generated)

Expand All @@ -1037,7 +1037,11 @@ def extract_objects(self, srclist: T.List[T.Union['FileOrString', 'GeneratedType
obj_gen.append(src)
else:
raise MesonException(f'Object extraction arguments must be strings, Files or targets (got {type(src).__name__}).')
return ExtractedObjects(self, obj_src, obj_gen)
eobjs = ExtractedObjects(self, obj_src, obj_gen)
if is_unity:
eobjs.check_unity_compatible()
return eobjs


def extract_all_objects(self, recursive: bool = True) -> ExtractedObjects:
return ExtractedObjects(self, self.sources, self.generated, self.objects,
Expand Down
8 changes: 4 additions & 4 deletions mesonbuild/interpreter/interpreterobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,10 @@ def extract_objects_method(self, args: T.Tuple[T.List[T.Union[mesonlib.FileOrStr
unity_value = self.interpreter.coredata.get_option_for_target(tobj, "unity")
if unity_value == 'on' or \
(unity_value == 'subprojects' and tobj.subproject != ''):
raise mesonlib.MesonException(('Single object files cannot be extracted '
'in Unity builds. You can only extract all '
'the object files for each compiler at once.'))
return tobj.extract_objects(args[0])
is_unity = True
else:
is_unity = False
return tobj.extract_objects(args[0], is_unity)

@noPosargs
@typed_kwargs(
Expand Down

0 comments on commit 40b0a6b

Please sign in to comment.