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

Add rules_android dependency and fix platform flags on CI #45

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ basic_example: &basic_example
working_directory: examples/basic
build_flags:
- "--incompatible_disallow_empty_glob"
- "--noincompatible_enable_cc_toolchain_resolution"
- "--fat_apk_cpu=arm64-v8a,x86"
- "--android_crosstool_top=@androidndk//:toolchain"
- "--android_platforms=@build_bazel_rules_android//:arm64-v8a,@build_bazel_rules_android//:x86"
build_targets:
- "//java/com/app:app"

cpu_features: &cpu_features
working_directory: examples/cpu_features
build_flags:
- "--incompatible_disallow_empty_glob"
- "--noincompatible_enable_cc_toolchain_resolution"
- "--cpu=arm64-v8a"
- "--crosstool_top=@androidndk//:toolchain"
- "--platforms=@build_bazel_rules_android//:arm64-v8a"
build_targets:
- "//:all"

Expand Down
28 changes: 28 additions & 0 deletions examples/cpu_features/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,31 @@ local_repository(
load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")

android_ndk_repository(name = "androidndk")

# Import rules_android

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

RULES_ANDROID_COMMIT = "a54904b056250a213117cee9287c996cd042f388"

RULES_ANDROID_SHA = "bf08c364e6d0946d09b485aee388557bba3bdb5f15323f73c2723d07d3503ba6"

http_archive(
name = "build_bazel_rules_android",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that rules_android uses the NDK in a few places -- so this might create a circular dependency (at least conceptually -- rules_android is using the native android_ndk_repository for the moment). If this is just for the platform definitions, it might actually make more sense to move those to rules_android_ndk, because rules_android itself doesn't really need to know about those platforms.

sha256 = RULES_ANDROID_SHA,
strip_prefix = "rules_android-%s" % RULES_ANDROID_COMMIT,
url = "https://github.com/bazelbuild/rules_android/archive/%s.zip" % RULES_ANDROID_COMMIT,
)

load("@build_bazel_rules_android//:prereqs.bzl", "rules_android_prereqs")

rules_android_prereqs()

load("@build_bazel_rules_android//:defs.bzl", "rules_android_workspace")

rules_android_workspace()

register_toolchains(
"@build_bazel_rules_android//toolchains/android:android_default_toolchain",
"@build_bazel_rules_android//toolchains/android_sdk:android_sdk_tools",
)
2 changes: 1 addition & 1 deletion ndk_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"""Toolchain command-line configuration logic."""

load("@bazel_tools//tools/build_defs/cc:action_names.bzl", action = "ACTION_NAMES")
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"action_config",
Expand All @@ -26,7 +27,6 @@ load(
"with_feature_set",
flag_set_ = "flag_set",
)
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", action = "ACTION_NAMES")

def ndk_cc_toolchain_config(
api_level,
Expand Down