From 6832497abdca9a12e3e969242e56062e7e05e9bc Mon Sep 17 00:00:00 2001 From: cushon Date: Tue, 7 Aug 2018 12:22:11 -0700 Subject: [PATCH] Don't use @local_jdk for jni headers instead, read the heads from the configured java runtime, so the values track with changes to --javabase. See #5594 PiperOrigin-RevId: 207759420 Change-Id: I0e5fa6060ea022b62fa8bd7fc427bc308ea61335 --- tools/jdk/BUILD | 21 +++++++++++---------- tools/jdk/default_java_toolchain.bzl | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD index 8ed37dec6aa1d9..f8a6b8ac9616f3 100644 --- a/tools/jdk/BUILD +++ b/tools/jdk/BUILD @@ -3,6 +3,7 @@ package(default_visibility = ["//visibility:public"]) load( "//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain", + "java_runtime_files", "DEFAULT_JAVACOPTS", ) @@ -32,29 +33,29 @@ alias( actual = "@bazel_tools//tools/jdk:current_java_runtime", ) -alias( +java_runtime_files( name = "jni_header", - actual = "@local_jdk//:jni_header", + srcs = ["include/jni.h"], ) -alias( +java_runtime_files( name = "jni_md_header-darwin", - actual = "@local_jdk//:jni_md_header-darwin", + srcs = ["include/darwin/jni_md.h"], ) -alias( +java_runtime_files( name = "jni_md_header-linux", - actual = "@local_jdk//:jni_md_header-linux", + srcs = ["include/linux/jni_md.h"], ) -alias( +java_runtime_files( name = "jni_md_header-windows", - actual = "@local_jdk//:jni_md_header-windows", + srcs = ["include/win32/jni_md.h"], ) -alias( +java_runtime_files( name = "jni_md_header-freebsd", - actual = "@local_jdk//:jni_md_header-freebsd", + srcs = ["include/freebsd/jni_md.h"], ) alias( diff --git a/tools/jdk/default_java_toolchain.bzl b/tools/jdk/default_java_toolchain.bzl index 5d7c8be0ebe07d..0361afacc16c89 100644 --- a/tools/jdk/default_java_toolchain.bzl +++ b/tools/jdk/default_java_toolchain.bzl @@ -86,3 +86,19 @@ def default_java_toolchain(name, **kwargs): name = name, **toolchain_args ) + +def java_runtime_files(name, srcs): + """Copies the given sources out of the current Java runtime.""" + + native.filegroup( + name = name, + srcs = srcs, + ) + for src in srcs: + native.genrule( + name = "gen_%s" % src, + srcs = ["//tools/jdk:current_java_runtime"], + toolchains = ["//tools/jdk:current_java_runtime"], + cmd = "cp $(JAVABASE)/%s $@" % src, + outs = [src], + )