bazelbuild/rules_android

android_sdk_repository isn't compatible with Bzlmod

Bencodes opened this issue · 10 comments

The current Starlark implementation relies on native functions like bind and register_toolchains which are not supported in the Bzlmod MODULE.bazel file.

keith commented

this is mostly fixed by #147, for the bind uses we'll have to change bazel I believe

For avoiding bind usages, you can check https://bazel.build/external/migration#bind-targets, my guess is no Bazel change is required.

Oh, unless some Bazel native code is referring to //external:*.. /cc @ahumesky @ted-xie

katre commented

Native Android rules depend on //external for a variety of things (mostly implicit dependencies on tools and the SDKs).

We should be able to remove these in the Starlark rules for the most part.

And https://cs.opensource.google/bazel/bazel/+/master:src/tools/android/java/com/google/devtools/build/android/r8/BUILD;l=55

I believe even before starlarkfying the android build rules, we can just replace those labels to directly pointing to @bazel_tools

katre commented

The actual labels are in @androidsdk, unless the user names the repo something different, and not all projects even create the repo (which is why //external:has_androidsdk exists).

FWIW I am close to fixing this (finally!). There are two changes pending review internally, after which a follow-up CL will clean up all the binds. There will also be a small bazelrc change necessary to point the SDK away from bazel's implicit definition: --android_sdk=@androidsdk//:sdk.

Very exciting to hear that, thanks for your hard work!

Do I understand correctly that if we want to remove all the binds from Bazel's WORKSPACE.bzlmod file, we'll have to build Bazel with Bazel@HEAD?

For Bazel itself, we'll delete the android_sdk_repository rule entirely closer to the Bazel 8 release, and when that happens, we can delete the binds too.