Skip to content

Commit

Permalink
Re-add some of the targets removed recently
Browse files Browse the repository at this point in the history
Commit c33ae8a removed some targets and replaced them with targets called "remote-X". This PR adds back the initial targets but now referencing remote tools.

Progress on #6316.

Closes #7506.

PiperOrigin-RevId: 235174166
  • Loading branch information
iirina authored and copybara-github committed Feb 22, 2019
1 parent 382d758 commit 17794d5
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 53 deletions.
1 change: 1 addition & 0 deletions src/create_embedded_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
('*jarjar_command_deploy.jar',
lambda x: 'tools/jdk/jarjar_command_deploy.jar'),
('*BUILD-new.pkg', lambda x: 'tools/jdk/BUILD.pkg'),
('*BUILD.javalangtools', lambda x: 'third_party/java/jdk/langtools/BUILD'),
('*singlejar_local.exe', lambda x: 'tools/jdk/singlejar/singlejar.exe'),
('*singlejar_local', lambda x: 'tools/jdk/singlejar/singlejar'),
('*launcher.exe', lambda x: 'tools/launcher/launcher.exe'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public Object getDefault(AttributeMap rule) {
}))
.add(
attr("$jacocorunner", LABEL)
.value(env.getToolsLabel("//tools/jdk:remote_jacoco_coverage_runner")))
.value(env.getToolsLabel("//tools/jdk:JacocoCoverageRunner")))
.addRequiredToolchains(CppRuleClasses.ccToolchainTypeAttribute(env))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
"@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main")))
.add(
attr("$jacocorunner", LABEL)
.value(env.getToolsLabel("//tools/jdk:remote_jacoco_coverage_runner")))
.value(env.getToolsLabel("//tools/jdk:JacocoCoverageRunner")))
/* <!-- #BLAZE_RULE(java_test).ATTRIBUTE(test_class) -->
The Java class to be loaded by the test runner.<br/>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void setupMockClient(MockToolsConfig config, List<String> workspaceConten
" ijar = ['ijar'],",
")",
"java_import(",
" name = 'remote_jacoco_coverage_runner',",
" name = 'JacocoCoverageRunner',",
" jars = ['JacocoCoverage_jarjar_deploy.jar'],",
")",
"java_import(",
Expand Down
6 changes: 3 additions & 3 deletions src/test/shell/integration/bazel_java_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ EOF
function test_javabase() {
mkdir -p zoo/bin
cat << EOF > BUILD
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_remote_java_toolchain", "JDK9_REMOTE_JVM_OPTS")
default_remote_java_toolchain(
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain", "JDK9_JVM_OPTS")
default_java_toolchain(
name = "toolchain",
# Implicitly use the host_javabase bootclasspath, since the target doesn't
# exist in this test.
bootclasspath = [],
jvm_opts = JDK9_REMOTE_JVM_OPTS,
jvm_opts = JDK9_JVM_OPTS,
visibility = ["//visibility:public"],
)
java_runtime(
Expand Down
78 changes: 47 additions & 31 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load(
"//tools/jdk:default_java_toolchain.bzl",
"default_remote_java_toolchain",
"default_java_toolchain",
"java_runtime_files",
"JDK8_JVM_OPTS",
"bootclasspath",
Expand Down Expand Up @@ -151,52 +151,72 @@ filegroup(
exports_files(["BUILD.pkg"])

filegroup(
name = "remote-genclass",
name = "genclass",
srcs = ["@remote_java_tools//:GenClass"],
)

filegroup(
name = "remote-turbine",
name = "GenClass_deploy.jar",
srcs = ["@remote_java_tools//:java_tools/GenClass_deploy.jar"],
)

filegroup(
name = "bazel-singlejar_deploy.jar",
srcs = ["@remote_java_tools//:java_tools/bazel-singlejar_deploy.jar"],
)

filegroup(
name = "turbine",
srcs = ["@remote_java_tools//:Turbine"],
)

filegroup(
name = "remote-turbine_direct",
name = "turbine_deploy.jar",
srcs = ["@remote_java_tools//:java_tools/turbine_deploy.jar"],
)

filegroup(
name = "turbine_direct",
srcs = ["@remote_java_tools//:TurbineDirect"],
)

filegroup(
name = "remote-javabuilder",
name = "turbine_direct_binary_deploy.jar",
srcs = ["@remote_java_tools//:java_tools/turbine_direct_binary_deploy.jar"],
)

filegroup(
name = "javabuilder",
srcs = ["@remote_java_tools//:JavaBuilder"],
)

filegroup(
name = "vanillajavabuilder",
srcs = ["//tools/jdk:VanillaJavaBuilder_deploy.jar"],
name = "JavaBuilder_deploy.jar",
srcs = ["@remote_java_tools//:java_tools/JavaBuilder_deploy.jar"],
)

filegroup(
name = "remote-vanillajavabuilder",
name = "vanillajavabuilder",
srcs = ["@remote_java_tools//:VanillaJavaBuilder"],
)

filegroup(
name = "remote-javac_jar",
name = "javac_jar",
srcs = ["@remote_java_tools//:javac_jar"],
)

filegroup(
name = "remote-jdk_compiler_jar",
name = "jdk_compiler_jar",
srcs = ["@remote_java_tools//:jdk_compiler_jar"],
)

filegroup(
name = "remote-java_compiler_jar",
name = "java_compiler_jar",
srcs = ["@remote_java_tools//:java_compiler_jar"],
)

java_import(
name = "remote_jacoco_coverage_runner",
name = "JacocoCoverageRunner",
jars = ["@remote_java_tools//:java_tools/JacocoCoverage_jarjar_deploy.jar"],
)

Expand All @@ -205,11 +225,21 @@ java_import(
jars = ["@remote_java_tools//:java_tools/Runner_deploy.jar"],
)

filegroup(
name = "TestRunner_deploy.jar",
srcs = ["@remote_java_tools//:java_tools/Runner_deploy.jar"],
)

java_import(
name = "ExperimentalTestRunner",
jars = ["@remote_java_tools//:java_tools/ExperimentalRunner_deploy.jar"],
)

filegroup(
name = "ExperimentalRunner_deploy.jar",
srcs = ["@remote_java_tools//:java_tools/ExperimentalRunner_deploy.jar"],
)

BOOTCLASS_JARS = [
"rt.jar",
"resources.jar",
Expand Down Expand Up @@ -268,29 +298,22 @@ bootclasspath(
target_javabase = "current_java_runtime",
)

default_remote_java_toolchain(
default_java_toolchain(
name = "toolchain_hostjdk8",
jvm_opts = JDK8_JVM_OPTS,
source_version = "8",
target_version = "8",
)

default_remote_java_toolchain(
name = "remote_toolchain_hostjdk8",
jvm_opts = JDK8_JVM_OPTS,
source_version = "8",
target_version = "8",
)

# Default to the Java 8 language level.
# TODO(cushon): consider if/when we should increment this?
default_remote_java_toolchain(
default_java_toolchain(
name = "toolchain",
source_version = "8",
target_version = "8",
)

default_remote_java_toolchain(
default_java_toolchain(
name = "remote_toolchain",
source_version = "8",
target_version = "8",
Expand All @@ -310,24 +333,17 @@ default_remote_java_toolchain(
#
# However it does allow using a wider range of `--host_javabase`s, including
# versions newer than the current embedded JDK.
default_remote_java_toolchain(
default_java_toolchain(
name = "toolchain_vanilla",
forcibly_disable_header_compilation = True,
javabuilder = [":vanillajavabuilder"],
jvm_opts = [],
)

default_remote_java_toolchain(
name = "remote_toolchain_vanilla",
forcibly_disable_header_compilation = True,
javabuilder = ["@bazel_tools//tools/jdk:remote-vanillajavabuilder"],
jvm_opts = [],
)

RELEASES = (8, 9)

[
default_remote_java_toolchain(
default_java_toolchain(
name = "toolchain_java%d" % release,
source_version = "%s" % release,
target_version = "%s" % release,
Expand Down
31 changes: 15 additions & 16 deletions tools/jdk/default_java_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"""Bazel rules for creating Java toolchains."""

JDK8_JVM_OPTS = [
"-Xbootclasspath/p:$(location @bazel_tools//tools/jdk:remote-javac_jar)",
"-Xbootclasspath/p:$(location @bazel_tools//tools/jdk:javac_jar)",
]

JDK9_REMOTE_JVM_OPTS = [
JDK9_JVM_OPTS = [
# In JDK9 we have seen a ~30% slow down in JavaBuilder performance when using
# G1 collector and having compact strings enabled.
"-XX:+UseParallelOldGC",
Expand All @@ -34,8 +34,8 @@ JDK9_REMOTE_JVM_OPTS = [
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",

# override the javac in the JDK.
"--patch-module=java.compiler=$(location @bazel_tools//tools/jdk:remote-java_compiler_jar)",
"--patch-module=jdk.compiler=$(location @bazel_tools//tools/jdk:remote-jdk_compiler_jar)",
"--patch-module=java.compiler=$(location @bazel_tools//tools/jdk:java_compiler_jar)",
"--patch-module=jdk.compiler=$(location @bazel_tools//tools/jdk:jdk_compiler_jar)",

# quiet warnings from com.google.protobuf.UnsafeUtil,
# see: https://github.com/google/protobuf/issues/3781
Expand All @@ -61,31 +61,30 @@ PROTO_JAVACOPTS = [
COMPATIBLE_JAVACOPTS = {
"proto": PROTO_JAVACOPTS,
}

DEFAULT_REMOTE_TOOLCHAIN_CONFIGURATION = {
DEFAULT_TOOLCHAIN_CONFIGURATION = {
"forcibly_disable_header_compilation": 0,
"genclass": ["@bazel_tools//tools/jdk:remote-genclass"],
"header_compiler": ["@bazel_tools//tools/jdk:remote-turbine"],
"header_compiler_direct": ["@bazel_tools//tools/jdk:remote-turbine_direct"],
"genclass": ["@bazel_tools//tools/jdk:genclass"],
"header_compiler": ["@bazel_tools//tools/jdk:turbine"],
"header_compiler_direct": ["@bazel_tools//tools/jdk:turbine_direct"],
"ijar": ["@bazel_tools//tools/jdk:ijar"],
"javabuilder": ["@bazel_tools//tools/jdk:remote-javabuilder"],
"javac": ["@bazel_tools//tools/jdk:remote-javac_jar"],
"javabuilder": ["@bazel_tools//tools/jdk:javabuilder"],
"javac": ["@bazel_tools//tools/jdk:javac_jar"],
"tools": [
"@bazel_tools//tools/jdk:remote-java_compiler_jar",
"@bazel_tools//tools/jdk:remote-jdk_compiler_jar",
"@bazel_tools//tools/jdk:java_compiler_jar",
"@bazel_tools//tools/jdk:jdk_compiler_jar",
],
"javac_supports_workers": 1,
"jvm_opts": JDK9_REMOTE_JVM_OPTS,
"jvm_opts": JDK9_JVM_OPTS,
"misc": DEFAULT_JAVACOPTS,
"compatible_javacopts": COMPATIBLE_JAVACOPTS,
"singlejar": ["@bazel_tools//tools/jdk:singlejar"],
"bootclasspath": ["@bazel_tools//tools/jdk:platformclasspath"],
}

def default_remote_java_toolchain(name, **kwargs):
def default_java_toolchain(name, **kwargs):
"""Defines a remote java_toolchain with appropriate defaults for Bazel."""

toolchain_args = dict(DEFAULT_REMOTE_TOOLCHAIN_CONFIGURATION)
toolchain_args = dict(DEFAULT_TOOLCHAIN_CONFIGURATION)
toolchain_args.update(kwargs)

native.java_toolchain(
Expand Down

0 comments on commit 17794d5

Please sign in to comment.