From 30c601dc13d9e1b40a57434c022c888c7578cc56 Mon Sep 17 00:00:00 2001 From: cushon Date: Wed, 8 Aug 2018 09:09:08 -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: 207894086 --- 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 d2463827aa3285..f1202e5bc56883 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], + )