From 6ba6041f4dd1afa31189c39ddfe85a9c31d7fc8a Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Wed, 27 Mar 2019 07:24:49 -0700 Subject: [PATCH] Prepare for --incompatible_use_toolchain_providers_in_java_common See https://github.com/bazelbuild/bazel/issues/7186, https://github.com/grpc/grpc-java/commit/c63752789e61dd44120dbafcc59f6c12d72d652f#diff-01b2f0c554164246dfe4fb696d181c9c --- WORKSPACE | 18 ++++----- .../io_grpc_grpc_java/c63752789e.patch | 38 +++++++++++++++++++ 2 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 third_party/io_grpc_grpc_java/c63752789e.patch diff --git a/WORKSPACE b/WORKSPACE index c1238d5a60..8669a4979c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -29,6 +29,7 @@ http_archive( "//third_party/io_grpc_grpc_java:054def3c63.patch", "//third_party/io_grpc_grpc_java:0959a846c8.patch", "//third_party/io_grpc_grpc_java:952a767b9c.patch", + "//third_party/io_grpc_grpc_java:c63752789e.patch", ], sha256 = "f5d0bdebc2a50d0e28f0d228d6c35081d3e973e6159f2695aa5c8c7f93d1e4d6", strip_prefix = "grpc-java-1.19.0", @@ -41,19 +42,19 @@ grpc_java_repositories() http_archive( name = "googleapis", + build_file = "@build_buildfarm//:BUILD.googleapis", sha256 = "7b6ea252f0b8fb5cd722f45feb83e115b689909bbb6a393a873b6cbad4ceae1d", - url = "https://github.com/googleapis/googleapis/archive/143084a2624b6591ee1f9d23e7f5241856642f4d.zip", strip_prefix = "googleapis-143084a2624b6591ee1f9d23e7f5241856642f4d", - build_file = "@build_buildfarm//:BUILD.googleapis", + url = "https://github.com/googleapis/googleapis/archive/143084a2624b6591ee1f9d23e7f5241856642f4d.zip", ) # The API that we implement. http_archive( name = "remote_apis", + build_file = "@build_buildfarm//:BUILD.remote_apis", sha256 = "6f22ba09356f8dbecb87ba03cacf147939f77fef1c9cfaffb3826691f3686e9b", - url = "https://github.com/bazelbuild/remote-apis/archive/cfe8e540cbb424e3ebc649ddcbc91190f70e23a6.zip", strip_prefix = "remote-apis-cfe8e540cbb424e3ebc649ddcbc91190f70e23a6", - build_file = "@build_buildfarm//:BUILD.remote_apis", + url = "https://github.com/bazelbuild/remote-apis/archive/cfe8e540cbb424e3ebc649ddcbc91190f70e23a6.zip", ) load("//3rdparty:workspace.bzl", "maven_dependencies") @@ -75,7 +76,6 @@ http_archive( ) load("@io_bazel_rules_docker//container:container.bzl", "container_pull") - load( "@io_bazel_rules_docker//java:image.bzl", _java_image_repos = "repositories", @@ -84,8 +84,8 @@ load( _java_image_repos() container_pull( - name = "java_base", - registry = "gcr.io", - repository = "distroless/java", - digest = "sha256:8c1769cb253bdecc257470f7fba05446a55b70805fa686f227a11655a90dfe9e", + name = "java_base", + digest = "sha256:8c1769cb253bdecc257470f7fba05446a55b70805fa686f227a11655a90dfe9e", + registry = "gcr.io", + repository = "distroless/java", ) diff --git a/third_party/io_grpc_grpc_java/c63752789e.patch b/third_party/io_grpc_grpc_java/c63752789e.patch new file mode 100644 index 0000000000..ecce5667f4 --- /dev/null +++ b/third_party/io_grpc_grpc_java/c63752789e.patch @@ -0,0 +1,38 @@ +From c63752789e61dd44120dbafcc59f6c12d72d652f Mon Sep 17 00:00:00 2001 +From: Eric Anderson +Date: Thu, 7 Mar 2019 16:22:54 -0800 +Subject: [PATCH] java_grpc_library.bzl: Pre-migrate for Bazel + incompatible_use_toolchain_providers_in_java_common + +This doesn't actually yet work with +--incompatible_use_toolchain_providers_in_java_common, as Bazel 0.23 didn't +include enough pieces. But this will work in 0.24 with the flag flipped. In +both cases it will continue working if the flag is not specified. + +See https://github.com/grpc/grpc-java/issues/5383#issuecomment-470357965 and +https://github.com/bazelbuild/bazel/issues/7186 +--- + java_grpc_library.bzl | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/java_grpc_library.bzl b/java_grpc_library.bzl +index 4601d4d78c..ff8abd422a 100644 +--- a/java_grpc_library.bzl ++++ b/java_grpc_library.bzl +@@ -1,3 +1,5 @@ ++load("@bazel_tools//tools/jdk:toolchain_utils.bzl", "find_java_runtime_toolchain", "find_java_toolchain") ++ + # "repository" here is for Bazel builds that span multiple WORKSPACES. + def _path_ignoring_repository(f): + if len(f.owner.workspace_root) == 0: +@@ -40,8 +42,8 @@ def _java_rpc_library_impl(ctx): + + java_info = java_common.compile( + ctx, +- java_toolchain = ctx.attr._java_toolchain, +- host_javabase = ctx.attr._host_javabase, ++ java_toolchain = find_java_toolchain(ctx, ctx.attr._java_toolchain), ++ host_javabase = find_java_runtime_toolchain(ctx, ctx.attr._host_javabase), + source_jars = [srcjar], + output_source_jar = ctx.outputs.srcjar, + output = ctx.outputs.jar,