Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence zap_regen_all to generate .matter first. #26806

Merged
merged 2 commits into from
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions scripts/tools/zap_regen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def __init__(self, zap_config, template, output_dir=None):
else:
self.output_dir = None

@property
def is_matter_idl_generation(self):
return (self.output_dir is None)

def distinct_output(self):
if not self.template and not self.output_dir:
# Matter IDL templates have no template/output dir as they go with the
Expand Down Expand Up @@ -489,9 +493,22 @@ def main():
if args.parallel:
# Ensure each zap run is independent
os.environ['ZAP_TEMPSTATE'] = '1'
with multiprocessing.Pool() as pool:
for timing in pool.imap_unordered(_ParallelGenerateOne, targets):
timings.append(timing)

# There is a sequencing here:
# - ZAP will generate ".matter" files
# - various codegen may generate from ".matter" files (like java)
# We split codegen into two generations to not be racy
first, second = [], []
for target in targets:
if isinstance(target, ZAPGenerateTarget) and target.is_matter_idl_generation:
first.append(target)
else:
second.append(target)

for items in [first, second]:
with multiprocessing.Pool() as pool:
for timing in pool.imap_unordered(_ParallelGenerateOne, items):
timings.append(timing)
else:
for target in targets:
timings.append(target.generate())
Expand Down