Use bazelisk instead of bazel.

* .bazeliskrc is used instead of USE_BAZEL_VERSION.
* Remove the .bazelversion file.

#codehealth

PiperOrigin-RevId: 716213424
This commit is contained in:
Hiroyuki Komatsu
2025-01-16 14:35:53 +00:00
parent 016c7385c6
commit 8d704f0f82
11 changed files with 32 additions and 54 deletions

View File

@ -29,10 +29,8 @@ jobs:
- name: build
working-directory: ./src
env:
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_android package --config release_build
bazelisk build --config oss_android package --config release_build
- name: upload artifacts
uses: actions/upload-artifact@v4

View File

@ -33,10 +33,8 @@ jobs:
- name: bazel build
working-directory: ./src
env:
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_linux package --config release_build
bazelisk build --config oss_linux package --config release_build
- name: Upload Artifacts
uses: actions/upload-artifact@v4
@ -66,7 +64,5 @@ jobs:
- name: bazel test
working-directory: ./src
env:
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel test ... --config oss_linux --build_tests_only -c dbg
bazelisk test ... --config oss_linux --build_tests_only -c dbg

View File

@ -54,10 +54,8 @@ jobs:
- name: bazel build
working-directory: ./src
env:
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_macos package --macos_cpus=arm64 --config release_build
bazelisk build --config oss_macos package --macos_cpus=arm64 --config release_build
- name: upload artifacts
uses: actions/upload-artifact@v4
@ -105,10 +103,8 @@ jobs:
- name: bazel build
working-directory: ./src
env:
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_macos package --macos_cpus=x86_64 --config release_build
bazelisk build --config oss_macos package --macos_cpus=x86_64 --config release_build
- name: upload artifacts
uses: actions/upload-artifact@v4
@ -156,10 +152,8 @@ jobs:
- name: bazel build
working-directory: ./src
env:
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_macos package --macos_cpus=x86_64,arm64 --config release_build
bazelisk build --config oss_macos package --macos_cpus=x86_64,arm64 --config release_build
- name: upload artifacts
uses: actions/upload-artifact@v4
@ -207,10 +201,8 @@ jobs:
- name: bazel test
working-directory: ./src
env:
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel test ... --config oss_macos --build_tests_only -c dbg
bazelisk test ... --config oss_macos --build_tests_only -c dbg
# actions/cache works without this job, but having this would increase the likelihood of cache hit
# in other jobs. Another approach would be to use "needs:".

View File

@ -122,9 +122,8 @@ jobs:
working-directory: .\src
env:
ANDROID_NDK_HOME: ""
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel --bazelrc=windows.bazelrc build --config oss_windows --config release_build package
bazelisk --bazelrc=windows.bazelrc build --config oss_windows --config release_build package
- name: upload Mozc64_bazel.msi
uses: actions/upload-artifact@v4

View File

@ -62,9 +62,8 @@ ENV PKG_CONFIG_PATH="/home/mozc_builder/work/mozc/docker/ubuntu22.04/qt6-core-pk
## Set up bazelisk as bazel
RUN curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /home/mozc_builder/bin/bazel \
&& chmod u+x /home/mozc_builder/bin/bazel
ENV USE_BAZEL_VERSION 8.0.0
&& mv bazelisk-linux-amd64 /home/mozc_builder/bin/bazelisk \
&& chmod u+x /home/mozc_builder/bin/bazelisk
## Set up Android SDK and NDK
ENV ANDROID_HOME /home/mozc_builder/Android/Sdk

View File

@ -56,9 +56,8 @@ WORKDIR /home/mozc_builder/work
## Set up bazelisk as bazel
RUN curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /home/mozc_builder/bin/bazel \
&& chmod u+x /home/mozc_builder/bin/bazel
ENV USE_BAZEL_VERSION 8.0.0
&& mv bazelisk-linux-amd64 /home/mozc_builder/bin/bazelisk \
&& chmod u+x /home/mozc_builder/bin/bazelisk
## Set up Android SDK and NDK
ENV ANDROID_HOME /home/mozc_builder/Android/Sdk

View File

@ -14,7 +14,7 @@ docker build --rm --tag mozc_ubuntu24.04 .
docker create --interactive --tty --name mozc_build mozc_ubuntu24.04
docker start mozc_build
docker exec mozc_build bazel build package --config oss_linux --config release_build
docker exec mozc_build bazelisk build package --config oss_linux --config release_build
docker cp mozc_build:/home/mozc_builder/work/mozc/src/bazel-bin/unix/mozc.zip .
```
@ -48,7 +48,7 @@ Notes
```
docker start mozc_build
docker exec mozc_build bazel build package --config oss_linux --config release_build
docker exec mozc_build bazelisk build package --config oss_linux --config release_build
docker cp mozc_build:/home/mozc_builder/work/mozc/src/bazel-bin/unix/mozc.zip .
```
@ -63,7 +63,7 @@ Notes
## Build Mozc for Linux Desktop
```
bazel build package --config oss_linux --config release_build
bazelisk build package --config oss_linux --config release_build
```
Note: You might want to execute `docker start --interactive mozc_build`
@ -92,7 +92,7 @@ Install paths are configurable by modifying
#### Run all tests
```
bazel test ... --config oss_linux --build_tests_only -c dbg
bazelisk test ... --config oss_linux --build_tests_only -c dbg
```
* `...` means all targets under the current and subdirectories.
@ -101,7 +101,7 @@ bazel test ... --config oss_linux --build_tests_only -c dbg
### Run tests under the specific directories
```
bazel test base/... composer/... --config oss_linux --build_tests_only -c dbg
bazelisk test base/... composer/... --config oss_linux --build_tests_only -c dbg
```
* `<dir>/...` means all targets under the `<dir>/` directory.
@ -110,7 +110,7 @@ bazel test base/... composer/... --config oss_linux --build_tests_only -c dbg
### Run tests without the specific directories
```
bazel test ... --config oss_linux --build_tests_only -c dbg -- -base/...
bazelisk test ... --config oss_linux --build_tests_only -c dbg -- -base/...
```
* `--` means the end of the flags which start from `-`.
@ -120,7 +120,7 @@ bazel test ... --config oss_linux --build_tests_only -c dbg -- -base/...
### Run the specific test
```
bazel test base:util_test --config oss_linux -c dbg
bazelisk test base:util_test --config oss_linux -c dbg
```
* `util_test` is defined in `base/BUILD.bazel`.
@ -128,7 +128,7 @@ bazel test base:util_test --config oss_linux -c dbg
### Output logs to stderr
```
bazel test base:util_test --config oss_linux --test_arg=--stderrthreshold=0 --test_output=all
bazelisk test base:util_test --config oss_linux --test_arg=--stderrthreshold=0 --test_output=all
```
* The `--test_arg=--stderrthreshold=0 --test_output=all` flags shows the
@ -177,13 +177,13 @@ You may have some build errors when you update build environment or configuratio
In that case, try the following command to [refetch external repositories](https://bazel.build/extending/repo#forcing_refetch_of_external_repositories).
```
bazel sync --configure
bazelisk sync --configure
```
If the issue persists, also try the following command to [clean Bazel's build cache](https://bazel.build/docs/user-manual#clean)
```
bazel clean --expunge
bazelisk clean --expunge
```
## Build Mozc library for Android:
@ -195,7 +195,7 @@ Client code for Android apk is deprecated.
The conversion engine for Android is built with Bazel.
```
bazel build package --config oss_android
bazelisk build package --config oss_android
```
`package` is an alias to build `android/jni:native_libs`.

View File

@ -134,7 +134,7 @@ brew install cmake
### Build installer
```
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos --config release_build
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk build package --config oss_macos --config release_build
open bazel-bin/mac/Mozc.pkg
```
@ -143,21 +143,21 @@ open bazel-bin/mac/Mozc.pkg
To build an Intel64 macOS binary regardless of the host CPU architecture.
```
python3 build_tools/build_qt.py --release --debug --confirm_license --macos_cpus=x64_64
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos --config release_build --macos_cpus=x64_64
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk build package --config oss_macos --config release_build --macos_cpus=x64_64
open bazel-bin/mac/Mozc.pkg
```
To build a Universal macOS Binary both x86_64 and arm64.
```
python3 build_tools/build_qt.py --release --debug --confirm_license --macos_cpus=x86_64,arm64
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos --config release_build --macos_cpus=x86_64,arm64
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk build package --config oss_macos --config release_build --macos_cpus=x86_64,arm64
open bazel-bin/mac/Mozc.pkg
```
### Unit tests
```
MOZC_QT_PATH=${PWD}/third_party/qt bazel test ... --config oss_macos --build_tests_only -c dbg
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk test ... --config oss_macos --build_tests_only -c dbg
```
See [build Mozc in Docker](build_mozc_in_docker.md#unittests) for details.
@ -197,7 +197,7 @@ Files in the GitHub Actions page remain available up to 90 days.
You can also find Mozc Installers for macOS in google/mozc repository. Please keep in mind that Mozc is not an officially supported Google product, even if downloaded from https://github.com/google/mozc/.
1. Sign in GitHub.
2. Check [recent successfull macOS runs](https://github.com/google/mozc/actions/workflows/macos.yaml?query=is%3Asuccess) in google/mozc repository.
2. Check [recent successful macOS runs](https://github.com/google/mozc/actions/workflows/macos.yaml?query=is%3Asuccess) in google/mozc repository.
3. Find action in last 90 days and click it.
4. Download `Mozc.pkg` from the action result page.

View File

@ -166,14 +166,14 @@ Note that you can specify `--qtdir=` option instead of `--noqt` in GYP phase sin
Additional requirements:
* [Bazel](https://bazel.build/)
* check [src/.bazelversion](../src/.bazelversion) for the supported Bazel version.
* [Bazelisk](https://github.com/bazelbuild/bazelisk)
* Bazelisk is a wrapper of [Bazel](https://bazel.build/) to use the specific version of Bazel.
* [MSYS2](https://github.com/msys2/msys2)
After running `build_tools/update_deps.py` and `build_tools/build_qt.py`, run the following command instead of `build_mozc.py`:
```
bazel --bazelrc=windows.bazelrc build --config oss_windows --config release_build package
bazelisk --bazelrc=windows.bazelrc build --config oss_windows --config release_build package
```
You have release build binaries in `bazel-bin\win32\installer\Mozc64.msi`.

View File

@ -81,7 +81,7 @@ protoc --encode=mozc.config.Config protocol/config.proto < config.textproto > co
`protoc` can be built as follows
```
bazel build @com_google_protobuf//:protoc
bazelisk build @com_google_protobuf//:protoc
```
## IBus

View File

@ -1,5 +0,0 @@
8.0.0
# The first line is intentionally empty to allow any Bazel versions.
# We have checked the build and tests with Bazel 8.0.0.
# Remove the first empty line and use Bazelisk to use the confirmed version.