diff options
author | 2016-02-22 08:29:14 +0000 | |
---|---|---|
committer | 2016-02-22 16:08:44 +0000 | |
commit | bff735b1adef1b54a01d7d09dd2359e175255946 (patch) | |
tree | 2c1780a99689d280d9557ba6d8dbb855e859425f | |
parent | 8d247107451beeddbbbd3ae9c43fa12681e0d43d (diff) |
Rename all the internal proto_library Java-related attributes.
This is part of our internal migration strategy for proto_library. Do not use
the new constructors unless you know what you're doing. They will go away as
soon as we have completed our internal migration.
--
MOS_MIGRATED_REVID=115199181
3 files changed, 49 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/BaseJavaCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/BaseJavaCompilationHelper.java index e9667ca6d8..a00ed930cf 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/BaseJavaCompilationHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/BaseJavaCompilationHelper.java @@ -54,9 +54,15 @@ public class BaseJavaCompilationHelper { "--warn_duplicate_resources"); protected final RuleContext ruleContext; + private final String implicitAttributesSuffix; public BaseJavaCompilationHelper(RuleContext ruleContext) { + this(ruleContext, ""); + } + + public BaseJavaCompilationHelper(RuleContext ruleContext, String implicitAttributesSuffix) { this.ruleContext = ruleContext; + this.implicitAttributesSuffix = implicitAttributesSuffix; } /** @@ -69,6 +75,16 @@ public class BaseJavaCompilationHelper { return AnalysisUtils.getMiddlemanFor(ruleContext, ":host_jdk"); } + /** + * Returns the artifacts required to invoke {@code javahome} relative binary + * in the action. + */ + public NestedSet<Artifact> getHostJavabaseInputsNonStatic(RuleContext ruleContext) { + // This must have a different name than above, because the middleman creation uses the rule's + // configuration, although it should use the host configuration. + return AnalysisUtils.getMiddlemanFor(ruleContext, ":host_jdk" + implicitAttributesSuffix); + } + private CommandLine sourceJarCommandLine(Artifact outputJar, Map<PathFragment, Artifact> resources, Iterable<Artifact> resourceJars) { CustomCommandLine.Builder args = CustomCommandLine.builder(); @@ -95,7 +111,7 @@ public class BaseJavaCompilationHelper { .addOutput(outputJar) .addInputs(resources.values()) .addInputs(resourceJars) - .addTransitiveInputs(getHostJavabaseInputs(ruleContext)) + .addTransitiveInputs(getHostJavabaseInputsNonStatic(ruleContext)) .setJarExecutable( ruleContext.getHostConfiguration().getFragment(Jvm.class).getJavaExecutable(), ruleContext.getPrerequisiteArtifact("$singlejar", Mode.HOST), @@ -111,18 +127,19 @@ public class BaseJavaCompilationHelper { * Returns the langtools jar Artifact. */ protected final Artifact getLangtoolsJar() { - return ruleContext.getHostPrerequisiteArtifact("$java_langtools"); + return ruleContext.getHostPrerequisiteArtifact("$java_langtools" + implicitAttributesSuffix); } /** * Returns the JavaBuilder jar Artifact. */ protected final Artifact getJavaBuilderJar() { - return ruleContext.getPrerequisiteArtifact("$javabuilder", Mode.HOST); + return ruleContext.getPrerequisiteArtifact( + "$javabuilder" + implicitAttributesSuffix, Mode.HOST); } protected FilesToRunProvider getIJar() { - return ruleContext.getExecutablePrerequisite("$ijar", Mode.HOST); + return ruleContext.getExecutablePrerequisite("$ijar" + implicitAttributesSuffix, Mode.HOST); } /** @@ -130,7 +147,7 @@ public class BaseJavaCompilationHelper { */ protected Iterable<Artifact> getInstrumentationJars() { TransitiveInfoCollection instrumentationTarget = ruleContext.getPrerequisite( - "$jacoco_instrumentation", Mode.HOST); + "$jacoco_instrumentation" + implicitAttributesSuffix, Mode.HOST); if (instrumentationTarget == null) { return ImmutableList.<Artifact>of(); } @@ -143,14 +160,16 @@ public class BaseJavaCompilationHelper { * Returns the javac bootclasspath artifacts. */ protected final ImmutableList<Artifact> getBootClasspath() { - return ruleContext.getPrerequisiteArtifacts("$javac_bootclasspath", Mode.HOST).list(); + return ruleContext.getPrerequisiteArtifacts( + "$javac_bootclasspath" + implicitAttributesSuffix, Mode.HOST).list(); } /** * Returns the extdir artifacts. */ protected final ImmutableList<Artifact> getExtdirInputs() { - return ruleContext.getPrerequisiteArtifacts("$javac_extdir", Mode.HOST).list(); + return ruleContext.getPrerequisiteArtifacts( + "$javac_extdir" + implicitAttributesSuffix, Mode.HOST).list(); } private Artifact getIjarArtifact(Artifact jar, boolean addPrefix) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java index a75840bdaf..dfd121002d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java @@ -65,6 +65,17 @@ public final class JavaCompilationHelper extends BaseJavaCompilationHelper { private final JavaSemantics semantics; public JavaCompilationHelper(RuleContext ruleContext, JavaSemantics semantics, + ImmutableList<String> javacOpts, JavaTargetAttributes.Builder attributes, + String implicitAttributesSuffix) { + super(ruleContext, implicitAttributesSuffix); + this.attributes = attributes; + this.customJavacOpts = javacOpts; + this.customJavacJvmOpts = + ImmutableList.copyOf(JavaToolchainProvider.getDefaultJavacJvmOptions(ruleContext)); + this.semantics = semantics; + } + + public JavaCompilationHelper(RuleContext ruleContext, JavaSemantics semantics, ImmutableList<String> javacOpts, JavaTargetAttributes.Builder attributes) { super(ruleContext); this.attributes = attributes; @@ -316,7 +327,7 @@ public final class JavaCompilationHelper extends BaseJavaCompilationHelper { .addInput(manifestProto) .addInput(classJar) .addOutput(genClassJar) - .addTransitiveInputs(getHostJavabaseInputs(getRuleContext())) + .addTransitiveInputs(getHostJavabaseInputsNonStatic(getRuleContext())) .setJarExecutable( getRuleContext().getHostConfiguration().getFragment(Jvm.class).getJavaExecutable(), getRuleContext().getPrerequisiteArtifact("$genclass", Mode.HOST), @@ -404,7 +415,7 @@ public final class JavaCompilationHelper extends BaseJavaCompilationHelper { JavaCompileAction.Builder builder = new JavaCompileAction.Builder(ruleContext, semantics); builder.setJavaExecutable( ruleContext.getHostConfiguration().getFragment(Jvm.class).getJavaExecutable()); - builder.setJavaBaseInputs(BaseJavaCompilationHelper.getHostJavabaseInputs(ruleContext)); + builder.setJavaBaseInputs(getHostJavabaseInputsNonStatic(ruleContext)); return builder; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java index 9ef2fa00a0..e66847e422 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java @@ -56,6 +56,8 @@ import java.util.Map; * Java compiler. */ public final class JavaLibraryHelper { + private static final String DEFAULT_SUFFIX_IS_EMPTY_STRING = ""; + /** * Function for extracting the {@link JavaCompilationArgs} - note that it also handles .jar files. */ @@ -91,6 +93,7 @@ public final class JavaLibraryHelper { private final RuleContext ruleContext; private final BuildConfiguration configuration; + private final String implicitAttributesSuffix; private Artifact output; private final List<Artifact> sourceJars = new ArrayList<>(); @@ -109,9 +112,14 @@ public final class JavaLibraryHelper { private boolean legacyCollectCppAndJavaLinkOptions; public JavaLibraryHelper(RuleContext ruleContext) { + this(ruleContext, DEFAULT_SUFFIX_IS_EMPTY_STRING); + } + + public JavaLibraryHelper(RuleContext ruleContext, String implicitAttributesSuffix) { this.ruleContext = ruleContext; this.configuration = ruleContext.getConfiguration(); this.classpathMode = ruleContext.getFragment(JavaConfiguration.class).getReduceJavaClasspath(); + this.implicitAttributesSuffix = implicitAttributesSuffix; } /** @@ -249,7 +257,8 @@ public final class JavaLibraryHelper { JavaCompilationArtifacts.Builder artifactsBuilder = new JavaCompilationArtifacts.Builder(); JavaCompilationHelper helper = - new JavaCompilationHelper(ruleContext, semantics, javacOpts, attributes); + new JavaCompilationHelper( + ruleContext, semantics, javacOpts, attributes, implicitAttributesSuffix); Artifact outputDepsProto = helper.createOutputDepsProtoArtifact(output, artifactsBuilder); helper.createCompileAction( output, |