Skip to content

fix: stabilize CXX API generator on MacOS, make parser indempotent for nested enums#57536

Open
artus9033 wants to merge 3 commits into
react:mainfrom
artus9033:fix/cxx-api-codegen-macos
Open

fix: stabilize CXX API generator on MacOS, make parser indempotent for nested enums#57536
artus9033 wants to merge 3 commits into
react:mainfrom
artus9033:fix/cxx-api-codegen-macos

Conversation

@artus9033

@artus9033 artus9033 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary:

Fixes C++ API snapshot generation failures for nested enums and macOS/Linux output drift due to platform-dependent behavior, in the CXX API generator.

Problems

  1. Duplicate enums: Doxygen parses codegen EventEmitters.h twice (direct codegen input + again via .mm includes). The parser raised RuntimeError: Identifier OnOrientationChangeOrientation already exists in scope ModalHostViewEventEmitter on ReactApple* views.

  2. Inconsistent behaviour on MacOS vs Linux:

  • for codegen component aliases (ConcreteComponentDescriptor, ConcreteViewShadowNode), macOS Doxygen emits hybrid XML definitions (typedef Type Name = Type) while Linux CI emits using Name = Type. The parser keyed off definition.startswith("typedef"), so identical source produced different .api output per platform.
  • CASE_SENSE_NAMES = SYSTEM follows the host OS default (case-insensitive on macOS, case-sensitive on Linux), causing inconsistent symbol resolution.

Resolution

  • .doxygen.config.template files: set CASE_SENSE_NAMES = YES for deterministic name matching across macOS and Linux.
  • snapshot.py: create_enum() returns an existing enum scope instead of raising when the enum is already registered.
  • builders.py: create_enum_scope() to skip enums that already exist; get_typedef_member() to normalize Doxygen’s typedef ... = ... form to using so the output format is unified.

Changelog:

[INTERNAL] [FIXED] - Fix C++ API snapshot generation crash on duplicate codegen enums
[INTERNAL] [FIXED] - Fix platform-dependent inconsistent CXX API generator output

Test Plan:

  • yarn cxx-api-build completes on macOS (tested locally)
  • yarn cxx-api-validate passes (tested locally on MacOS & on the Linux CI)
  • validate-cxx-api-snapshots passes on Linux (tested on CI)

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 13, 2026
@facebook-github-tools facebook-github-tools Bot added p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jul 13, 2026

@cipolleschi cipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing the parser. I left a comment on one of the changes.

Comment on lines +472 to +473
"ConcreteComponentDescriptor" in typedef_definition
or "ConcreteViewShadowNode" in typedef_definition

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of this ad hoc handling.. Is this actually happening for only these two cases? OR can we generalize the behavior somehow.

@artus9033 artus9033 Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I only reproduced an edge case for these 2 cases. I've tried finding a broader approach pattern and it unfortunately modifies existing contents to use using where there used to be typedef. At least, I couldn't find a broader approach / other cases breaking the parser.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants