Skip to content

Commit a27c7de

Browse files
hvadehrarules_java Copybara
authored andcommitted
Cut the dependency on ijar when not stripping the bootclasspath
Rule deps are fetched eagerly, even if unused, so we need to actually cut the edge to ijar when not stripping for bazel bootstrapping to succeed. Unfortunately, with the way Bazel integration tests are set up, there's no way to test this with Bazel without making a release. I manually verified that `bazel query deps()` reports the right results and the targets build correctly. ``` $ bazel query 'deps(//toolchains:platformclasspath, 1)' //:license //toolchains:DumpPlatformClassPath.java //toolchains:current_java_runtime //toolchains:ijar //toolchains:incompatible_language_version_bootclasspath_enabled //toolchains:language_version_bootstrap_runtime //toolchains:platformclasspath //toolchains:utf8_environment @bazel_tools//tools/allowlists/function_transition_allowlist:function_transition_allowlist @bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type $ bazel query 'deps(//toolchains:platformclasspath_unstripped, 1)' //:license //toolchains:DumpPlatformClassPath.java //toolchains:current_java_runtime //toolchains:incompatible_language_version_bootclasspath_enabled //toolchains:language_version_bootstrap_runtime //toolchains:platformclasspath_unstripped //toolchains:utf8_environment @bazel_tools//tools/allowlists/function_transition_allowlist:function_transition_allowlist @bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type ``` (ignore-relnotes) PiperOrigin-RevId: 828368783 Change-Id: Ie29eea882ad41e4efa8f1dd752679a221a239ae1
1 parent 67e83ef commit a27c7de

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

toolchains/bootclasspath.bzl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,16 @@ Rerun with --toolchain_resolution_debug='@bazel_tools//tools/jdk:bootstrap_runti
224224
)
225225

226226
bootclasspath = ctx.outputs.output_jar
227-
_run_ijar(
228-
actions = ctx.actions,
229-
label = ctx.label,
230-
ijar = ctx.executable._ijar,
231-
input = unstripped_bootclasspath,
232-
output = bootclasspath,
233-
)
234-
bootclasspath = bootclasspath if ctx.attr.strip else unstripped_bootclasspath
227+
if ctx.attr.strip:
228+
_run_ijar(
229+
actions = ctx.actions,
230+
label = ctx.label,
231+
ijar = ctx.executable._ijar,
232+
input = unstripped_bootclasspath,
233+
output = bootclasspath,
234+
)
235+
else:
236+
ctx.actions.symlink(output = bootclasspath, target_file = unstripped_bootclasspath)
235237
return [
236238
DefaultInfo(files = depset([bootclasspath])),
237239
java_common.BootClassPathInfo(
@@ -241,6 +243,9 @@ Rerun with --toolchain_resolution_debug='@bazel_tools//tools/jdk:bootstrap_runti
241243
OutputGroupInfo(jar = [bootclasspath]),
242244
]
243245

246+
def _compute_ijar(strip):
247+
return Label("//toolchains:ijar") if strip else None
248+
244249
_bootclasspath = rule(
245250
implementation = _bootclasspath_impl,
246251
attrs = {
@@ -261,7 +266,7 @@ _bootclasspath = rule(
261266
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
262267
),
263268
"_ijar": attr.label(
264-
default = "//toolchains:ijar",
269+
default = _compute_ijar,
265270
cfg = "exec",
266271
executable = True,
267272
),

0 commit comments

Comments
 (0)