Skip to content

feat: generate compile database without building - #387

Open
wellwei wants to merge 13 commits into
mcpp-community:mainfrom
wellwei:codex/configure-only-cdb
Open

feat: generate compile database without building#387
wellwei wants to merge 13 commits into
mcpp-community:mainfrom
wellwei:codex/configure-only-cdb

Conversation

@wellwei

@wellwei wellwei commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

  • add mcpp build --configure-only, reusing the real build plan and existing build selectors while skipping ordinary compilation, linking, BMI cache population, and build-success cache writes
  • include tests/**/*.cpp, matching [build].flags, and test dev-dependencies in the generated CDB; stage only std and already-cached dependency BMIs needed by language tooling
  • publish compile_commands.json atomically across platforms, preserve last-known-good files and CDB symlinks, and keep normal build/test publication failures non-fatal
  • document the trust and side-effect boundary: configure-only may still execute build.mcpp, resolve/install dependencies or toolchains, and update lock/resolution metadata

This is the independently agreed A part from #379. It intentionally does not add JSON/NDJSON, ide subcommands, snapshots, mcpp.wire, invalidatedBy, or new selector semantics. It does not close the RFC.

Core impact

  • shared test target discovery is extracted from mcpp test; existing list/build/run behavior remains covered by unit and E2E tests
  • the Ninja backend gains an opt-in requireCompileDatabase flag; default build/test behavior remains warning-only
  • CDB publication changes from direct truncation to same-directory temporary write plus atomic replacement; concurrent writers remain documented last-writer-wins

Test plan

  • fresh self-hosted mcpp build --no-color --no-cache on macOS ARM64
  • fresh mcpp test --no-color: 70 passed, 0 failed
  • tests/e2e/202_configure_only_cdb.sh: syntax-error source, test/dev-dependency flags, workspace fan-out, -p, no build artifacts/cache, publication failure preservation
  • adjacent E2E: 01, 18, 35, 76, 77, 90, 157, 159
  • unit coverage for test discovery, configure prerequisites, atomic replacement, unchanged mtime, symlink preservation, unreadable/failed destinations

Refs #379
Refs mcpp-community/mcpp-vscode#5

Comment thread .agents/docs/2026-08-08-configure-only-cdb-implementation-plan.md
… replace

- publish_compile_commands: treat a missing CDB (symlink_status type ==
  not_found) as the normal first-build case instead of a fatal error.
  is_symlink sets ec on missing paths on every standard library (generic
  ENOENT on libstdc++/libc++, system ERROR_FILE_NOT_FOUND on MSVC), so no
  compile_commands.json was ever written on fresh workspaces and all
  CDB-dependent e2e tests failed.
- close the existing-CDB ifstream before the atomic replace so Windows
  MoveFileExW can replace the destination (open handles cause Access
  denied / sharing violation).
- unit tests: escape Windows backslash paths in the entry() JSON helper,
  write the mtime fixture in binary mode so on-disk bytes match on
  Windows, and add a regression test for publishing with no prior CDB.
@wellwei
wellwei requested a review from Sunrisepeak August 8, 2026 15:13
wellwei added 3 commits August 8, 2026 23:53
# Conflicts:
#	tests/unit/test_compile_commands.cpp
Windows CDBs store file paths with backslashes, so `grep 'src/main.cpp'`
never matched and the test failed on the Windows e2e shard once the CDB
was actually being generated. Match either separator with `[\/]`.
Windows CDBs store paths with JSON-escaped backslashes (src\\main.cpp),
so one-separator patterns still missed. Allow one or more separators.
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.

2 participants