Skip to content

fix: fold [build].defines into cflags/cxxflags before P1689 scan - #297

Open
ZheFeng7110 wants to merge 3 commits into
mcpp-community:mainfrom
ZheFeng7110:fix/build-defines-p1689-scan
Open

fix: fold [build].defines into cflags/cxxflags before P1689 scan#297
ZheFeng7110 wants to merge 3 commits into
mcpp-community:mainfrom
ZheFeng7110:fix/build-defines-p1689-scan

Conversation

@ZheFeng7110

Copy link
Copy Markdown
Member

Summary

[build].defines was parsed by the TOML loader but never folded into the compile flags used by the P1689 module scanner. When import statements were guarded by a macro declared in [build].defines, the scanner saw no imports, while the planner (via scan_overrides) expected them, causing a plan-vs-scan divergence.

This PR fixes that by:

  1. Adding defines to BuildConfig in src/manifest/types.cppm.
  2. Parsing [build].defines in src/manifest/toml.cppm.
  3. Introducing fold_build_defines_into_flags() in src/build/prepare.cppm to desugar defines into -D<x> on both cflags and cxxflags before the manifest is snapshotted into packages and before fingerprinting.
  4. Adding a unit test and an E2E regression test (tests/e2e/167_build_defines_module_scan.sh) that mirrors the conditional-import + scan_overrides scenario.
  5. Updating docs/05-mcpp-toml.md and docs/zh/05-mcpp-toml.md.

Closes #296

Test plan

  • mcpp build self-hosts successfully.
  • mcpp test unit/test_manifest passes.
  • New E2E test tests/e2e/167_build_defines_module_scan.sh passes.
  • Reproduced the original failure with the unpatched binary and confirmed the patched binary builds the user's example.

[build].defines was parsed but never folded into the compile flags used
by the P1689 module scanner. When imports were guarded by a macro from
[build].defines, the scanner saw no imports while the planner (via
scan_overrides) expected them, causing module-graph divergence.

- Add defines to BuildConfig
- Parse [build].defines in TOML loader
- Fold defines into -D<x> on cflags/cxxflags before snapshot/fingerprint
- Add unit test and E2E regression test
- Update English and Chinese docs

Closes mcpp-community#296
[build].defines was parsed but never folded into the compile flags used
by the P1689 module scanner. When imports were guarded by a macro from
[build].defines, the scanner saw no imports while the planner (via
scan_overrides) expected them, causing module-graph divergence.

- Add defines to BuildConfig
- Parse [build].defines in TOML loader
- Fold defines into -D<x> on cflags/cxxflags before snapshot/fingerprint
- Add unit test and E2E regression test
- Update English and Chinese docs

Closes mcpp-community#296
…to fix/build-defines-p1689-scan

# Conflicts:
#	tests/e2e/167_build_defines_module_scan.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: [build].defines 未被传入 P1689 模块扫描,导致条件 import 与 scan_overrides 冲突

1 participant