aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/JackCompilationHelper.java
diff options
context:
space:
mode:
authorGravatar Michael Staib <mstaib@google.com>2015-07-15 13:50:28 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-07-16 08:14:28 +0000
commit4c568437c9c51657c672209673c65b679df238cc (patch)
treeb65f59e0f7ea74e3db4ac24adafe023b472160d8 /src/main/java/com/google/devtools/build/lib/rules/android/JackCompilationHelper.java
parent39ad966bd9706d1f70fa02c10bd04020500b55d1 (diff)
Move Jack's tools into AndroidSdkProvider.
This also eliminates the JackRule, which is no longer necessary, as its sole purpose was to allow Jack's tools to be found. This is now part of AndroidSdkProvider, like all other Android tools. For now, the new attributes on android_sdk are optional and default to their old values. In the future, the new attributes will become mandatory with no defaults, like the other attributes on that rule. Also fixes a bug where errors found during AndroidCommon.initJava would not result in a null return from init, previously obscured by the early return from initJack. -- MOS_MIGRATED_REVID=98305022
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/JackCompilationHelper.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/JackCompilationHelper.java35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/JackCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/android/JackCompilationHelper.java
index 247a37ffeb..d8377d218e 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/JackCompilationHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/JackCompilationHelper.java
@@ -25,7 +25,6 @@ import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.FileProvider;
import com.google.devtools.build.lib.analysis.FilesToRunProvider;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
@@ -550,8 +549,8 @@ public final class JackCompilationHelper {
/** Rule context used to build and register actions. */
@Nullable private RuleContext ruleContext;
- /** Jack library containing Android base classes. */
- @Nullable private Artifact androidBaseLibraryForJack;
+ /** Set of Android tools used to pick up the Jack tools. */
+ @Nullable private AndroidSdkProvider androidSdk;
/** The destination for the Jack artifact to be created. */
@Nullable private Artifact outputArtifact;
@@ -625,11 +624,11 @@ public final class JackCompilationHelper {
}
/**
- * Sets the artifact representing android.jack, to supply base libraries to Jack compilation.
+ * Sets the tools bundle containing Jack, Jill, the resource extractor, and the Android base
+ * library in Jack format.
*/
- public JackCompilationHelper.Builder setAndroidBaseLibraryForJack(
- Artifact androidBaseLibraryForJack) {
- this.androidBaseLibraryForJack = Preconditions.checkNotNull(androidBaseLibraryForJack);
+ public JackCompilationHelper.Builder setAndroidSdk(AndroidSdkProvider androidSdk) {
+ this.androidSdk = Preconditions.checkNotNull(androidSdk);
return this;
}
@@ -803,25 +802,25 @@ public final class JackCompilationHelper {
* JackCompilationHelpers will attempt to generate the same actions.
*/
public JackCompilationHelper build() {
+ Preconditions.checkNotNull(ruleContext);
+ Preconditions.checkNotNull(androidSdk);
+
boolean useSanityChecks =
ruleContext
.getConfiguration()
.getFragment(AndroidConfiguration.class)
.isJackSanityChecked();
- FilesToRunProvider jackBinary = ruleContext.getExecutablePrerequisite("$jack", Mode.HOST);
- FilesToRunProvider jillBinary = ruleContext.getExecutablePrerequisite("$jill", Mode.HOST);
- FilesToRunProvider resourceExtractorBinary =
- ruleContext.getExecutablePrerequisite("$resource_extractor", Mode.HOST);
- if (ruleContext.hasErrors()) {
- return null;
- }
+ FilesToRunProvider jackBinary = androidSdk.getJack();
+ FilesToRunProvider jillBinary = androidSdk.getJill();
+ FilesToRunProvider resourceExtractorBinary = androidSdk.getResourceExtractor();
+ Artifact androidBaseLibraryForJack = androidSdk.getAndroidJack();
return new JackCompilationHelper(
- Preconditions.checkNotNull(ruleContext),
+ ruleContext,
useSanityChecks,
- resourceExtractorBinary,
- jackBinary,
- jillBinary,
+ Preconditions.checkNotNull(resourceExtractorBinary),
+ Preconditions.checkNotNull(jackBinary),
+ Preconditions.checkNotNull(jillBinary),
Preconditions.checkNotNull(androidBaseLibraryForJack),
Preconditions.checkNotNull(outputArtifact),
ImmutableSet.copyOf(javaSources),