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

[tooling] Migrate bazel to bzlmod and update all rules #175

Merged
merged 12 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
common --experimental_allow_tags_propagation
common --enable_bzlmod
common --incompatible_disable_native_android_rules

mobile-install --config=android

build --enable_platform_specific_config
# https://github.com/bazelbuild/bazel/issues/18958
build --noenable_bzlmod
build:macos --apple_crosstool_top=@local_config_apple_cc//:toolchain
build:macos --crosstool_top=@local_config_apple_cc//:toolchain
build:macos --host_crosstool_top=@local_config_apple_cc//:toolchain
Expand All @@ -30,15 +29,12 @@ build --features=swift.use_global_module_cache

# Gate the references to androidndk behind a flag to support building on arm linux.
build:android --android_crosstool_top=@androidndk//:toolchain
build:android --extra_toolchains=@androidndk//...
build --platform_mappings=bazel/platform_mappings

build --@rules_rust//rust/settings:rustfmt.toml=//:rustfmt.toml
build --@rules_rust//rust/settings:clippy.toml=//:.clippy.toml

build --macos_minimum_os=12.5
build --host_macos_minimum_os=12.5

build --ios_minimum_os=12.0
build --ios_simulator_device="iPhone 13"
build --ios_simulator_version=17.5
Expand Down Expand Up @@ -83,11 +79,14 @@ build:release-common --config=abort-panic
# Size optimizations, codegen-units=1 go along side LTO, which accounts for
# about 10% reduction; -z has a non-zero smaller impact (a few pp).
build:release-common --@rules_rust//rust/settings:extra_rustc_flag='-Ccodegen-units=1'
build:release-common --@rules_rust//rust/settings:extra_rustc_flag='-Clto=fat'
build:release-common --@rules_rust//rust/settings:extra_rustc_flag='-Copt-level=s'
build:release-common --@rules_rust//rust/settings:extra_rustc_flag='-Clto=fat'
# Without the next line, rules_rust will add -Clinker-plugin-lto which would be amazing
# but the ndk's lld won't support the output
build:release-common --@rules_rust//rust/settings:lto='manual'

build:release-android --define android_strip_symbols=true
build:release-android --fat_apk_cpu=x86,x86_64,armeabi-v7a,arm64-v8a
build:release-android --android_platforms=@rules_android//:armeabi-v7a,@rules_android//:arm64-v8a,@rules_android//:x86,@rules_android//:x86_64
build:release-android --config=release-common
build:release-android --copt=-flto=thin --linkopt=-flto=thin
build:release-android --config=android
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.0-pre.20231018.3
7.4.1
4 changes: 2 additions & 2 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
# Check if any status indicates a relevant change or error
if [[ "$bazel_status" == "1" || "$workflow_status" == "1" || "$gradle_status" == "1" ]]; then
echo "An unexpected issue occurred during checks."
exit 1
exit 1
elif [[ "$bazel_status" == "0" || "$workflow_status" == "0" || "$gradle_status" == "0" ]]; then
echo "Changes detected in one or more checks. Running tests."
echo "run_tests=true" >> $GITHUB_ENV
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:

- name: build apk
timeout-minutes: 30
run: ./bazelw build --config ci --config release-android --fat_apk_cpu=x86_64 //examples/android:android_app
run: ./bazelw build --config ci --config release-android --android_platforms=@rules_android//:x86_64 //examples/android:android_app
- uses: actions/upload-artifact@v4
with:
name: android_app.apk
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,3 @@ rust-project.json
/perf.data
/perf.data.old
vendor

# TODO(mattklein123): Theoretically we should be using these files now, but they cause errors and
# are spit out so need to sort this out.
MODULE.bazel
MODULE.bazel.lock
16 changes: 4 additions & 12 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
load("@build_bazel_rules_apple//apple:apple.bzl", "apple_static_framework_import")
load(
"@io_bazel_rules_kotlin//kotlin:core.bzl",
"define_kt_toolchain",
"kt_compiler_plugin",
"kt_kotlinc_options",
)
load(
"@io_bazel_rules_kotlin//kotlin:jvm.bzl",
"kt_javac_options",
)
load("@rules_apple//apple:apple.bzl", "apple_static_framework_import")
load("@rules_java//java:defs.bzl", "java_binary")
load("@rules_kotlin//kotlin:core.bzl", "define_kt_toolchain", "kt_compiler_plugin", "kt_kotlinc_options")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_javac_options")
load("@rules_pkg//:pkg.bzl", "pkg_zip")
load(
"@rules_xcodeproj//xcodeproj:defs.bzl",
Expand Down Expand Up @@ -160,7 +152,7 @@ kt_compiler_plugin(
target_embedded_compiler = True,
visibility = ["//visibility:public"],
deps = [
"@maven//:androidx_compose_compiler_compiler",
"@maven//:org_jetbrains_kotlin_kotlin_compose_compiler_plugin_embeddable",
],
)

Expand Down
Loading
Loading