Skip to content

Commit 0e84b67

Browse files
cushonbuchgr
authored andcommitted
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
1 parent 7c332b5 commit 0e84b67

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

tools/jdk/BUILD

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ load(
88
"default_java_toolchain",
99
"JDK8_JVM_OPTS",
1010
"JDK9_JVM_OPTS",
11+
"java_runtime_files",
1112
"DEFAULT_JAVACOPTS",
1213
)
1314

@@ -52,29 +53,29 @@ alias(
5253
actual = "@bazel_tools//tools/jdk:current_java_runtime",
5354
)
5455

55-
alias(
56+
java_runtime_files(
5657
name = "jni_header",
57-
actual = "@local_jdk//:jni_header",
58+
srcs = ["include/jni.h"],
5859
)
5960

60-
alias(
61+
java_runtime_files(
6162
name = "jni_md_header-darwin",
62-
actual = "@local_jdk//:jni_md_header-darwin",
63+
srcs = ["include/darwin/jni_md.h"],
6364
)
6465

65-
alias(
66+
java_runtime_files(
6667
name = "jni_md_header-linux",
67-
actual = "@local_jdk//:jni_md_header-linux",
68+
srcs = ["include/linux/jni_md.h"],
6869
)
6970

70-
alias(
71+
java_runtime_files(
7172
name = "jni_md_header-windows",
72-
actual = "@local_jdk//:jni_md_header-windows",
73+
srcs = ["include/win32/jni_md.h"],
7374
)
7475

75-
alias(
76+
java_runtime_files(
7677
name = "jni_md_header-freebsd",
77-
actual = "@local_jdk//:jni_md_header-freebsd",
78+
srcs = ["include/freebsd/jni_md.h"],
7879
)
7980

8081
alias(

tools/jdk/default_java_toolchain.bzl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,19 @@ def default_java_toolchain(name, **kwargs):
8989
name = name,
9090
**toolchain_args
9191
)
92+
93+
def java_runtime_files(name, srcs):
94+
"""Copies the given sources out of the current Java runtime."""
95+
96+
native.filegroup(
97+
name = name,
98+
srcs = srcs,
99+
)
100+
for src in srcs:
101+
native.genrule(
102+
name = "gen_%s" % src,
103+
srcs = ["//tools/jdk:current_java_runtime"],
104+
toolchains = ["//tools/jdk:current_java_runtime"],
105+
cmd = "cp $(JAVABASE)/%s $@" % src,
106+
outs = [src],
107+
)

0 commit comments

Comments
 (0)