Skip to content

Conversation

@dmaranges-gd
Copy link
Contributor

Summary

The main goal is to separate the logic to apply clang formatting, for that I move the logic to codegen.py

Related issues

ticket #38774

Testing

you can check the time and the output on the ZAP Regeneration job or run it locally with the command "./scripts/run_in_build_env.sh scripts/tools/zap_regen_all.py"

Readability checklist

The checklist below will help the reviewer finish PR review in time and keep the
code readable:

  • PR title is
    descriptive
  • Apply the
    “When in Rome…”
    rule (coding style)
  • PR size is short
  • Try to avoid "squashing" and "force-update" in commit history
  • CI time didn't increase

See: Pull Request Guidelines

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the clang-formatting logic by moving it from zap_regen_all.py to codegen.py. This is a good change as it places the formatting logic closer to where the files are generated. The implementation is sound and consistent with the previous behavior. I have one suggestion to make the code for collecting C++ files more concise and Pythonic.

dmaranges-gd and others added 2 commits October 20, 2025 17:25
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

subprocess.check_call([getClangFormatBinary(), "-i"] + cpp_files)
except Exception:
traceback.print_exc()
Copy link
Contributor

@bzbarsky-apple bzbarsky-apple Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this! This will really help me out when done.

When I do codegen on top of this PR locally, I get:

Traceback (most recent call last):
  File "/Users/bzbarsky/connectedhomeip/./scripts/codegen.py", line 187, in main
    subprocess.check_call([getClangFormatBinary(), "-i"] + cpp_files)
  File "/Users/bzbarsky/connectedhomeip/.environment/cipd/packages/pigweed/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/bzbarsky/connectedhomeip/.environment/cipd/packages/pigweed/bin/clang-format', '-i', ... long list of paths ... ]' returned non-zero exit status 1.

but then codegen claims to succeed even though it failed, because this code is swallowing the exception (which admittedly the old code did too).

The error messages before that look like a long list of:

RelativeHumidityMeasurement/MetadataProvider.h: No such file or directory

and such, so it looks like this is passing in relative paths that are not relative to the cwd?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review!! I missed the join method to select the right path, leading to an error related to the paths

I'm working on fixing it, and when I finish it I will request a new review

@github-actions
Copy link

PR #41543: Size comparison from 3e5d0a5 to 49813b3

Full report (6 builds for cc32xx, nrfconnect, realtek, stm32)
platform target config section 3e5d0a5 49813b3 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554286 554286 0 0.0
RAM 205736 205736 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587534 587534 0 0.0
RAM 205832 205832 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 933064 933064 0 0.0
RAM 161313 161313 0 0.0
realtek light-switch-app rtl8777g FLASH 706584 706584 0 0.0
RAM 106904 106904 0 0.0
lighting-app rtl8777g FLASH 757672 757672 0 0.0
RAM 127236 127236 0 0.0
stm32 light STM32WB5MM-DK FLASH 470076 470076 0 0.0
RAM 141304 141304 0 0.0

@github-actions
Copy link

PR #41543: Size comparison from 3e5d0a5 to b4be92f

Full report (6 builds for cc32xx, nrfconnect, realtek, stm32)
platform target config section 3e5d0a5 b4be92f change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554286 554286 0 0.0
RAM 205736 205736 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587534 587534 0 0.0
RAM 205832 205832 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 933064 933064 0 0.0
RAM 161313 161313 0 0.0
realtek light-switch-app rtl8777g FLASH 706584 706584 0 0.0
RAM 106904 106904 0 0.0
lighting-app rtl8777g FLASH 757672 757672 0 0.0
RAM 127236 127236 0 0.0
stm32 light STM32WB5MM-DK FLASH 470076 470076 0 0.0
RAM 141304 141304 0 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

3 participants