diff --git a/.bazelci/android.yml b/.bazelci/android.yml index ef223eb5b..0d0ac08ca 100644 --- a/.bazelci/android.yml +++ b/.bazelci/android.yml @@ -2,15 +2,13 @@ common: android-firebase: &android-firebase name: "Android Firebase Cloud Messaging" - bazel: last_green + bazel: 7.2.0rc1 working_directory: ../android/firebase-cloud-messaging - build_flags: - - "--android_platforms=//:arm64-v8a" build_targets: - "//app:app" android-ndk: &android-ndk name: "Android NDK" - bazel: 6.3.2 + bazel: 7.2.0rc1 working_directory: ../android/ndk build_flags: - "--android_platforms=//:arm64-v8a,//:x86" @@ -48,9 +46,11 @@ tasks: android-firebase-macos: platform: macos <<: *android-firebase - android-firebase-windows: - platform: windows - <<: *android-firebase + # rules_android doesn't support windows yet. + # https://github.com/bazelbuild/rules_android/issues/72 + # android-firebase-windows: + # platform: windows + # <<: *android-firebase android-ndk-linux: platform: ubuntu1804 environment: diff --git a/android/firebase-cloud-messaging/.bazelrc b/android/firebase-cloud-messaging/.bazelrc new file mode 100644 index 000000000..be4e550d9 --- /dev/null +++ b/android/firebase-cloud-messaging/.bazelrc @@ -0,0 +1,4 @@ +common --experimental_google_legacy_api +common --experimental_enable_android_migration_apis +# Necesary until bazel 7.2.0rc2 or later is released (https://github.com/bazelbuild/bazel/issues/22415) +common --nocheck_visibility diff --git a/android/firebase-cloud-messaging/.bazelversion b/android/firebase-cloud-messaging/.bazelversion new file mode 100644 index 000000000..58cbedfa9 --- /dev/null +++ b/android/firebase-cloud-messaging/.bazelversion @@ -0,0 +1 @@ +7.2.0rc1 diff --git a/android/firebase-cloud-messaging/WORKSPACE b/android/firebase-cloud-messaging/WORKSPACE index 287d4dc78..2ec8c866a 100644 --- a/android/firebase-cloud-messaging/WORKSPACE +++ b/android/firebase-cloud-messaging/WORKSPACE @@ -1,11 +1,6 @@ # FIXME(alexeagle): move to bzlmod load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# Requires ANDROID_HOME set to the path of your Android SDK. -android_sdk_repository(name = "androidsdk") - -android_ndk_repository(name = "androidndk") - RULES_JVM_EXTERNAL_TAG = "5.3" RULES_JVM_EXTERNAL_SHA = "d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac" @@ -27,7 +22,6 @@ maven_install( "com.android.support.constraint:constraint-layout:1.0.2", "com.google.code.gson:gson:2.8.2", ], - fetch_sources = True, # See https://github.com/bazelbuild/rules_jvm_external/#repository-aliases # This can be removed if none of your external dependencies uses `maven_jar`. generate_compat_repositories = True, @@ -37,6 +31,8 @@ maven_install( "https://repo1.maven.org/maven2", ], version_conflict_policy = "pinned", + use_starlark_android_rules = True, + aar_import_bzl_label = "@rules_android//rules:rules.bzl", ) load("@maven//:compat.bzl", "compat_repositories") @@ -55,16 +51,27 @@ http_archive( url = "https://github.com/bazelbuild/tools_android/archive/%s.tar.gz" % TOOLS_ANDROID_COMMIT, ) +RULES_ANDROID_COMMIT = "93e27030d3f0defa39cbbc35195638cb772b0c27" + http_archive( name = "rules_android", - sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", - strip_prefix = "rules_android-0.1.1", - urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"], + sha256 = "71cae2413868a24f17d43fd595af6f3905d2e5b3235f76514f54800bfd90c903", + strip_prefix = "rules_android-" + RULES_ANDROID_COMMIT, + urls = ["https://github.com/bazelbuild/rules_android/archive/%s.zip" % RULES_ANDROID_COMMIT], ) -http_archive( - name = "rules_cc", - sha256 = "5f862a44bbd032e1b48ed53c9c211ba2a1da60e10c5baa01c97369c249299ecb", - strip_prefix = "rules_cc-c8c38f8c710cbbf834283e4777916b68261b359c", - url = "https://github.com/bazelbuild/rules_cc/archive/c8c38f8c710cbbf834283e4777916b68261b359c.zip", +load("@rules_android//:prereqs.bzl", "rules_android_prereqs") +rules_android_prereqs() +load("@rules_android//:defs.bzl", "rules_android_workspace") +rules_android_workspace() + +load("@rules_android//rules:rules.bzl", "android_sdk_repository") +# Requires that the ANDROID_HOME environment variable is set to the Android SDK path. +android_sdk_repository( + name = "androidsdk", +) + +register_toolchains( + "@rules_android//toolchains/android:android_default_toolchain", + "@rules_android//toolchains/android_sdk:android_sdk_tools", ) diff --git a/android/ndk/.bazelrc b/android/ndk/.bazelrc new file mode 100644 index 000000000..be4e550d9 --- /dev/null +++ b/android/ndk/.bazelrc @@ -0,0 +1,4 @@ +common --experimental_google_legacy_api +common --experimental_enable_android_migration_apis +# Necesary until bazel 7.2.0rc2 or later is released (https://github.com/bazelbuild/bazel/issues/22415) +common --nocheck_visibility diff --git a/android/ndk/.bazelversion b/android/ndk/.bazelversion index 73d3e3a55..f085a8db2 100644 --- a/android/ndk/.bazelversion +++ b/android/ndk/.bazelversion @@ -1,2 +1,2 @@ -6.4.0 +7.2.0rc1 diff --git a/android/ndk/MODULE.bazel b/android/ndk/MODULE.bazel index 35ea9c78a..d48de4ff7 100644 --- a/android/ndk/MODULE.bazel +++ b/android/ndk/MODULE.bazel @@ -1,8 +1,15 @@ "Bazel dependencies" bazel_dep(name = "platforms", version = "0.0.10") -bazel_dep(name = "rules_android", version = "0.1.1") bazel_dep(name = "rules_jvm_external", version = "5.3") +bazel_dep(name = "rules_cc", version = "0.0.9") + +bazel_dep(name = "rules_android", version = "0.1.1") +git_override( + module_name = "rules_android", + remote = "https://github.com/bazelbuild/rules_android", + commit = "93e27030d3f0defa39cbbc35195638cb772b0c27", +) maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") maven.install( @@ -23,5 +30,7 @@ maven.install( "https://maven.google.com", "https://repo1.maven.org/maven2", ], + use_starlark_android_rules = True, + aar_import_bzl_label = "@rules_android//rules:rules.bzl", ) use_repo(maven, "maven") diff --git a/android/ndk/WORKSPACE b/android/ndk/WORKSPACE index 407fa06e7..21d87bf54 100644 --- a/android/ndk/WORKSPACE +++ b/android/ndk/WORKSPACE @@ -1,15 +1,29 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +RULES_ANDROID_COMMIT = "93e27030d3f0defa39cbbc35195638cb772b0c27" + 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"], + name = "rules_android", + sha256 = "71cae2413868a24f17d43fd595af6f3905d2e5b3235f76514f54800bfd90c903", + strip_prefix = "rules_android-" + RULES_ANDROID_COMMIT, + urls = ["https://github.com/bazelbuild/rules_android/archive/%s.zip" % RULES_ANDROID_COMMIT], ) -load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository") +load("@rules_android//:prereqs.bzl", "rules_android_prereqs") +rules_android_prereqs() +load("@rules_android//:defs.bzl", "rules_android_workspace") +rules_android_workspace() -android_sdk_repository(name = "androidsdk") +load("@rules_android//rules:rules.bzl", "android_sdk_repository") +# Requires that the ANDROID_HOME environment variable is set to the Android SDK path. +android_sdk_repository( + name = "androidsdk", +) + +register_toolchains( + "@rules_android//toolchains/android:android_default_toolchain", + "@rules_android//toolchains/android_sdk:android_sdk_tools", +) http_archive( name = "rules_android_ndk", @@ -21,3 +35,5 @@ http_archive( load("@rules_android_ndk//:rules.bzl", "android_ndk_repository") android_ndk_repository(name = "androidndk") + +register_toolchains("@androidndk//:all")