Skip to content

Commit

Permalink
Automated rollback of commit 56ef727.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breaks guitar tests

*** Original change description ***

Allow --javabase to accept java_runtime (not just java_runtime_suite)

Fixes bazelbuild#3407

PiperOrigin-RevId: 179771492
  • Loading branch information
dkelmer authored and Copybara-Service committed Dec 21, 2017
1 parent dbe59b2 commit 26b7ea6
Showing 1 changed file with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,13 @@ private static Jvm createFromJavaRuntimeSuite(
}
Target javaHomeTarget = lookup.getTarget(javaBase);
if (javaHomeTarget instanceof Rule) {
switch (((Rule) javaHomeTarget).getRuleClass()) {
case "java_runtime_suite":
return createFromRuntimeSuite(lookup, (Rule) javaHomeTarget, cpu);
case "java_runtime":
return createFromRuntime(lookup, javaHomeTarget.getLabel());
default:
throw new InvalidConfigurationException(
"Unexpected javabase rule kind '"
+ ((Rule) javaHomeTarget).getRuleClass()
+ "'. Expected java_runtime_suite");
if (!((Rule) javaHomeTarget).getRuleClass().equals("java_runtime_suite")) {
throw new InvalidConfigurationException(
"Unexpected javabase rule kind '"
+ ((Rule) javaHomeTarget).getRuleClass()
+ "'. Expected java_runtime_suite");
}
return createFromRuntimeSuite(lookup, (Rule) javaHomeTarget, cpu);
}
throw new InvalidConfigurationException(
"No JVM target found under " + javaBase + " that would work for " + cpu);
Expand All @@ -105,25 +101,11 @@ private static Jvm createFromJavaRuntimeSuite(

// TODO(b/34175492): eventually the Jvm fragement will containg only the label of a java_runtime
// rule, and all of the configuration will be accessed using JavaRuntimeInfo.

private static Jvm createFromRuntimeSuite(
ConfigurationEnvironment lookup, Rule javaRuntimeSuite, String cpu)
private static Jvm createFromRuntimeSuite(ConfigurationEnvironment lookup, Rule javaRuntimeSuite,
String cpu)
throws InvalidConfigurationException, InterruptedException, NoSuchTargetException,
NoSuchPackageException {
Label javaRuntimeLabel = selectRuntime(javaRuntimeSuite, cpu);
PathFragment javaHome = getJavaHome(lookup, javaRuntimeLabel);
return new Jvm(javaHome, javaRuntimeSuite.getLabel());
}

private static Jvm createFromRuntime(ConfigurationEnvironment lookup, Label javaRuntimeLabel)
throws InvalidConfigurationException, InterruptedException, NoSuchTargetException,
NoSuchPackageException {
return new Jvm(getJavaHome(lookup, javaRuntimeLabel), javaRuntimeLabel);
}

private static PathFragment getJavaHome(ConfigurationEnvironment lookup, Label javaRuntimeLabel)
throws NoSuchPackageException, NoSuchTargetException, InterruptedException,
InvalidConfigurationException {
Target javaRuntimeTarget = lookup.getTarget(javaRuntimeLabel);
if (javaRuntimeTarget == null) {
return null;
Expand All @@ -150,7 +132,7 @@ private static PathFragment getJavaHome(ConfigurationEnvironment lookup, Label j
javaHomePath, srcs.toString()));
}
}
return javaHomePath;
return new Jvm(javaHomePath, javaRuntimeSuite.getLabel());
}

private static Label selectRuntime(Rule javaRuntimeSuite, String cpu)
Expand Down

0 comments on commit 26b7ea6

Please sign in to comment.