Skip to content

Commit

Permalink
Migrate to Bazel 5.0.0 (#2034)
Browse files Browse the repository at this point in the history
* Update Envoy: 71248e5...bbcd487
* Remove various `remotejdk_11` configurations in .bazelrc which we now inherit from Envoy
* Work around https://github.com/bazelbuild/bazel/issues/14260 androidndk fetching issue

Signed-off-by: JP Simard <jp@jpsim.com>
Co-authored-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
  • Loading branch information
jpsim and keith committed Nov 29, 2022
1 parent 37bdafb commit 36183c9
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
4 changes: 0 additions & 4 deletions mobile/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ build --spawn_strategy=local
build --verbose_failures
build --workspace_status_command=envoy/bazel/get_workspace_status
build --xcode_version=13.2.1
build --host_javabase=@bazel_tools//tools/jdk:remote_jdk11
build --javabase=@bazel_tools//tools/jdk:remote_jdk11
build --tool_java_runtime_version=remotejdk_11
build --java_runtime_version=remotejdk_11
# https://github.com/bazelbuild/rules_jvm_external/issues/445
build --repo_env=JAVA_HOME=../bazel_tools/jdk
build --define disable_known_issue_asserts=true
Expand Down
7 changes: 5 additions & 2 deletions mobile/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ python_configure(name = "local_config_python", python_version = "3")
load("//bazel:python.bzl", "declare_python_abi")
declare_python_abi(name = "python_abi", python_version = "3")

android_sdk_repository(name = "androidsdk", api_level = 30, build_tools_version = "30.0.2")
android_ndk_repository(name = "androidndk", api_level = 21)
load("//bazel:android_configure.bzl", "android_configure")
android_configure(name = "local_config_android")

load("@local_config_android//:android_configure.bzl", "android_workspace")
android_workspace()
53 changes: 53 additions & 0 deletions mobile/bazel/android_configure.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Repository rule for Android SDK and NDK autoconfiguration.
This rule is a no-op unless the required android environment variables are set.
"""

# Based on https://github.com/tensorflow/tensorflow/tree/34c03ed67692eb76cb3399cebca50ea8bcde064c/third_party/android
# Workaround for https://github.com/bazelbuild/bazel/issues/14260

_ANDROID_NDK_HOME = "ANDROID_NDK_HOME"
_ANDROID_SDK_HOME = "ANDROID_HOME"

def _android_autoconf_impl(repository_ctx):
sdk_home = repository_ctx.os.environ.get(_ANDROID_SDK_HOME)
ndk_home = repository_ctx.os.environ.get(_ANDROID_NDK_HOME)

sdk_rule = ""
if sdk_home:
sdk_rule = """
native.android_sdk_repository(
name="androidsdk",
path="{}",
api_level=30,
build_tools_version="30.0.2",
)
""".format(sdk_home)

ndk_rule = ""
if ndk_home:
ndk_rule = """
native.android_ndk_repository(
name="androidndk",
path="{}",
api_level=21,
)
""".format(ndk_home)

if ndk_rule == "" and sdk_rule == "":
sdk_rule = "pass"

repository_ctx.file("BUILD.bazel", "")
repository_ctx.file("android_configure.bzl", """
def android_workspace():
{}
{}
""".format(sdk_rule, ndk_rule))

android_configure = repository_rule(
implementation = _android_autoconf_impl,
environ = [
_ANDROID_NDK_HOME,
_ANDROID_SDK_HOME,
],
)
2 changes: 1 addition & 1 deletion mobile/envoy
Submodule envoy updated from 71248e to bbcd48

0 comments on commit 36183c9

Please sign in to comment.