Skip to content

Migrate Bazel build to explicit rule loads for Bazel 9/10 forward compatibility - #1381

Merged
frankslin merged 1 commit into
masterfrom
claude/nervous-wozniak-2a2727
Jul 1, 2026
Merged

frankslin merged 1 commit into
masterfrom
claude/nervous-wozniak-2a2727

Conversation

@BYVoid

@BYVoid BYVoid commented Jul 1, 2026

Copy link
Copy Markdown
Owner

動機

Bazel 9 移除了原生 sh_binary / cc_* 規則以及 CcInfo 全域符號,Bazel 10(rolling)進一步不再讓 source file 繼承 package default_visibility。本 PR 補上必要的 load()、rules_shell module 依賴與 exports_files(),讓整個 build tree 在 Bazel 7 / 8 / 9 / 10 rolling 上皆可建置與測試,且不改變任何版本的行為。

變更內容

原生規則 load

  • scripts/BUILD.bazel 從 @rules_shell load sh_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.bzl load cc_binary / cc_library / cc_test。
  • vendored 的 deps/rapidjson-1.1.0、deps/darts-clone-0.32h BUILD 檔 load cc_library;並在 darts-clone 的 MODULE.bazel 加入 rules_cc 依賴,使 @rules_cc 能在其 repo mapping 內解析。

CcInfo 全域移除

  • node/cc_headers_files.bzl 從 @rules_cc//cc/common:cc_info.bzl load CcInfo。

Source file 可見性

  • 為跨 package 引用的 source file 加上 exports_files():src 的公開標頭、data/config 的 config JSON、data/dictionary 的 CJK_Compatibility_Ideographs.txt。

測試結果

使用 CI 的測試指令逐版驗證:

bazel test --skip_incompatible_explicit_targets \
  //src/... //data/... //test/... //python/... //plugins/... //node/test:node_test
Bazel 版本 結果
7.6.2 ✅ 104 tests pass
8.5.1 ✅ 104 tests pass
9.0.0 ✅ 104 tests pass
10.0.0-pre (rolling) ✅ 104 tests pass

註:未修改前,Bazel 9 於 src/tools(原生 cc_*)載入失敗;Bazel 10 rolling 另因 CcInfo 全域移除與 source-file 可見性收緊而分析失敗。以上皆已修正。

🤖 Generated with Claude Code

…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.
@frankslin
frankslin merged commit c0aa415 into master Jul 1, 2026
41 of 42 checks passed
@frankslin
frankslin deleted the claude/nervous-wozniak-2a2727 branch July 1, 2026 19:04
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