diff options
author | 2016-07-14 19:12:09 +0000 | |
---|---|---|
committer | 2016-07-15 13:30:55 +0000 | |
commit | 6c693a15a23b29e5d97fd0849b31367541e48bca (patch) | |
tree | fe1db9877caea528b94471638b3a85245e92cca9 /src/main/java/com/google | |
parent | e3dc62f2b520d6698776754ef70e916300895330 (diff) |
Create another pseudo-label for the JDK launcher
--
MOS_MIGRATED_REVID=127458867
Diffstat (limited to 'src/main/java/com/google')
4 files changed, 9 insertions, 16 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java index f216ea6cd0..0ec9779d48 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java @@ -52,7 +52,6 @@ import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.util.ShellEscaper; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.PathFragment; - import java.io.File; import java.util.ArrayList; import java.util.Collection; @@ -78,8 +77,8 @@ public class BazelJavaSemantics implements JavaSemantics { } @Override - public Label getJdkLauncherLabel() { - return JDK_LAUNCHER_LABEL; + public boolean isJdkLauncher(Label label) { + return JDK_LAUNCHER_LABEL.equals(label); } private boolean isJavaBinaryOrJavaTest(RuleContext ruleContext) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java index 10a56bf90f..3b3060e843 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java @@ -46,11 +46,9 @@ import com.google.devtools.build.lib.rules.java.JavaCompilationArgs.ClasspathTyp import com.google.devtools.build.lib.rules.java.ProguardHelper.ProguardOutput; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.ArrayList; import java.util.Collection; import java.util.List; - import javax.annotation.Nullable; /** @@ -87,8 +85,7 @@ public class JavaBinary implements RuleConfiguredTargetFactory { // TODO(cushon): disallow combining launcher=JDK_LAUNCHER_LABEL with create_executable=0 // and use isAttributeExplicitlySpecified here Label launcherAttribute = ruleContext.attributes().get("launcher", BuildType.LABEL); - if (launcherAttribute != null - && !launcherAttribute.equals(semantics.getJdkLauncherLabel())) { + if (launcherAttribute != null && !semantics.isJdkLauncher(launcherAttribute)) { ruleContext.ruleError("launcher specified but create_executable is false"); } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java index cfcbedbdd5..0e709d0f4f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java @@ -23,7 +23,6 @@ import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.shell.ShellUtils; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.ArrayList; import java.util.List; @@ -68,8 +67,7 @@ public abstract class JavaHelper { // BUILD rule "launcher" attribute if (ruleContext.getRule().isAttrDefined("launcher", BuildType.LABEL) && ruleContext.attributes().get("launcher", BuildType.LABEL) != null) { - if (ruleContext.attributes().get("launcher", BuildType.LABEL) - .equals(semantics.getJdkLauncherLabel())) { + if (semantics.isJdkLauncher(ruleContext.attributes().get("launcher", BuildType.LABEL))) { return null; } return "launcher"; @@ -78,7 +76,7 @@ public abstract class JavaHelper { JavaConfiguration javaConfig = ruleContext.getFragment(JavaConfiguration.class); if (ruleContext.getRule().isAttrDefined(":java_launcher", BuildType.LABEL) && javaConfig.getJavaLauncherLabel() != null - && !javaConfig.getJavaLauncherLabel().equals(semantics.getJdkLauncherLabel())) { + && !semantics.isJdkLauncher(javaConfig.getJavaLauncherLabel())) { return ":java_launcher"; } return null; diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java index 5496502f1d..ed81f99187 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java @@ -39,10 +39,8 @@ import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.rules.java.DeployArchiveBuilder.Compression; import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.Collection; import java.util.List; - import javax.annotation.Nullable; /** @@ -385,9 +383,10 @@ public interface JavaSemantics { Artifact getProtoMapping(RuleContext ruleContext) throws InterruptedException; /** - * @return Label of pseudo-cc_binary that tells Blaze a java target's JAVABIN is never to be - * replaced by the contents of --java_launcher; only the JDK's launcher will ever be used. + * Returns true if the given Label is of the pseudo-cc_binary that tells Blaze a java target's + * JAVABIN is never to be replaced by the contents of --java_launcher; only the JDK's launcher + * will ever be used. */ - Label getJdkLauncherLabel(); + boolean isJdkLauncher(Label label); } |