Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tree artifacts in bootclasspath rule #15819

Merged
merged 3 commits into from
Jul 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions tools/jdk/default_java_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,7 @@ def java_runtime_files(name, srcs):
def _bootclasspath_impl(ctx):
host_javabase = ctx.attr.host_javabase[java_common.JavaRuntimeInfo]

# explicitly list output files instead of using TreeArtifact to work around
# https://github.com/bazelbuild/bazel/issues/6203
classes = [
"DumpPlatformClassPath.class",
]

class_outputs = [
ctx.actions.declare_file("%s_classes/%s" % (ctx.label.name, clazz))
for clazz in classes
]
class_dir = ctx.actions.declare_directory("%s_classes" % ctx.label.name)

args = ctx.actions.args()
args.add("-source")
Expand All @@ -223,20 +214,20 @@ def _bootclasspath_impl(ctx):
args.add("-cp")
args.add("%s/lib/tools.jar" % host_javabase.java_home)
args.add("-d")
args.add(class_outputs[0].dirname)
args.add_all([class_dir], expand_directories = False)
args.add(ctx.file.src)

ctx.actions.run(
executable = "%s/bin/javac" % host_javabase.java_home,
mnemonic = "JavaToolchainCompileClasses",
inputs = [ctx.file.src] + ctx.files.host_javabase,
outputs = class_outputs,
outputs = [class_dir],
arguments = [args],
)

bootclasspath = ctx.outputs.output_jar

inputs = class_outputs + ctx.files.host_javabase
inputs = [class_dir] + ctx.files.host_javabase

args = ctx.actions.args()
args.add("-XX:+IgnoreUnrecognizedVMOptions")
Expand All @@ -245,8 +236,9 @@ def _bootclasspath_impl(ctx):
args.add("--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED")
args.add_joined(
"-cp",
[class_outputs[0].dirname, "%s/lib/tools.jar" % host_javabase.java_home],
[class_dir, "%s/lib/tools.jar" % host_javabase.java_home],
join_with = ctx.configuration.host_path_separator,
expand_directories = False,
)
args.add("DumpPlatformClassPath")
args.add(bootclasspath)
Expand Down