Repository navigation
Migrate Bazel build to explicit rule loads for Bazel 9/10 forward compatibility - #1381
Merged
Merged
Conversation
…patibility
Bazel 9 removes the native `sh_binary`/`cc_*` rules and the `CcInfo`
global, and Bazel 10 stops letting source files inherit package
`default_visibility`. Add the missing `load()` statements, the
`rules_shell` module dependency, and `exports_files()` declarations so
the tree builds and tests green on Bazel 7, 8, 9, and the 10 rolling
release without changing behavior on any of them.
Detailed Changes:
- **Native rule loads**:
- Load `sh_binary` from `@rules_shell` in `scripts/BUILD.bazel` and add
`bazel_dep(name = "rules_shell", ...)` to `MODULE.bazel`.
- Load `cc_binary`/`cc_library`/`cc_test` from `@rules_cc//cc:defs.bzl`
in `src/tools`, `src` (adds `cc_test`), `data/config`,
`data/dictionary`, `examples/config`, and `test/config_test`.
- Load `cc_library` in the vendored `deps/rapidjson-1.1.0` and
`deps/darts-clone-0.32h` BUILD files, and add a `rules_cc` dep to the
`darts-clone` module so `@rules_cc` resolves in its repo mapping.
- **CcInfo global removal**:
- Load `CcInfo` from `@rules_cc//cc/common:cc_info.bzl` in
`node/cc_headers_files.bzl`.
- **Source-file visibility**:
- Add `exports_files()` for the public headers in `src`, the config
JSONs in `data/config`, and `CJK_Compatibility_Ideographs.txt` in
`data/dictionary`, which are referenced across packages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
動機
Bazel 9 移除了原生
sh_binary/cc_*規則以及CcInfo全域符號,Bazel 10(rolling)進一步不再讓 source file 繼承 packagedefault_visibility。本 PR 補上必要的load()、rules_shellmodule 依賴與exports_files(),讓整個 build tree 在 Bazel 7 / 8 / 9 / 10 rolling 上皆可建置與測試,且不改變任何版本的行為。變更內容
原生規則 load
scripts/BUILD.bazel從@rules_shellloadsh_binary,並在MODULE.bazel加入bazel_dep(name = "rules_shell", version = "0.8.0")。src/tools、src(新增cc_test)、data/config、data/dictionary、examples/config、test/config_test從@rules_cc//cc:defs.bzlloadcc_binary/cc_library/cc_test。deps/rapidjson-1.1.0、deps/darts-clone-0.32hBUILD 檔 loadcc_library;並在darts-clone的MODULE.bazel加入rules_cc依賴,使@rules_cc能在其 repo mapping 內解析。CcInfo 全域移除
node/cc_headers_files.bzl從@rules_cc//cc/common:cc_info.bzlloadCcInfo。Source file 可見性
exports_files():src的公開標頭、data/config的 config JSON、data/dictionary的CJK_Compatibility_Ideographs.txt。測試結果
使用 CI 的測試指令逐版驗證:
🤖 Generated with Claude Code