Skip to content

Commit

Permalink
Don't use @local_jdk for jni headers
Browse files Browse the repository at this point in the history
instead, read the heads from the configured java runtime, so the values
track with changes to --javabase.

See bazelbuild#5594

PiperOrigin-RevId: 207759420
Change-Id: I0e5fa6060ea022b62fa8bd7fc427bc308ea61335
  • Loading branch information
cushon authored and buchgr committed Aug 8, 2018
1 parent 1056e94 commit 6832497
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package(default_visibility = ["//visibility:public"])
load(
"//tools/jdk:default_java_toolchain.bzl",
"default_java_toolchain",
"java_runtime_files",
"DEFAULT_JAVACOPTS",
)

Expand Down Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions tools/jdk/default_java_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)

0 comments on commit 6832497

Please sign in to comment.