Skip to content

Commit

Permalink
Remove support for java_runtime_suite
Browse files Browse the repository at this point in the history
RELNOTES: Remove support for java_runtime_suite; use alias() together with select() instead.
PiperOrigin-RevId: 203393253
  • Loading branch information
cushon authored and Copybara-Service committed Jul 5, 2018
1 parent 55d0c1c commit 6e0466f
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 202 deletions.
2 changes: 0 additions & 2 deletions src/main/java/com/google/devtools/build/lib/BUILD
Expand Up @@ -929,8 +929,6 @@ java_library(
"rules/java/JavaRuntimeAliasRule.java", "rules/java/JavaRuntimeAliasRule.java",
"rules/java/JavaRuntimeClasspathProvider.java", "rules/java/JavaRuntimeClasspathProvider.java",
"rules/java/JavaRuntimeRule.java", "rules/java/JavaRuntimeRule.java",
"rules/java/JavaRuntimeSuite.java",
"rules/java/JavaRuntimeSuiteRule.java",
"rules/java/JavaSkylarkCommon.java", "rules/java/JavaSkylarkCommon.java",
"rules/java/JavaSourceInfoProvider.java", "rules/java/JavaSourceInfoProvider.java",
"rules/java/JavaToolchain.java", "rules/java/JavaToolchain.java",
Expand Down
Expand Up @@ -37,7 +37,6 @@
import com.google.devtools.build.lib.rules.java.JavaRuleClasses.IjarBaseRule; import com.google.devtools.build.lib.rules.java.JavaRuleClasses.IjarBaseRule;
import com.google.devtools.build.lib.rules.java.JavaRuntimeAliasRule; import com.google.devtools.build.lib.rules.java.JavaRuntimeAliasRule;
import com.google.devtools.build.lib.rules.java.JavaRuntimeRule; import com.google.devtools.build.lib.rules.java.JavaRuntimeRule;
import com.google.devtools.build.lib.rules.java.JavaRuntimeSuiteRule;
import com.google.devtools.build.lib.rules.java.JavaSkylarkCommon; import com.google.devtools.build.lib.rules.java.JavaSkylarkCommon;
import com.google.devtools.build.lib.rules.java.JavaToolchainAliasRule; import com.google.devtools.build.lib.rules.java.JavaToolchainAliasRule;
import com.google.devtools.build.lib.rules.java.JavaToolchainRule; import com.google.devtools.build.lib.rules.java.JavaToolchainRule;
Expand Down Expand Up @@ -78,7 +77,6 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {
builder.addRuleDefinition(JavaToolchainRule.create(BazelJavaToolchain.class)); builder.addRuleDefinition(JavaToolchainRule.create(BazelJavaToolchain.class));
builder.addRuleDefinition(new JavaPackageConfigurationRule()); builder.addRuleDefinition(new JavaPackageConfigurationRule());
builder.addRuleDefinition(new JavaRuntimeRule()); builder.addRuleDefinition(new JavaRuntimeRule());
builder.addRuleDefinition(new JavaRuntimeSuiteRule());
builder.addRuleDefinition(new JavaRuntimeAliasRule()); builder.addRuleDefinition(new JavaRuntimeAliasRule());
builder.addRuleDefinition(new JavaHostRuntimeAliasRule()); builder.addRuleDefinition(new JavaHostRuntimeAliasRule());
builder.addRuleDefinition(new JavaToolchainAliasRule()); builder.addRuleDefinition(new JavaToolchainAliasRule());
Expand Down
Expand Up @@ -74,16 +74,15 @@ public ImportDepsCheckingLevelConverter() {
} }


@Option( @Option(
name = "javabase", name = "javabase",
defaultValue = "@bazel_tools//tools/jdk:jdk", defaultValue = "@bazel_tools//tools/jdk:jdk",
converter = LabelConverter.class, converter = LabelConverter.class,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN}, effectTags = {OptionEffectTag.UNKNOWN},
help = help =
"JAVABASE used for the JDK invoked by Blaze. This is the " "JAVABASE used for the JDK invoked by Blaze. This is the "
+ "java_runtime_suite which will be used to execute " + "java_runtime which will be used to execute "
+ "external Java commands." + "external Java commands.")
)
public Label javaBase; public Label javaBase;


@Option( @Option(
Expand All @@ -107,15 +106,14 @@ public ImportDepsCheckingLevelConverter() {
public Label hostJavaToolchain; public Label hostJavaToolchain;


@Option( @Option(
name = "host_javabase", name = "host_javabase",
defaultValue = "@bazel_tools//tools/jdk:host_jdk", defaultValue = "@bazel_tools//tools/jdk:host_jdk",
converter = LabelConverter.class, converter = LabelConverter.class,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN}, effectTags = {OptionEffectTag.UNKNOWN},
help = help =
"JAVABASE used for the host JDK. This is the java_runtime_suite which is used to execute " "JAVABASE used for the host JDK. This is the java_runtime which is used to execute "
+ "tools during a build." + "tools during a build.")
)
public Label hostJavaBase; public Label hostJavaBase;


@Option( @Option(
Expand Down

This file was deleted.

This file was deleted.

8 changes: 1 addition & 7 deletions src/main/tools/jdk.BUILD
Expand Up @@ -141,14 +141,8 @@ filegroup(
]), ]),
) )


java_runtime_suite(
name = "jdk",
runtimes = {},
default = ":jdk-default",
)

java_runtime( java_runtime(
name = "jdk-default", name = "jdk",
srcs = [ srcs = [
":jdk-bin", ":jdk-bin",
":jdk-include", ":jdk-include",
Expand Down
Expand Up @@ -92,13 +92,12 @@ public void setupMockClient(MockToolsConfig config) throws IOException {
" genclass = ['GenClass_deploy.jar'],", " genclass = ['GenClass_deploy.jar'],",
" ijar = ['ijar'],", " ijar = ['ijar'],",
")", ")",
"java_runtime(name = 'jdk-default', srcs = [])", "java_runtime(name = 'jdk', srcs = [])",
"java_runtime(name = 'host_jdk', srcs = [])",
"java_runtime_alias(name = 'current_java_runtime')", "java_runtime_alias(name = 'current_java_runtime')",
// This isn't actually the host runtime, but will do. This way, we don't need to pull in the // This isn't actually the host runtime, but will do. This way, we don't need to pull in the
// Skylark implementation of the java_host_runtime_alias rule. // Skylark implementation of the java_host_runtime_alias rule.
"java_runtime_alias(name = 'current_host_java_runtime')", "java_runtime_alias(name = 'current_host_java_runtime')",
"java_runtime_suite(name = 'jdk', runtimes = {}, default = ':jdk-default')",
"java_runtime_suite(name = 'host_jdk', runtimes = {}, default = ':jdk-default')",
"filegroup(name='langtools', srcs=['jdk/lib/tools.jar'])", "filegroup(name='langtools', srcs=['jdk/lib/tools.jar'])",
"filegroup(name='bootclasspath', srcs=['jdk/jre/lib/rt.jar'])", "filegroup(name='bootclasspath', srcs=['jdk/jre/lib/rt.jar'])",
"filegroup(name='extdir', srcs=glob(['jdk/jre/lib/ext/*']))", "filegroup(name='extdir', srcs=glob(['jdk/jre/lib/ext/*']))",
Expand All @@ -111,7 +110,6 @@ public void setupMockClient(MockToolsConfig config) throws IOException {
" 'turbine_deploy.jar','ExperimentalTestRunner_deploy.jar'])", " 'turbine_deploy.jar','ExperimentalTestRunner_deploy.jar'])",
"sh_binary(name = 'proguard_whitelister', srcs = ['empty.sh'])"); "sh_binary(name = 'proguard_whitelister', srcs = ['empty.sh'])");



ImmutableList<String> androidBuildContents = createAndroidBuildContents(); ImmutableList<String> androidBuildContents = createAndroidBuildContents();
config.create( config.create(
"/bazel_tools_workspace/tools/android/BUILD", "/bazel_tools_workspace/tools/android/BUILD",
Expand Down
Expand Up @@ -53,7 +53,6 @@ public void testJavaRuntimeProviderJavaExecutableAbsolute() throws Exception {
scratch.file("a/BUILD", scratch.file("a/BUILD",
"load(':rule.bzl', 'jrule')", "load(':rule.bzl', 'jrule')",
"java_runtime(name='jvm', srcs=[], java_home='/foo/bar/')", "java_runtime(name='jvm', srcs=[], java_home='/foo/bar/')",
"java_runtime_suite(name='suite', default=':jvm')",
"java_runtime_alias(name='alias')", "java_runtime_alias(name='alias')",
"jrule(name='r')"); "jrule(name='r')");


Expand All @@ -67,7 +66,7 @@ public void testJavaRuntimeProviderJavaExecutableAbsolute() throws Exception {
")", ")",
"jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})"); "jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})");


useConfiguration("--javabase=//a:suite"); useConfiguration("--javabase=//a:jvm");
ConfiguredTarget ct = getConfiguredTarget("//a:r"); ConfiguredTarget ct = getConfiguredTarget("//a:r");
@SuppressWarnings("unchecked") PathFragment javaExecutable = @SuppressWarnings("unchecked") PathFragment javaExecutable =
(PathFragment) ct.get("java_executable"); (PathFragment) ct.get("java_executable");
Expand All @@ -82,7 +81,6 @@ public void testJavaRuntimeProviderJavaExecutableHermetic() throws Exception {
scratch.file("a/BUILD", scratch.file("a/BUILD",
"load(':rule.bzl', 'jrule')", "load(':rule.bzl', 'jrule')",
"java_runtime(name='jvm', srcs=[], java_home='foo/bar')", "java_runtime(name='jvm', srcs=[], java_home='foo/bar')",
"java_runtime_suite(name='suite', default=':jvm')",
"java_runtime_alias(name='alias')", "java_runtime_alias(name='alias')",
"jrule(name='r')"); "jrule(name='r')");


Expand All @@ -96,7 +94,7 @@ public void testJavaRuntimeProviderJavaExecutableHermetic() throws Exception {
")", ")",
"jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})"); "jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})");


useConfiguration("--javabase=//a:suite"); useConfiguration("--javabase=//a:jvm");
ConfiguredTarget ct = getConfiguredTarget("//a:r"); ConfiguredTarget ct = getConfiguredTarget("//a:r");
@SuppressWarnings("unchecked") PathFragment javaExecutable = @SuppressWarnings("unchecked") PathFragment javaExecutable =
(PathFragment) ct.get("java_executable"); (PathFragment) ct.get("java_executable");
Expand All @@ -111,7 +109,6 @@ public void testJavaRuntimeProviderJavaHome() throws Exception {
scratch.file("a/BUILD", scratch.file("a/BUILD",
"load(':rule.bzl', 'jrule')", "load(':rule.bzl', 'jrule')",
"java_runtime(name='jvm', srcs=[], java_home='/foo/bar/')", "java_runtime(name='jvm', srcs=[], java_home='/foo/bar/')",
"java_runtime_suite(name='suite', default=':jvm')",
"java_runtime_alias(name='alias')", "java_runtime_alias(name='alias')",
"jrule(name='r')"); "jrule(name='r')");


Expand All @@ -124,7 +121,7 @@ public void testJavaRuntimeProviderJavaHome() throws Exception {
")", ")",
"jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})"); "jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})");


useConfiguration("--javabase=//a:suite"); useConfiguration("--javabase=//a:jvm");
ConfiguredTarget ct = getConfiguredTarget("//a:r"); ConfiguredTarget ct = getConfiguredTarget("//a:r");
@SuppressWarnings("unchecked") PathFragment javaHome = @SuppressWarnings("unchecked") PathFragment javaHome =
(PathFragment) ct.get("java_home"); (PathFragment) ct.get("java_home");
Expand Down
Expand Up @@ -2008,27 +2008,6 @@ public void testCoverageInstrumentedMatchesFilterNonDefaultLabel() throws Except
assertThat((Boolean) result).isTrue(); assertThat((Boolean) result).isTrue();
} }


@Test
public void testStringKeyedLabelDictAttributeInSkylarkRuleContext() throws Exception {
scratch.file("jvm/BUILD",
"java_runtime(name='runtime', srcs=[], java_home='')",
"java_runtime_suite(",
" name = 'suite',",
" runtimes = {'x86': ':runtime'},",
" default = ':runtime',",
")");

invalidatePackages();
SkylarkRuleContext ruleContext = createRuleContext("//jvm:suite");
assertNoEvents();
String keyString =
(String) evalRuleContextCode(ruleContext, "ruleContext.attr.runtimes.keys()[0]");
assertThat(keyString).isEqualTo("x86");
Label valueLabel =
(Label) evalRuleContextCode(ruleContext, "ruleContext.attr.runtimes.values()[0]");
assertThat(valueLabel).isEqualTo(Label.parseAbsolute("//jvm:runtime", ImmutableMap.of()));
}

// A list of attributes and methods ctx objects have // A list of attributes and methods ctx objects have
private final List<String> ctxAttributes = ImmutableList.of( private final List<String> ctxAttributes = ImmutableList.of(
"attr", "attr",
Expand Down
6 changes: 1 addition & 5 deletions src/test/py/bazel/windows_remote_test.py
Expand Up @@ -179,12 +179,8 @@ def testJavaTestWithRuntimeRunsRemotely(self):
' use_testrunner = 0,', ' use_testrunner = 0,',
' data = ["//bar:bar.txt"],', ' data = ["//bar:bar.txt"],',
')', ')',
'java_runtime_suite(',
' name = "jdk8",',
' default = ":jdk8-default",',
')',
'java_runtime(', 'java_runtime(',
' name = "jdk8-default",', ' name = "jdk8",',
' srcs = [],', ' srcs = [],',
' java_home = "' + java_home + '",', ' java_home = "' + java_home + '",',
')', ')',
Expand Down
3 changes: 1 addition & 2 deletions src/test/shell/integration/java_integration_test.sh
Expand Up @@ -254,14 +254,13 @@ function assert_singlejar_works() {
mkdir -p "$pkg/jvm" mkdir -p "$pkg/jvm"
cat > "$pkg/jvm/BUILD" <<EOF cat > "$pkg/jvm/BUILD" <<EOF
package(default_visibility=["//visibility:public"]) package(default_visibility=["//visibility:public"])
java_runtime_suite(name='suite', default=':runtime')
java_runtime(name='runtime', java_home='$javabase') java_runtime(name='runtime', java_home='$javabase')
EOF EOF




# Set javabase to an absolute path. # Set javabase to an absolute path.
bazel build //$pkg/java/hello:hello //$pkg/java/hello:hello_deploy.jar \ bazel build //$pkg/java/hello:hello //$pkg/java/hello:hello_deploy.jar \
"$stamp_arg" --javabase="//$pkg/jvm:suite" "$embed_label" >&"$TEST_log" \ "$stamp_arg" --javabase="//$pkg/jvm:runtime" "$embed_label" >&"$TEST_log" \
|| fail "Build failed" || fail "Build failed"


mkdir $pkg/ugly/ || fail "mkdir failed" mkdir $pkg/ugly/ || fail "mkdir failed"
Expand Down

0 comments on commit 6e0466f

Please sign in to comment.