Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration of Bazel dependency system to Bzlmod. #1002

Closed
hiroyuki-komatsu opened this issue Aug 15, 2024 · 1 comment
Closed

Migration of Bazel dependency system to Bzlmod. #1002

hiroyuki-komatsu opened this issue Aug 15, 2024 · 1 comment

Comments

@hiroyuki-komatsu
Copy link
Collaborator

Bzlmod is the new dependency system of Bazel. We need to migrate the current system (i.e. WORKSPACE) to Bzlmod since the current system will be deprecated.

https://bazel.build/external/overview#bzlmod

Once we complete the migration, we will remove the current system with WORKSPACE soon. This should not change anything for users, unless you use Mozc as a third party library in your Bazel WORKSPACE rules.

Please let us know if you have concerns about our migration plan.

hiroyuki-komatsu added a commit that referenced this issue Aug 15, 2024
* This is still opt-in. Use --enable-bzlmod to enable it.
* Updated some packages to get the MODULE support.
* rules for Android are not migrated yet due to the build error.
  + We may need to update the rule configurations.
* #1002

PiperOrigin-RevId: 663206260
hiroyuki-komatsu added a commit that referenced this issue Aug 24, 2024
* #1002

PiperOrigin-RevId: 663257591
hiroyuki-komatsu added a commit that referenced this issue Aug 24, 2024
* #1002

PiperOrigin-RevId: 663526070
hiroyuki-komatsu added a commit that referenced this issue Aug 24, 2024
In bzlmod, repo_ctx.attr.name has a prefix like "_main~_repo_rules~ibus".
This CL fixes the issue by extracting the last part of the name.

#1002

PiperOrigin-RevId: 663573267
hiroyuki-komatsu added a commit that referenced this issue Aug 24, 2024
This CL is a preparation for Bzlmod migration.

In Bzlmod, we need to specify the platforms for --android_platforms option.
This CL adds the platforms and android_binary rule for Android build.

This CL also adds a placeholder of rules_android for the compatibility with Bzlmod. This placeholder is necessary because Bzlmod requires rules_android.

#1002

PiperOrigin-RevId: 664617381
hiroyuki-komatsu added a commit that referenced this issue Aug 24, 2024
* Added `oss_android_bzlmod` config to build Android lib with Blzmod.
  + e.g. `bazel build --config oss_android_bzlmod package`
* Tested with NDK r27. The former versions may not work.
* The current implementation always requires the ANDROID_NDK_HOME envvar even for non-Android builds.
  + This will be addressed in following CLs.
* #1002

Note, although --android_platforms supports multiple platforms,
Abseil doesn't support it yet, and requires the --cpu option.
As the result, it is not possibl to build both cpus with a single command.

When multiple platforms are specified, Abseil build fails with the following error.

```
ERROR: .../external/abseil-cpp~/absl/random/internal/BUILD.bazel:344:11: Compiling absl/random/internal/randen_hwaes.cc failed: (Exit 1): clang failed: error executing CppCompile command (from target @@abseil-cpp~//absl/random/internal:randen_hwaes_impl) external/rules_android_ndk~~android_ndk_repository_extension~androidndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -no-canonical-prefixes '--target=aarch64-linux-android31' -fdiagnostics-color ... (remaining 114 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
clang: error: unsupported option '-maes' for target 'aarch64-linux-android31'
clang: error: unsupported option '-msse4.1' for target 'aarch64-linux-android31'
```

It comes from `absl/copts/configure_copts.bzl`
* https://github.com/abseil/abseil-cpp/blob/20240722.0/absl/copts/configure_copts.bzl#L78

PiperOrigin-RevId: 664647967
hiroyuki-komatsu added a commit that referenced this issue Aug 24, 2024
…s empty.

* Without this change, ANDROID_NDK_HOME is always required even for non-Android build targets.
* #1002

PiperOrigin-RevId: 664648557
hiroyuki-komatsu added a commit that referenced this issue Aug 24, 2024
* #1002

PiperOrigin-RevId: 665041376
hiroyuki-komatsu pushed a commit that referenced this issue Sep 30, 2024
This is a follow up to our previous commits [1][2], which enabled bzlmod
by default except for Android. With this commit, Android build actually
starts only bzlmod mode.

Basically the idea is to use transition [3] to specify required CPU and
platforms for each libmozc.so target. A bonus is that we no longer need
to rely on rules_android.

 [1]: e54fbcb
 [2]: 699c2ce
 [3]: https://bazel.build/rules/lib/builtins/transition

PiperOrigin-RevId: 680441153
hiroyuki-komatsu pushed a commit that referenced this issue Sep 30, 2024
This follows up to my previous commit [1], which aimed to switch to
bzlmod for Android.

Due to a last minute mistake, android/jni/make_archive.py somehow
generated 'native_libs.zip.zip' rather than 'native_libs.zip', which
is then caught as an error in genrule. With this commit it starts
generating 'native_libs.zip' as expected.

 [1]: 6c61c4f

PiperOrigin-RevId: 680579645
hiroyuki-komatsu pushed a commit that referenced this issue Oct 1, 2024
As we are about to complete bzlmod migration (#1002), let's also update
the build instructions to make it clear that "MODULE.bazel" will be the
file to be customized depending on differences in Linux distributions
and packagers' needs.

PiperOrigin-RevId: 680748113
hiroyuki-komatsu pushed a commit that referenced this issue Oct 1, 2024
bazelisk [1] is a wrapper around bazel that allows you to use different
versions of bazel without having to install them all. This is useful
for testing different versions of bazel or for using a specific version
of bazel that is not available in the default repository.

Let's update Dockerfile to use bazelisk instead of bazel. This will
allow us to avoid a tricky question on which version of bazel should be
installed in the Docker container by checking in '.bazeliskrc' into the
repository.

Note that switching to recent versions of bazel is also necessary due to
our migration to bzlmod (#1002). Probably bazel 7.3 or later is
currently required to build Mozc with bazel.

 [1]: https://github.com/bazelbuild/bazelisk

#codehealth

PiperOrigin-RevId: 680750168
@hiroyuki-komatsu
Copy link
Collaborator Author

We have completed the migration from WORKSPACE to Bzlmod.
We will remove WORKSPACE.bazel in future.

Note,

  • Bazel 8 will disable WORKSPACE by default.
  • Bazel 9 will remove WORKSPACE.

https://bazel.build/about/roadmap

hiroyuki-komatsu added a commit that referenced this issue Oct 10, 2024
2.30.5595 → 2.30.5618

Conversion
* Updated zip code entries (#1063).
* Updated word entries (#1068, #1069)

Bug fix
* Linux: Enabled switching to the DIRECT mode from the menu (#1061)
* Linux: Enabled switching modes with Super+Space in Wayland (#853, #1059)
* macOS: Fixed the limitation of mouse clicking on the renderer on macOS 15 (120bd93)
* Windows: Fixed the setting of Omaha updater for the GoogleJapaneseInput build (#1072)

Build
* Android: Switched the Bazel rules from WORKSPACE to Bzlmod (#1002)
* Android: Updated the Docker build environment
* Linux: Update the build environment: Ubuntu 22.04 → 24.04 (#924)
* macOS / Windows: Updated the Qt version: 6.7.2 → 6.7.3 (#1065)
* Windows: Supported Bazel build (#948)
* Windows: Updated the Wix version: 4.0.5 → 5.0.2 (#1070)

Code
* Performed code refactoring

PiperOrigin-RevId: 684295272
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

No branches or pull requests

1 participant