Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fcitx
Browse files Browse the repository at this point in the history
  • Loading branch information
Fcitx Bot committed Aug 24, 2024
2 parents 17c8da1 + b0b37db commit a9175c2
Show file tree
Hide file tree
Showing 39 changed files with 760 additions and 153 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# Python compiled objects
*.pyc

# Bazel autogenerated files
MODULE.bazel.lock

# Hidden files
.DS_Store

Expand Down
2 changes: 2 additions & 0 deletions docs/build_mozc_in_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ bazel build package --config oss_android

`package` is an alias to build `android/jni:native_libs`.

We have tested Android NDK r27. The former versions may not work.

-----

## Build Mozc for Linux Desktop with GYP (deprecated):
Expand Down
1 change: 1 addition & 0 deletions src/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
third_party/
53 changes: 41 additions & 12 deletions src/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# enable_bzlmod causes the build failure. Suppress it util the fix.
common --noenable_bzlmod

## Target platforms
common:linux --config=linux_env --define TARGET=oss_linux
common:oss_linux --config=linux_env --define TARGET=oss_linux
Expand All @@ -16,9 +13,20 @@ common:oss_windows --config=windows_env --define TARGET=oss_windows
common:prod_windows --config=windows_env --define TARGET=prod_windows
common:prod_windows_dev --config=prod_windows --config=dev_channel

common:android --config=android_env --define TARGET=oss_android
common:oss_android --config=android_env --define TARGET=oss_android
common:prod_android --config=android_env --define TARGET=prod_android
common:android --config=android_env --config=android_env_workspace --define TARGET=oss_android
common:oss_android --config=android_env --config=android_env_workspace --define TARGET=oss_android
common:prod_android --config=android_env --config=android_env_workspace --define TARGET=prod_android
common:oss_android_bzlmod --config=android_env --config=android_env_bzlmod --define TARGET=oss_android

## Bzlmod options: Bzlmod is the default except for Android.
common:linux_env --config=bzlmod
common:macos_env --config=bzlmod
common:windows_env --config=bzlmod
common:android_env_bzlmod --config=bzlmod
common:android_env_workspace --config=workspace

common:bzlmod --enable_bzlmod
common:workspace --noenable_bzlmod

## Dev channel
build:dev_channel --define CHANNEL=dev
Expand Down Expand Up @@ -60,12 +68,33 @@ test:windows_env --test_tag_filters=-nowin
# TODO: Re-enable "incompatible_enable_cc_toolchain_resolution"
build:windows_env --noincompatible_enable_cc_toolchain_resolution

## Android specific options
# Android specific options
build:android_env --copt "-DOS_ANDROID"
build:android_env --android_crosstool_top=@androidndk//:toolchain
# --fat_apk_cpu should be replaced with --android_platforms
# https://github.com/bazelbuild/bazel/commit/05bea52ed3159aa5d15d967f5f56fc084a2b6c73
build:android_env --fat_apk_cpu=armeabi-v7a,arm64-v8a,x86,x86_64 --incompatible_enable_android_toolchain_resolution=false
build:android_env --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:android_env --build_tag_filters=-noandroid
test:android_env --test_tag_filters=-noandroid

## Android workspace specific options
build:android_env_workspace --android_crosstool_top=@androidndk//:toolchain
# --fat_apk_cpu should be replaced with --android_platforms
# https://github.com/bazelbuild/bazel/commit/05bea52ed3159aa5d15d967f5f56fc084a2b6c73
build:android_env_workspace --fat_apk_cpu=armeabi-v7a,arm64-v8a,x86,x86_64 --incompatible_enable_android_toolchain_resolution=false
build:android_env_workspace --host_crosstool_top=@bazel_tools//tools/cpp:toolchain

## Android Blzmod specific options
### --experimental_google_legacy_api is required for all platforms.
build:bzlmod --experimental_google_legacy_api

build:android_env_bzlmod --experimental_enable_android_migration_apis
build:android_env_bzlmod --android_sdk=@androidsdk//:sdk
### arm64-v8a build (Arm 64bit)
build:android_env_bzlmod --android_platforms=//bazel/android:arm64-v8a --cpu=arm64
### x86_64 build (x86 64bit)
# build:android_env_bzlmod --android_platforms=//bazel/android:x86_64 --cpu=x86_64
### armeabi-v7a build (Arm 32bit)
# build:android_env_bzlmod --android_platforms=//bazel/android:armeabi-v7a --cpu=armv7
### x86 build (x86 32bit)
# build:android_env_bzlmod --android_platforms=//bazel/android:x86 --cpu=x86_32

# Note, although --android_platforms supports multiple platforms,
# Abseil doesn't support it yet, and requires the --cpu option.
# As the result, it is not possible to build both cpus with a single command.
5 changes: 5 additions & 0 deletions src/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

7.3.0
# The first liine is intentionally empty to allow any Bazel versions.
# We have checked the build and tests with Bazel 7.3.0.
# Remove the first line and use Bazelisk to use the confirmed version.
65 changes: 59 additions & 6 deletions src/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ local_path_override(
)


# platforms: 0.0.10 2024-04-26
# https://github.com/bazelbuild/platforms/
bazel_dep(
name = "platforms",
version = "0.0.10",
)

# bazel_skylib: 1.7.1 2024-06-03
# https://github.com/bazelbuild/bazel-skylib/
bazel_dep(
Expand Down Expand Up @@ -61,13 +68,52 @@ bazel_dep(
repo_name = "build_bazel_apple_support",
)

# Note, rules_android does not work yet with the following configurations.

# Java rules (7.9.0 2024-08-13)
# bazel_dep(name = "rules_java", version = "7.9.0")
# https://github.com/bazelbuild/rules_java
bazel_dep(
name = "rules_java",
version = "7.9.0",
)

# Android NDK rules (0.1.2 2024-07-23)
# https://github.com/bazelbuild/rules_android_ndk
bazel_dep(
name = "rules_android_ndk",
version = "0.1.2",
)
single_version_override(
module_name = "rules_android_ndk",
version = "0.1.2",
patches = ["bazel/rules_android_ndk.patch"],
)
android_ndk_repository_extension = use_extension(
"@rules_android_ndk//:extension.bzl",
"android_ndk_repository_extension",
)
use_repo(android_ndk_repository_extension, "androidndk")
register_toolchains("@androidndk//:all")

# Android SDK rules (0.5.1 2024-08-06)
# bazel_dep(name = "rules_android", version = "0.5.1")
# https://github.com/bazelbuild/rules_android
bazel_dep(
name = "rules_android",
version = "0.5.1",
)
remote_android_extensions = use_extension(
"@rules_android//bzlmod_extensions:android_extensions.bzl",
"remote_android_tools_extensions",
)
use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
register_toolchains(
"@rules_android//toolchains/android:android_default_toolchain",
"@rules_android//toolchains/android_sdk:android_sdk_tools",
)
android_sdk_repository_extension = use_extension(
"@rules_android//rules/android_sdk_repository:rule.bzl",
"android_sdk_repository_extension",
)
use_repo(android_sdk_repository_extension, "androidsdk")
register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")


new_local_repository = use_repo_rule(
Expand Down Expand Up @@ -191,19 +237,26 @@ http_archive(
],
strip_prefix = "google-toolbox-for-mac-%s/UnitTesting" % GTM_GIT_SHA,
build_file = "@//bazel:BUILD.google_toolbox_for_mac.bazel",
patches = ["@//:google_toolbox_for_mac.patch"],
patches = ["@//bazel:google_toolbox_for_mac.patch"],
patch_args = ["-p2"],
sha256 = "424bca6571778496efa5328ffcca26edf083e282da7074d30b3e980516cea2a4",
)

# Zip code
# Since the URL is shared among multiple versions, we cannot specify the SHA256.
# For offline build (with the --repository_cache flag), SHA256 should be specified.
#
# SHA256 as of 2024-08-14
# SHA256_ZIP_CODE_KEN_ALL = "d2d177ef64b9459a618d8aaa96b6c5f081cb3f37f6e9c00ba912001e66b81f3e"
SHA256_ZIP_CODE_KEN_ALL = None
http_archive(
name = "zip_code_ken_all",
build_file_content = "exports_files([\"KEN_ALL.CSV\"])",
sha256 = SHA256_ZIP_CODE_KEN_ALL,
url = "https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip",
)

# SHA256 as of 2024-08-14
# SHA256_ZIP_CODE_JIGYOSYO="ab6fd92df35e63c4566d29f70456da1603d8178ce3fec073f7c27b28d0af2e10"
SHA256_ZIP_CODE_JIGYOSYO = None
http_archive(
name = "zip_code_jigyosyo",
Expand Down
24 changes: 21 additions & 3 deletions src/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ http_archive(
strip_prefix = "rules_android_ndk-0.1.2",
url = "https://github.com/bazelbuild/rules_android_ndk/releases/download/v0.1.2/rules_android_ndk-v0.1.2.tar.gz",
)

# Check the ANDROID_NDK_HOME envvar, if it is specified set up NDK as follows
# load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")
# android_ndk_repository(name="androidndk")
Expand All @@ -142,20 +141,39 @@ load("@android_repository//:setup.bzl", "android_ndk_setup")
android_ndk_setup()


# Placeholder of rules_android for the compatibility with Bzlmod.
new_local_repository(
name = "rules_android",
path = "bazel",
build_file_content = "",
)


# Android SDK rules (0.1.1 2018-06-15)
http_archive(
name = "build_bazel_rules_android",
sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
strip_prefix = "rules_android-0.1.1",
urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
)

load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository")

android_sdk_repository(
name = "androidsdk",
)


# platforms (0.0.10 2024-04-26)
# https://github.com/bazelbuild/platforms/
http_archive(
name = "platforms",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
],
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
)


# Windows Implementation Library (WIL)
# https://github.com/microsoft/wil/
new_local_repository(
Expand Down
43 changes: 4 additions & 39 deletions src/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
# WORKSPACE.bzlmod is used with Bzlmod (i.e. MODULE.bazel).
# To use Bzlmod, you need to specify --enable_bzlmod to the Bazel command or modify .bazelrc.
# To use Bzlmod, you need to specify --enable_bzlmod to the Bazel command or
# modify .bazelrc.

# An identifier for this repository.
workspace(name = "mozc")

load(
"@bazel_tools//tools/build_defs/repo:http.bzl",
"http_archive",
)

# Android NDK setup (0.1.2 2024-07-23)
http_archive(
name = "rules_android_ndk",
sha256 = "65aedff0cd728bee394f6fb8e65ba39c4c5efb11b29b766356922d4a74c623f5",
strip_prefix = "rules_android_ndk-0.1.2",
url = "https://github.com/bazelbuild/rules_android_ndk/releases/download/v0.1.2/rules_android_ndk-v0.1.2.tar.gz",
)

# Check the ANDROID_NDK_HOME envvar, if it is specified set up NDK as follows
# load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")
# android_ndk_repository(name="androidndk")
# If it is empty, do nothing.
load("@//bazel:android_repository.bzl", "android_repository")
android_repository(name = "android_repository")
load("@android_repository//:setup.bzl", "android_ndk_setup")
android_ndk_setup()


http_archive(
name = "build_bazel_rules_android",
sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
strip_prefix = "rules_android-0.1.1",
urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
)

load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository")

android_sdk_repository(
name = "androidsdk",
)
# This empty file prevents fetching any dependencies from the old WORKSPACE
# system when Bzlmod is enabled.
1 change: 1 addition & 0 deletions src/android/jni/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# Usage:
# % blaze --blazerc android/blazerc build --config=android_arm android/jni:libmozc.so

load("@rules_android//android:rules.bzl", "android_binary")
load(
"//:build_defs.bzl",
"MOZC_TAGS",
Expand Down
4 changes: 2 additions & 2 deletions src/base/absl.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@
'<!@(<(glob_absl) status/internal "*.cc")',
],
'include_dirs': [
'<(third_party_dir)/gtest/googlemock/include',
'<(third_party_dir)/gtest/googletest/include',
'<(gmock_dir)/include',
'<(gtest_dir)/include',
],
'dependencies': [
'absl_base',
Expand Down
Loading

0 comments on commit a9175c2

Please sign in to comment.