Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<frontend>.json`. For each production target emit a `cc_library` /
`cc_binary` with `srcs`, `hdrs`, `copts`, `defines`, `includes`, `deps`. Library
Expand All @@ -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}
Expand Down
17 changes: 17 additions & 0 deletions docs/REFERENCE-cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ python3 "$SKILL_DIR/scripts/extract_cmake.py" <build> <repo_root> 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_<LANG>_FLAGS_<CONFIG>` 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
Expand Down
Loading