diff --git a/SKILL.md b/SKILL.md index 372974d..b2e3912 100644 --- a/SKILL.md +++ b/SKILL.md @@ -256,7 +256,7 @@ changes what "migrated" means, so surface it when first diff; the test-inclusive configure for [Diff tests](#diff-tests) is recorded apart, as `test_configure_command`. -### Create initial BUILD.bazel files +### Create initial BUILD.bazel files {#create-build-files} Read `model..json`. For each production target emit a `cc_library` / `cc_binary` with `srcs`, `hdrs`, `copts`, `defines`, `includes`, `deps`. Library @@ -270,6 +270,9 @@ rather than recalled). Put `common --check_direct_dependencies=error` in the generated `.bazelrc` so a declared version that MVS overrides fails the build instead of being a warning nobody reads. +The reference guide covers what is specific to translating its build system +(for CMake: the build type). + ### Main migration loop {#main-migration-loop} #### Extract the Bazel action graph {#extract-bazel-graph} diff --git a/docs/REFERENCE-cmake.md b/docs/REFERENCE-cmake.md index ce6227a..db36825 100644 --- a/docs/REFERENCE-cmake.md +++ b/docs/REFERENCE-cmake.md @@ -46,6 +46,23 @@ python3 "$SKILL_DIR/scripts/extract_cmake.py" model.cmake.js The project flags passed to `cmake` define the platform/options the Bazel aquery must mirror. +## Writing the BUILD files + +What is specific to CMake when +[creating the BUILD files](../SKILL.md#create-build-files). + +### Build type + +`--compilation_mode` is not a translation of `CMAKE_BUILD_TYPE`: Release is +`-O3 -DNDEBUG` where Bazel's `opt` is `-O2 -DNDEBUG`, and Debug is `-g` where +Bazel's default `fastbuild` has neither. A project may set its own default +build type in `CMakeLists.txt` even when none is passed. Read the reference's +level (`levels` in `diff.json`, or `CMAKE__FLAGS_` in the cache) +and pin it in `.bazelrc`, e.g. `build -c opt` plus `build --copt=-O3`. `opt` +also turns assertions off where the reference keeps them (`ndebug` in +`diff.json`); `build --copt=-UNDEBUG` undoes the toolchain's `-DNDEBUG`, not +one in a rule's `copts`. + ## CMake-specific comparison notes - **Target names** in `target_map` and `exclude_targets` keys are CMake target