Skip to content

Commit de72f1f

Browse files
committed
separate the concerns, leave hardcoded groups for testing
1 parent 964d460 commit de72f1f

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

scripts/build/build/target.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,30 @@ def __init__(self, name, builder_class, **kwargs):
225225
def isUnifiedBuild(self, parts: List[TargetPart]):
226226
"""Checks if the given parts combine into a unified build.
227227
228-
Returns the unified group ID (e.g., 'main', 'no-read-client', 'rpc-json')
229-
if this is a unified build, or None otherwise.
228+
Returns the unified group ID based on the combination of modifiers present.
229+
The group determines which output directory and build configuration to use.
230230
"""
231+
has_unified = False
231232
for part in parts:
232233
if part.build_arguments.get('unified', False):
233-
# Return the group ID, defaulting to 'main' for backward compatibility
234-
return part.build_arguments.get('unified_group', 'main')
235-
return None
234+
has_unified = True
235+
break
236+
237+
if not has_unified:
238+
return None
239+
240+
# Auto-detect unified group based on which other modifiers are present
241+
has_no_read_client = any(part.build_arguments.get('chip_enable_read_client', None) == False
242+
for part in parts)
243+
has_rpc = any(part.build_arguments.get('enable_rpcs', False)
244+
for part in parts)
245+
246+
if has_no_read_client:
247+
return 'group2'
248+
elif has_rpc:
249+
return 'group3'
250+
else:
251+
return 'main'
236252

237253
def AppendFixedTargets(self, parts: List[TargetPart]):
238254
"""Append a list of potential targets/variants.
@@ -467,12 +483,17 @@ def Create(self, name: str, runner, repository_path: str, output_prefix: str,
467483
for part in parts:
468484
kargs.update(part.build_arguments)
469485

486+
# Determine unified group before creating builder
487+
unified_group = self.isUnifiedBuild(parts)
488+
if unified_group:
489+
kargs['unified_group'] = unified_group
490+
470491
logging.info("Preparing builder '%s'" % (name,))
471492

472493
builder = self.builder_class(repository_path, runner=runner, **kargs)
473494
builder.target = self
474495
builder.identifier = name
475-
unified_group = self.isUnifiedBuild(parts)
496+
476497
if unified_group:
477498
# Use group-specific output directory
478499
# group2 = apps with chip_enable_read_client=false

scripts/build/builders/host.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,18 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
416416
enable_webrtc=False,
417417
terms_and_conditions_required: Optional[bool] = None, chip_enable_nfc_based_commissioning=None,
418418
chip_enable_read_client=True,
419-
unified=False
419+
unified=False,
420+
unified_group=None
420421
):
421422
"""
422423
Construct a host builder.
423424
424425
Params (limited docs, documenting interesting ones):
425426
426427
- unified: build will happen in a SINGLE output directory instead of separated out
427-
into per-target directories. The specific unified group is automatically
428-
determined based on build configuration (chip_enable_read_client, enable_rpcs, etc.)
428+
into per-target directories.
429+
- unified_group: which unified group this build belongs to (determined automatically
430+
by target.py based on modifiers present)
429431
"""
430432

431433
# Unified builds use the top level root for compilation
@@ -455,21 +457,14 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
455457
self.extra_gn_options.append('chip_enable_read_client=false')
456458

457459
if unified:
458-
# Auto-detect unified group based on build configuration
459-
if not chip_enable_read_client:
460-
unified_group = 'group2'
461-
elif enable_rpcs:
462-
unified_group = 'group3'
463-
else:
464-
unified_group = 'main'
465-
466460
self.extra_gn_options.append('target_os="all"')
467461
self.extra_gn_options.append('matter_enable_tracing_support=true')
468462
# All unified builds use JSON logging for better debugging
469463
self.extra_gn_options.append('matter_log_json_payload_hex=true')
470464
self.extra_gn_options.append('matter_log_json_payload_decode_full=true')
471465

472-
self.build_command = app.UnifiedTargetName(unified_group)
466+
# Use the unified_group determined by target.py
467+
self.build_command = app.UnifiedTargetName(unified_group or 'main')
473468

474469
if not enable_wifipaf:
475470
self.extra_gn_options.append(

0 commit comments

Comments
 (0)