diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java b/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java index ad878088445634..56d88f375b30a8 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; import com.google.devtools.build.lib.analysis.actions.SpawnAction; @@ -79,7 +78,7 @@ public ConfiguredTarget create(RuleContext ruleContext) AndroidSdkProvider.verifyPresence(ruleContext); RuleConfiguredTargetBuilder ruleBuilder = new RuleConfiguredTargetBuilder(ruleContext); - Artifact aar = ruleContext.getPrerequisiteArtifact("aar", TransitionMode.TARGET); + Artifact aar = ruleContext.getPrerequisiteArtifact("aar"); Artifact allAarJars = createAarTreeArtifact(ruleContext, "jars"); Artifact jarMergingParams = createAarArtifact(ruleContext, "jar_merging_params"); @@ -140,8 +139,8 @@ public ConfiguredTarget create(RuleContext ruleContext) ImmutableList targets = ImmutableList.builder() - .addAll(ruleContext.getPrerequisites("exports", TransitionMode.TARGET)) - .addAll(ruleContext.getPrerequisites("deps", TransitionMode.TARGET)) + .addAll(ruleContext.getPrerequisites("exports")) + .addAll(ruleContext.getPrerequisites("deps")) .build(); JavaCommon common = new JavaCommon( @@ -198,7 +197,7 @@ public ConfiguredTarget create(RuleContext ruleContext) // Wire up the source jar for the current target and transitive source jars from dependencies. ImmutableList srcJars = ImmutableList.of(); - Artifact srcJar = ruleContext.getPrerequisiteArtifact("srcjar", TransitionMode.TARGET); + Artifact srcJar = ruleContext.getPrerequisiteArtifact("srcjar"); NestedSetBuilder transitiveJavaSourceJarBuilder = NestedSetBuilder.stableOrder(); if (srcJar != null) { srcJars = ImmutableList.of(srcJar); @@ -206,8 +205,7 @@ public ConfiguredTarget create(RuleContext ruleContext) } for (JavaSourceJarsProvider other : JavaInfo.getProvidersFromListOfTargets( - JavaSourceJarsProvider.class, - ruleContext.getPrerequisites("exports", TransitionMode.TARGET))) { + JavaSourceJarsProvider.class, ruleContext.getPrerequisites("exports"))) { transitiveJavaSourceJarBuilder.addTransitive(other.getTransitiveSourceJars()); } NestedSet transitiveJavaSourceJars = transitiveJavaSourceJarBuilder.build(); @@ -269,7 +267,7 @@ private NestedSet getBootclasspath(RuleContext ruleContext) { return NestedSetBuilder.stableOrder() .addTransitive( ruleContext - .getPrerequisite("$desugar_java8_extra_bootclasspath", TransitionMode.HOST) + .getPrerequisite("$desugar_java8_extra_bootclasspath") .getProvider(FileProvider.class) .getFilesToBuild()) .add(AndroidSdkProvider.fromRuleContext(ruleContext).getAndroidJar()) @@ -297,9 +295,7 @@ private static Action[] createSingleFileExtractorActions( SpawnAction.Builder builder = new SpawnAction.Builder() .useDefaultShellEnvironment() - .setExecutable( - ruleContext.getExecutablePrerequisite( - AarImportBaseRule.ZIPPER, TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite(AarImportBaseRule.ZIPPER)) .setMnemonic("AarFileExtractor") .setProgressMessage("Extracting %s from %s", filename, aar.getFilename()) .addInput(aar) @@ -327,8 +323,7 @@ private static Action[] createAarResourcesExtractorActions( return new SpawnAction.Builder() .useDefaultShellEnvironment() .setExecutable( - ruleContext.getExecutablePrerequisite( - AarImportBaseRule.AAR_RESOURCES_EXTRACTOR, TransitionMode.HOST)) + ruleContext.getExecutablePrerequisite(AarImportBaseRule.AAR_RESOURCES_EXTRACTOR)) .setMnemonic("AarResourcesExtractor") .addInput(aar) .addOutput(resourcesDir) @@ -354,8 +349,7 @@ private static Action[] createAarEmbeddedJarsExtractorActions( return new SpawnAction.Builder() .useDefaultShellEnvironment() .setExecutable( - ruleContext.getExecutablePrerequisite( - AarImportBaseRule.AAR_EMBEDDED_JARS_EXTACTOR, TransitionMode.HOST)) + ruleContext.getExecutablePrerequisite(AarImportBaseRule.AAR_EMBEDDED_JARS_EXTACTOR)) .setMnemonic("AarEmbeddedJarsExtractor") .setProgressMessage("Extracting classes.jar and libs/*.jar from %s", aar.getFilename()) .addInput(aar) @@ -395,7 +389,7 @@ private static Action[] createAarNativeLibsFilterActions( .useDefaultShellEnvironment() .setExecutable( ruleContext.getExecutablePrerequisite( - AarImportBaseRule.AAR_NATIVE_LIBS_ZIP_CREATOR, TransitionMode.HOST)) + AarImportBaseRule.AAR_NATIVE_LIBS_ZIP_CREATOR)) .setMnemonic("AarNativeLibsFilter") .setProgressMessage("Filtering AAR native libs by architecture") .addInput(aar) @@ -415,11 +409,10 @@ private static DataBindingV2Provider createDatabindingProvider( SpecialArtifact databindingSetterStoreFiles) { Iterable> databindingProvidersFromDeps = - ruleContext.getPrerequisites("deps", TransitionMode.TARGET, DataBindingV2Provider.PROVIDER); + ruleContext.getPrerequisites("deps", DataBindingV2Provider.PROVIDER); Iterable> databindingProvidersFromExports = - ruleContext.getPrerequisites( - "exports", TransitionMode.TARGET, DataBindingV2Provider.PROVIDER); + ruleContext.getPrerequisites("exports", DataBindingV2Provider.PROVIDER); DataBindingV2Provider dataBindingV2Provider = DataBindingV2Provider.createProvider( diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidAssets.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidAssets.java index ef74fe7dbd6245..ad168fdbb49fe5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidAssets.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidAssets.java @@ -21,7 +21,6 @@ import com.google.devtools.build.lib.analysis.FileProvider; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.RuleErrorConsumer; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException; import com.google.devtools.build.lib.packages.Type; @@ -110,7 +109,7 @@ private static Iterable getAssetTargets( return null; } - return ruleContext.getPrerequisitesIf(ASSETS_ATTR, TransitionMode.TARGET, FileProvider.class); + return ruleContext.getPrerequisitesIf(ASSETS_ATTR, FileProvider.class); } @Nullable diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java index 9e3c40f59b5dbd..d08471ad5852be 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java @@ -47,7 +47,6 @@ import com.google.devtools.build.lib.analysis.RuleErrorConsumer; import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; @@ -173,10 +172,7 @@ && getMultidexMode(ruleContext) == MultidexMode.OFF) { if (ruleContext.getFragment(JavaConfiguration.class).enforceProguardFileExtension() && ruleContext.attributes().has(ProguardHelper.PROGUARD_SPECS)) { List pathsWithUnexpectedExtension = - ruleContext - .getPrerequisiteArtifacts(ProguardHelper.PROGUARD_SPECS, TransitionMode.TARGET) - .list() - .stream() + ruleContext.getPrerequisiteArtifacts(ProguardHelper.PROGUARD_SPECS).list().stream() .filter(Artifact::isSourceArtifact) .map(Artifact::getRootRelativePath) .filter( @@ -267,7 +263,6 @@ private static RuleConfiguredTargetBuilder init( AndroidApplicationResourceInfo androidApplicationResourceInfo = ruleContext.getPrerequisite( "application_resources", - TransitionMode.TARGET, AndroidApplicationResourceInfo.PROVIDER); final ResourceApk resourceApk; @@ -362,8 +357,7 @@ private static RuleConfiguredTargetBuilder init( .build(ruleContext); } - Artifact proguardMapping = - ruleContext.getPrerequisiteArtifact("proguard_apply_mapping", TransitionMode.TARGET); + Artifact proguardMapping = ruleContext.getPrerequisiteArtifact("proguard_apply_mapping"); MobileInstallResourceApks mobileInstallResourceApks = AndroidBinaryMobileInstall.createMobileInstallResourceApks( @@ -411,13 +405,11 @@ public static RuleConfiguredTargetBuilder createAndroidBinary( List proguardDeps = new ArrayList<>(); Iterables.addAll( - proguardDeps, - ruleContext.getPrerequisites("deps", TransitionMode.TARGET, ProguardSpecProvider.PROVIDER)); + proguardDeps, ruleContext.getPrerequisites("deps", ProguardSpecProvider.PROVIDER)); if (ruleContext.getConfiguration().isCodeCoverageEnabled() && ruleContext.attributes().has("$jacoco_runtime", BuildType.LABEL)) { proguardDeps.add( - ruleContext.getPrerequisite( - "$jacoco_runtime", TransitionMode.TARGET, ProguardSpecProvider.PROVIDER)); + ruleContext.getPrerequisite("$jacoco_runtime", ProguardSpecProvider.PROVIDER)); } ImmutableList proguardSpecs = getProguardSpecs( @@ -426,13 +418,9 @@ public static RuleConfiguredTargetBuilder createAndroidBinary( resourceApk.getResourceProguardConfig(), resourceApk.getManifest(), ruleContext.attributes().has(ProguardHelper.PROGUARD_SPECS, BuildType.LABEL_LIST) - ? ruleContext - .getPrerequisiteArtifacts(ProguardHelper.PROGUARD_SPECS, TransitionMode.TARGET) - .list() + ? ruleContext.getPrerequisiteArtifacts(ProguardHelper.PROGUARD_SPECS).list() : ImmutableList.of(), - ruleContext - .getPrerequisiteArtifacts(":extra_proguard_specs", TransitionMode.TARGET) - .list(), + ruleContext.getPrerequisiteArtifacts(":extra_proguard_specs").list(), proguardDeps); boolean hasProguardSpecs = !proguardSpecs.isEmpty(); @@ -508,10 +496,9 @@ public static RuleConfiguredTargetBuilder createAndroidBinary( Artifact zipAlignedApk = ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_BINARY_APK); ImmutableList signingKeys = AndroidCommon.getApkDebugSigningKeys(ruleContext); - Artifact signingLineage = - ruleContext.getPrerequisiteArtifact("debug_signing_lineage_file", TransitionMode.HOST); + Artifact signingLineage = ruleContext.getPrerequisiteArtifact("debug_signing_lineage_file"); FilesToRunProvider resourceExtractor = - ruleContext.getExecutablePrerequisite("$resource_extractor", TransitionMode.HOST); + ruleContext.getExecutablePrerequisite("$resource_extractor"); Artifact finalClassesDex; ImmutableList finalShardDexZips = dexingOutput.shardDexZips; @@ -520,17 +507,14 @@ public static RuleConfiguredTargetBuilder createAndroidBinary( Artifact java8LegacyDex; if (binaryJar.equals(jarToDex)) { // No Proguard: use canned Java 8 legacy .dex file - java8LegacyDex = - ruleContext.getPrerequisiteArtifact("$java8_legacy_dex", TransitionMode.TARGET); + java8LegacyDex = ruleContext.getPrerequisiteArtifact("$java8_legacy_dex"); } else { // Proguard is used: build custom Java 8 legacy .dex file java8LegacyDex = getDxArtifact(ruleContext, "_java8_legacy.dex.zip"); Artifact androidJar = AndroidSdkProvider.fromRuleContext(ruleContext).getAndroidJar(); ruleContext.registerAction( new SpawnAction.Builder() - .setExecutable( - ruleContext.getExecutablePrerequisite( - "$build_java8_legacy_dex", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$build_java8_legacy_dex")) .addInput(jarToDex) .addInput(androidJar) .addOutput(java8LegacyDex) @@ -552,8 +536,7 @@ public static RuleConfiguredTargetBuilder createAndroidBinary( .useDefaultShellEnvironment() .setMnemonic("AppendJava8LegacyDex") .setProgressMessage("Adding Java 8 legacy library for %s", ruleContext.getLabel()) - .setExecutable( - ruleContext.getExecutablePrerequisite("$merge_dexzips", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$merge_dexzips")) .addInput(dexPostprocessingOutput.classesDexZip()) .addInput(java8LegacyDex) .addOutput(finalClassesDex) @@ -601,8 +584,7 @@ public static RuleConfiguredTargetBuilder createAndroidBinary( // If this is an instrumentation APK, create the provider for android_instrumentation_test. if (isInstrumentation(ruleContext)) { - ApkInfo targetApkProvider = - ruleContext.getPrerequisite("instruments", TransitionMode.TARGET, ApkInfo.PROVIDER); + ApkInfo targetApkProvider = ruleContext.getPrerequisite("instruments", ApkInfo.PROVIDER); AndroidInstrumentationInfo instrumentationProvider = new AndroidInstrumentationInfo(targetApkProvider); @@ -611,7 +593,7 @@ public static RuleConfiguredTargetBuilder createAndroidBinary( // At this point, the Android manifests of both target and instrumentation APKs are finalized. FilesToRunProvider checker = - ruleContext.getExecutablePrerequisite("$instrumentation_test_check", TransitionMode.HOST); + ruleContext.getExecutablePrerequisite("$instrumentation_test_check"); Artifact targetManifest = targetApkProvider.getMergedManifest(); Artifact instrumentationManifest = resourceApk.getManifest(); Artifact checkOutput = @@ -728,7 +710,7 @@ private static Artifact getCoverageInstrumentationJarForApk(RuleContext ruleCont public static NestedSet getLibraryResourceJars(RuleContext ruleContext) { Iterable libraryResourceJarProviders = AndroidCommon.getTransitivePrerequisites( - ruleContext, TransitionMode.TARGET, AndroidLibraryResourceClassJarProvider.PROVIDER); + ruleContext, AndroidLibraryResourceClassJarProvider.PROVIDER); NestedSetBuilder libraryResourceJarsBuilder = NestedSetBuilder.naiveLinkOrder(); for (AndroidLibraryResourceClassJarProvider provider : libraryResourceJarProviders) { @@ -792,7 +774,7 @@ private static ProguardOutput applyProguard( // Proguard sees the desugared app, so it needs legacy APIs to resolve symbols libraryJars.addTransitive( ruleContext - .getPrerequisite("$desugared_java8_legacy_apis", TransitionMode.TARGET) + .getPrerequisite("$desugared_java8_legacy_apis") .getProvider(FileProvider.class) .getFilesToBuild()); } @@ -802,8 +784,7 @@ private static ProguardOutput applyProguard( ruleContext.getImplicitOutputArtifact(JavaSemantics.JAVA_BINARY_PROGUARD_SEEDS); Artifact proguardUsage = ruleContext.getImplicitOutputArtifact(JavaSemantics.JAVA_BINARY_PROGUARD_USAGE); - Artifact proguardDictionary = - ruleContext.getPrerequisiteArtifact("proguard_apply_dictionary", TransitionMode.TARGET); + Artifact proguardDictionary = ruleContext.getPrerequisiteArtifact("proguard_apply_dictionary"); ProguardOutput result = ProguardHelper.createOptimizationActions( ruleContext, @@ -1067,8 +1048,7 @@ private static DexingOutput dex( } } - Artifact mainDexList = - ruleContext.getPrerequisiteArtifact("main_dex_list", TransitionMode.TARGET); + Artifact mainDexList = ruleContext.getPrerequisiteArtifact("main_dex_list"); if ((mainDexList != null && multidexMode != MultidexMode.MANUAL_MAIN_DEX) || (mainDexList == null && multidexMode == MultidexMode.MANUAL_MAIN_DEX)) { ruleContext.throwWithRuleError( @@ -1182,8 +1162,7 @@ private static DexingOutput dex( .useDefaultShellEnvironment() .setMnemonic("MergeDexZips") .setProgressMessage("Merging dex shards for %s", ruleContext.getLabel()) - .setExecutable( - ruleContext.getExecutablePrerequisite("$merge_dexzips", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$merge_dexzips")) .addInputs(shardDexes) .addOutput(classesDex) .addCommandLine(mergeCommandLine) @@ -1399,8 +1378,7 @@ private static SpecialArtifact createSharderAction( .setMnemonic("ShardForMultidex") .setProgressMessage( "Assembling dex files for %s", ruleContext.getLabel().getCanonicalForm()) - .setExecutable( - ruleContext.getExecutablePrerequisite("$dexsharder", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$dexsharder")) .addInputs(dexArchives) .addOutput(outputTree); @@ -1442,7 +1420,7 @@ private static Artifact createTemplatedMergerActions( ruleContext.getUniqueDirectory("dexfiles"), ruleContext.getBinOrGenfilesDirectory()); SpawnActionTemplate.Builder dexmerger = new SpawnActionTemplate.Builder(inputTree, outputTree) - .setExecutable(ruleContext.getExecutablePrerequisite("$dexmerger", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$dexmerger")) .setMnemonics("DexShardsToMerge", "DexMerger") .setOutputPathMapper( (OutputPathMapper & Serializable) TreeFileArtifact::getParentRelativePath); @@ -1506,7 +1484,7 @@ private static void createDexMergerAction( SpawnAction.Builder dexmerger = new SpawnAction.Builder() .useDefaultShellEnvironment() - .setExecutable(ruleContext.getExecutablePrerequisite("$dexmerger", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$dexmerger")) .setMnemonic("DexMerger") .setProgressMessage("Assembling dex files into %s", classesDex.getRootRelativePath()) .addInputs(dexArchives) @@ -1569,8 +1547,7 @@ static AndroidRuntimeJarProvider.Builder collectDesugaredJarsFromAttributes( for (String attr : attributes) { // Use all available AndroidRuntimeJarProvider from attributes that carry runtime dependencies result.addTransitiveProviders( - ruleContext.getPrerequisites( - attr, TransitionMode.TARGET, AndroidRuntimeJarProvider.class)); + ruleContext.getPrerequisites(attr, AndroidRuntimeJarProvider.class)); } return result; } @@ -1588,8 +1565,7 @@ private static Map collectDexArchives( DexArchiveProvider.Builder result = new DexArchiveProvider.Builder(); for (String attr : semantics.getAttributesWithJavaRuntimeDeps(ruleContext)) { // Use all available DexArchiveProviders from attributes that carry runtime dependencies - result.addTransitiveProviders( - ruleContext.getPrerequisites(attr, TransitionMode.TARGET, DexArchiveProvider.class)); + result.addTransitiveProviders(ruleContext.getPrerequisites(attr, DexArchiveProvider.class)); } ImmutableSet incrementalDexopts = DexArchiveAspect.incrementalDexopts(ruleContext, dexopts); @@ -1646,8 +1622,7 @@ private static Artifact createShuffleJarActions( .useDefaultShellEnvironment() .setMnemonic("ShardClassesToDex") .setProgressMessage("Sharding classes for dexing for %s", ruleContext.getLabel()) - .setExecutable( - ruleContext.getExecutablePrerequisite("$shuffle_jars", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$shuffle_jars")) .addOutputs(shuffleOutputs) .addOutput(javaResourceJar); @@ -1804,10 +1779,7 @@ static Artifact createMainDexListAction( Artifact mainDexList = AndroidBinary.getDxArtifact(ruleContext, "main_dex_list.txt"); List proguardSpecs = new ArrayList<>(); - proguardSpecs.addAll( - ruleContext - .getPrerequisiteArtifacts("main_dex_proguard_specs", TransitionMode.TARGET) - .list()); + proguardSpecs.addAll(ruleContext.getPrerequisiteArtifacts("main_dex_proguard_specs").list()); if (proguardSpecs.isEmpty()) { proguardSpecs.add(sdk.getMainDexClasses()); } @@ -1878,8 +1850,7 @@ static Artifact createMainDexListAction( .build(ruleContext)); } else { FilesToRunProvider legacyMainDexListGenerator = - ruleContext.getExecutablePrerequisite( - ":legacy_main_dex_list_generator", TransitionMode.HOST); + ruleContext.getExecutablePrerequisite(":legacy_main_dex_list_generator"); // Use the newer legacy multidex main-dex list generation. SpawnAction.Builder actionBuilder = new SpawnAction.Builder() @@ -1893,7 +1864,7 @@ static Artifact createMainDexListAction( if (AndroidCommon.getAndroidConfig(ruleContext).desugarJava8Libs()) { NestedSet legacyApis = ruleContext - .getPrerequisite("$desugared_java8_legacy_apis", TransitionMode.TARGET) + .getPrerequisite("$desugared_java8_legacy_apis") .getProvider(FileProvider.class) .getFilesToBuild(); for (Artifact lib : legacyApis.toList()) { @@ -1934,8 +1905,7 @@ static Artifact transformDexListThroughProguardMapAction( new SpawnAction.Builder() .setMnemonic("MainDexProguardClasses") .setProgressMessage("Obfuscating main dex classes list") - .setExecutable( - ruleContext.getExecutablePrerequisite("$dex_list_obfuscator", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$dex_list_obfuscator")) .addInput(mainDexList) .addInput(proguardOutputMap) .addOutput(obfuscatedMainDexList) @@ -2013,7 +1983,7 @@ private static Artifact getFilteredDeployJar(RuleContext ruleContext, Artifact d throws InterruptedException { Artifact filterJar = ruleContext - .getPrerequisite("instruments", TransitionMode.TARGET) + .getPrerequisite("instruments") .get(AndroidPreDexJarProvider.PROVIDER) .getPreDexJar(); Artifact filteredDeployJar = diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinaryMobileInstall.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinaryMobileInstall.java index 76c6804a17dbaf..e959973c34b38b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinaryMobileInstall.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinaryMobileInstall.java @@ -26,7 +26,6 @@ import com.google.devtools.build.lib.analysis.FilesToRunProvider; import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; import com.google.devtools.build.lib.analysis.actions.SpawnAction; @@ -130,9 +129,7 @@ static void addMobileInstall( .setMnemonic("AndroidDexManifest") .setProgressMessage( "Generating incremental installation manifest for %s", ruleContext.getLabel()) - .setExecutable( - ruleContext.getExecutablePrerequisite( - "$build_incremental_dexmanifest", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$build_incremental_dexmanifest")) .addOutput(incrementalDexManifest) .addInputs(shardDexZips) .addCommandLine( @@ -251,8 +248,7 @@ static void addMobileInstall( .useDefaultShellEnvironment() .setMnemonic("AndroidStripResources") .setProgressMessage("Stripping resources from split main apk") - .setExecutable( - ruleContext.getExecutablePrerequisite("$strip_resources", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$strip_resources")) .addInput(resourceApk.getArtifact()) .addOutput(splitMainApkResources) .addCommandLine( @@ -331,7 +327,7 @@ private static Artifact getStubDex( String attribute = split ? "$incremental_split_stub_application" : "$incremental_stub_application"; - TransitiveInfoCollection dep = ruleContext.getPrerequisite(attribute, TransitionMode.TARGET); + TransitiveInfoCollection dep = ruleContext.getPrerequisite(attribute); if (dep == null) { ruleContext.attributeError(attribute, "Stub application cannot be found"); return null; @@ -390,8 +386,7 @@ private static void createInstallAction( SpawnAction.Builder builder = new SpawnAction.Builder() .useDefaultShellEnvironment() - .setExecutable( - ruleContext.getExecutablePrerequisite("$incremental_install", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$incremental_install")) // We cannot know if the user connected a new device, uninstalled the app from the // device // or did anything strange to it, so we always run this action. @@ -443,8 +438,7 @@ private static void createSplitInstallAction( SpawnAction.Builder builder = new SpawnAction.Builder() .useDefaultShellEnvironment() - .setExecutable( - ruleContext.getExecutablePrerequisite("$incremental_install", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$incremental_install")) .addTool(adb) .executeUnconditionally() .setMnemonic("AndroidInstall") diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java index 2d724579ba5914..ca80033b77f39d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java @@ -256,7 +256,7 @@ public static AndroidIdeInfoProvider createAndroidIdeInfoProvider( .setDefinesAndroidResources(true) // Sets the possibly merged manifest and the raw manifest. .setGeneratedManifest(resourceApk.getManifest()) - .setManifest(ruleContext.getPrerequisiteArtifact("manifest", TransitionMode.TARGET)) + .setManifest(ruleContext.getPrerequisiteArtifact("manifest")) .setJavaPackage(getJavaPackage(ruleContext)) .setResourceApk(resourceApk.getArtifact()); } @@ -359,8 +359,7 @@ static PathFragment trimTo(PathFragment haystack, PathFragment needle) { public static NestedSetBuilder collectTransitiveNativeLibs(RuleContext ruleContext) { NestedSetBuilder transitiveNativeLibs = NestedSetBuilder.naiveLinkOrder(); Iterable infos = - getTransitivePrerequisites( - ruleContext, TransitionMode.TARGET, AndroidNativeLibsInfo.PROVIDER); + getTransitivePrerequisites(ruleContext, AndroidNativeLibsInfo.PROVIDER); for (AndroidNativeLibsInfo nativeLibsZipsInfo : infos) { transitiveNativeLibs.addTransitive(nativeLibsZipsInfo.getNativeLibs()); } @@ -386,7 +385,7 @@ static boolean getExportsManifest(RuleContext ruleContext) { /** Returns the artifact for the debug key for signing the APK. */ static ImmutableList getApkDebugSigningKeys(RuleContext ruleContext) { ImmutableList keys = - ruleContext.getPrerequisiteArtifacts("debug_signing_keys", TransitionMode.HOST).list(); + ruleContext.getPrerequisiteArtifacts("debug_signing_keys").list(); if (!keys.isEmpty()) { return keys; } @@ -452,8 +451,7 @@ public JavaTargetAttributes init( NestedSetBuilder bootclasspath = NestedSetBuilder.stableOrder(); if (getAndroidConfig(ruleContext).desugarJava8()) { bootclasspath.addTransitive( - PrerequisiteArtifacts.nestedSet( - ruleContext, "$desugar_java8_extra_bootclasspath", TransitionMode.HOST)); + PrerequisiteArtifacts.nestedSet(ruleContext, "$desugar_java8_extra_bootclasspath")); } bootclasspath.add(androidSdkProvider.getAndroidJar()); bootClassPathInfo = BootClassPathInfo.create(bootclasspath.build()); @@ -843,8 +841,7 @@ public static AndroidConfiguration getAndroidConfig(RuleContext context) { private NestedSet collectHiddenTopLevelArtifacts(RuleContext ruleContext) { NestedSetBuilder builder = NestedSetBuilder.stableOrder(); for (OutputGroupInfo provider : - getTransitivePrerequisites( - ruleContext, TransitionMode.TARGET, OutputGroupInfo.STARLARK_CONSTRUCTOR)) { + getTransitivePrerequisites(ruleContext, OutputGroupInfo.STARLARK_CONSTRUCTOR)) { builder.addTransitive(provider.getOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL)); } return builder.build(); @@ -864,8 +861,7 @@ static JavaCommon createJavaCommonWithAndroidDataBinding( DataBindingContext dataBindingContext, boolean isLibrary) { - ImmutableList ruleSources = - ruleContext.getPrerequisiteArtifacts("srcs", TransitionMode.TARGET).list(); + ImmutableList ruleSources = ruleContext.getPrerequisiteArtifacts("srcs").list(); ImmutableList dataBindingSources = dataBindingContext.getAnnotationSourceFiles(ruleContext); @@ -886,8 +882,7 @@ static JavaCommon createJavaCommonWithAndroidDataBinding( bothDeps = JavaCommon.defaultDeps(ruleContext, semantics, ClasspathType.BOTH); } else { // Binary: - compileDeps = - ImmutableList.copyOf(ruleContext.getPrerequisites("deps", TransitionMode.TARGET)); + compileDeps = ImmutableList.copyOf(ruleContext.getPrerequisites("deps")); runtimeDeps = compileDeps; bothDeps = compileDeps; } @@ -901,8 +896,7 @@ static JavaCommon createJavaCommonWithAndroidDataBinding( */ static NestedSet getSupportApks(RuleContext ruleContext) { NestedSetBuilder supportApks = NestedSetBuilder.stableOrder(); - for (TransitiveInfoCollection dep : - ruleContext.getPrerequisites("support_apks", TransitionMode.TARGET)) { + for (TransitiveInfoCollection dep : ruleContext.getPrerequisites("support_apks")) { ApkInfo apkProvider = dep.get(ApkInfo.PROVIDER); FileProvider fileProvider = dep.getProvider(FileProvider.class); // If ApkInfo is present, do not check FileProvider for .apk files. For example, diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataContext.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataContext.java index 3bab0e6f4f0ca9..bdfed2092dbf86 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataContext.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDataContext.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.FilesToRunProvider; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.RuleErrorConsumer; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext; import com.google.devtools.build.lib.analysis.actions.SpawnAction; import com.google.devtools.build.lib.cmdline.Label; @@ -80,7 +79,7 @@ public static AndroidDataContext makeContext(RuleContext ruleContext) { return new AndroidDataContext( ruleContext, - ruleContext.getExecutablePrerequisite("$android_resources_busybox", TransitionMode.HOST), + ruleContext.getExecutablePrerequisite("$android_resources_busybox"), androidConfig.persistentBusyboxTools(), AndroidSdkProvider.fromRuleContext(ruleContext), hasExemption(ruleContext, "allow_raw_access_to_resource_paths", false), diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java index 6724236dd77dea..7d32a0d461ed5f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java @@ -36,7 +36,6 @@ import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.RunfilesProvider; import com.google.devtools.build.lib.analysis.RunfilesSupport; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; import com.google.devtools.build.lib.analysis.actions.SpawnAction; @@ -211,26 +210,20 @@ private AndroidDeviceRuleAttributes( vmHeap = ruleContext.attributes().get("vm_heap", Type.INTEGER); defaultProperties = - Optional.fromNullable( - ruleContext.getPrerequisiteArtifact("default_properties", TransitionMode.HOST)); - adb = ruleContext.getPrerequisiteArtifact("$adb", TransitionMode.HOST); - emulatorArm = ruleContext.getPrerequisiteArtifact("$emulator_arm", TransitionMode.HOST); - emulatorX86 = ruleContext.getPrerequisiteArtifact("$emulator_x86", TransitionMode.HOST); - adbStatic = ruleContext.getPrerequisiteArtifact("$adb_static", TransitionMode.HOST); - emulatorX86Bios = - ruleContext.getPrerequisiteArtifacts("$emulator_x86_bios", TransitionMode.HOST).list(); - xvfbSupportFiles = - ruleContext.getPrerequisiteArtifacts("$xvfb_support", TransitionMode.HOST).list(); - mksdcard = ruleContext.getPrerequisiteArtifact("$mksd", TransitionMode.HOST); - snapshotFs = ruleContext.getPrerequisiteArtifact("$empty_snapshot_fs", TransitionMode.HOST); - unifiedLauncher = - ruleContext.getExecutablePrerequisite("$unified_launcher", TransitionMode.HOST); - androidRuntestDeps = - ruleContext.getPrerequisiteArtifacts("$android_runtest", TransitionMode.HOST).list(); + Optional.fromNullable(ruleContext.getPrerequisiteArtifact("default_properties")); + adb = ruleContext.getPrerequisiteArtifact("$adb"); + emulatorArm = ruleContext.getPrerequisiteArtifact("$emulator_arm"); + emulatorX86 = ruleContext.getPrerequisiteArtifact("$emulator_x86"); + adbStatic = ruleContext.getPrerequisiteArtifact("$adb_static"); + emulatorX86Bios = ruleContext.getPrerequisiteArtifacts("$emulator_x86_bios").list(); + xvfbSupportFiles = ruleContext.getPrerequisiteArtifacts("$xvfb_support").list(); + mksdcard = ruleContext.getPrerequisiteArtifact("$mksd"); + snapshotFs = ruleContext.getPrerequisiteArtifact("$empty_snapshot_fs"); + unifiedLauncher = ruleContext.getExecutablePrerequisite("$unified_launcher"); + androidRuntestDeps = ruleContext.getPrerequisiteArtifacts("$android_runtest").list(); androidRuntest = androidRuntestDeps.stream().filter(Artifact::isSourceArtifact).collect(onlyElement()); - testingShbaseDeps = - ruleContext.getPrerequisiteArtifacts("$testing_shbase", TransitionMode.HOST).list(); + testingShbaseDeps = ruleContext.getPrerequisiteArtifacts("$testing_shbase").list(); testingShbase = testingShbaseDeps .stream() @@ -239,12 +232,11 @@ private AndroidDeviceRuleAttributes( .collect(onlyElement()); // may be empty - platformApks = - ruleContext.getPrerequisiteArtifacts("platform_apks", TransitionMode.TARGET).list(); - sdkPath = ruleContext.getPrerequisiteArtifact("$sdk_path", TransitionMode.HOST); + platformApks = ruleContext.getPrerequisiteArtifacts("platform_apks").list(); + sdkPath = ruleContext.getPrerequisiteArtifact("$sdk_path"); TransitiveInfoCollection systemImagesAndSourceProperties = - ruleContext.getPrerequisite("system_image", TransitionMode.TARGET); + ruleContext.getPrerequisite("system_image"); if (ruleContext.hasErrors()) { return; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceScriptFixture.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceScriptFixture.java index b9bee36b11a348..cff3a7e54ca9bd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceScriptFixture.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceScriptFixture.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.FileWriteAction; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; @@ -70,7 +69,7 @@ private static Artifact getFixtureScript(RuleContext ruleContext) if (ruleContext.attributes().isAttributeValueExplicitlySpecified("cmd")) { cmd = ruleContext.attributes().get("cmd", Type.STRING); } - TransitiveInfoCollection script = ruleContext.getPrerequisite("script", TransitionMode.TARGET); + TransitiveInfoCollection script = ruleContext.getPrerequisite("script"); if (((cmd == null) && (script == null)) || ((cmd != null) && (script != null))) { ruleContext.throwWithRuleError( diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidFeatureFlagSetProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidFeatureFlagSetProvider.java index 9ee7520280bbb9..ac09a67df56f29 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidFeatureFlagSetProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidFeatureFlagSetProvider.java @@ -20,7 +20,6 @@ import com.google.devtools.build.lib.analysis.AliasProvider; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; @@ -102,7 +101,7 @@ public static Optional> getAndValidateFlagMapFromRul } Iterable actualTargets = - ruleContext.getPrerequisites(FEATURE_FLAG_ATTR, TransitionMode.TARGET); + ruleContext.getPrerequisites(FEATURE_FLAG_ATTR); RuleErrorException exception = null; for (TransitiveInfoCollection target : actualTargets) { Label label = AliasProvider.getDependencyLabel(target); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidHostServiceFixture.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidHostServiceFixture.java index d0339dad501146..ac5711190df887 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidHostServiceFixture.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidHostServiceFixture.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.packages.Type; @@ -42,8 +41,7 @@ public ConfiguredTarget create(RuleContext ruleContext) androidSemantics.checkForMigrationTag(ruleContext); RuleConfiguredTargetBuilder ruleBuilder = new RuleConfiguredTargetBuilder(ruleContext); NestedSet supportApks = AndroidCommon.getSupportApks(ruleContext); - FilesToRunProvider executable = - ruleContext.getExecutablePrerequisite("executable", TransitionMode.HOST); + FilesToRunProvider executable = ruleContext.getExecutablePrerequisite("executable"); NestedSet filesToBuild = NestedSetBuilder.stableOrder() diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidIdlHelper.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidIdlHelper.java index d3e01ea3d23a79..7baa6cf3c3befd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidIdlHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidIdlHelper.java @@ -21,7 +21,6 @@ import com.google.devtools.build.lib.analysis.OutputGroupInfo; import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; import com.google.devtools.build.lib.analysis.actions.SpawnAction; @@ -208,7 +207,7 @@ private static ImmutableList getIdlParcelables(RuleContext ruleContext return ruleContext.getRule().isAttrDefined("idl_parcelables", BuildType.LABEL_LIST) ? ImmutableList.copyOf( ruleContext - .getPrerequisiteArtifacts("idl_parcelables", TransitionMode.TARGET) + .getPrerequisiteArtifacts("idl_parcelables") .filter(AndroidRuleClasses.ANDROID_IDL) .list()) : ImmutableList.of(); @@ -221,7 +220,7 @@ private static Collection getIdlSrcs(RuleContext ruleContext) { } checkIdlSrcsSamePackage(ruleContext); return ruleContext - .getPrerequisiteArtifacts("idl_srcs", TransitionMode.TARGET) + .getPrerequisiteArtifacts("idl_srcs") .filter(AndroidRuleClasses.ANDROID_IDL) .list(); } @@ -233,7 +232,7 @@ private static void checkIdlSrcsSamePackage(RuleContext ruleContext) { PathFragment packageName = ruleContext.getLabel().getPackageFragment(); Collection idls = ruleContext - .getPrerequisiteArtifacts("idl_srcs", TransitionMode.TARGET) + .getPrerequisiteArtifacts("idl_srcs") .filter(AndroidRuleClasses.ANDROID_IDL) .list(); for (Artifact idl : idls) { @@ -342,7 +341,7 @@ private static void createIdlClassJarAction( .addInputs(generatedIdlJavaFiles) .addOutput(idlClassJar) .addOutput(idlSourceJar) - .setExecutable(ruleContext.getExecutablePrerequisite("$idlclass", TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite("$idlclass")) .addCommandLine( CustomCommandLine.builder() .addExecPath("--manifest_proto", manifestProtoOutput) @@ -432,8 +431,7 @@ private static AndroidIdlProvider createAndroidIdlProvider( } for (AndroidIdlProvider dep : - AndroidCommon.getTransitivePrerequisites( - ruleContext, TransitionMode.TARGET, AndroidIdlProvider.PROVIDER)) { + AndroidCommon.getTransitivePrerequisites(ruleContext, AndroidIdlProvider.PROVIDER)) { rootsBuilder.addTransitive(dep.getTransitiveIdlImportRoots()); importsBuilder.addTransitive(dep.getTransitiveIdlImports()); preprocessedBuilder.addTransitive(dep.getTransitiveIdlPreprocessed()); @@ -506,7 +504,7 @@ private static String getIdlImportRoot(RuleContext ruleContext) { private static Collection getIdlPreprocessed(RuleContext ruleContext) { return ruleContext.isAttrDefined("idl_preprocessed", BuildType.LABEL_LIST) ? ruleContext - .getPrerequisiteArtifacts("idl_preprocessed", TransitionMode.TARGET) + .getPrerequisiteArtifacts("idl_preprocessed") .filter(AndroidRuleClasses.ANDROID_IDL) .list() : ImmutableList.of(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestBase.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestBase.java index dd349f94083c79..eb4ea210c71b7c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestBase.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestBase.java @@ -27,7 +27,6 @@ import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.RunfilesProvider; import com.google.devtools.build.lib.analysis.RunfilesSupport; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.Substitution; import com.google.devtools.build.lib.analysis.actions.Template; @@ -79,9 +78,9 @@ public ConfiguredTarget create(RuleContext ruleContext) ImmutableList runfilesDeps = ImmutableList.builder() - .addAll(ruleContext.getPrerequisites("fixtures", TransitionMode.TARGET)) - .add(ruleContext.getPrerequisite("target_device", TransitionMode.HOST)) - .add(ruleContext.getPrerequisite("$test_entry_point", TransitionMode.HOST)) + .addAll(ruleContext.getPrerequisites("fixtures")) + .add(ruleContext.getPrerequisite("target_device")) + .add(ruleContext.getPrerequisite("$test_entry_point")) .build(); Runfiles runfiles = @@ -203,13 +202,12 @@ private static Substitution artifactListSubstitution(String key, List @Nullable private static AndroidInstrumentationInfo getInstrumentationProvider(RuleContext ruleContext) { - return ruleContext.getPrerequisite( - "test_app", TransitionMode.TARGET, AndroidInstrumentationInfo.PROVIDER); + return ruleContext.getPrerequisite("test_app", AndroidInstrumentationInfo.PROVIDER); } @Nullable private static ApkInfo getApkProvider(RuleContext ruleContext) { - return ruleContext.getPrerequisite("test_app", TransitionMode.TARGET, ApkInfo.PROVIDER); + return ruleContext.getPrerequisite("test_app", ApkInfo.PROVIDER); } /** The target APK from the {@code android_binary} in the {@code instrumentation} attribute. */ @@ -235,14 +233,12 @@ private static NestedSet getAllSupportApks(RuleContext ruleContext) { for (AndroidDeviceScriptFixtureInfoProvider fixture : ruleContext.getPrerequisites( "fixtures", - TransitionMode.TARGET, AndroidDeviceScriptFixtureInfoProvider.STARLARK_CONSTRUCTOR)) { allSupportApks.addTransitive(fixture.getSupportApks()); } for (AndroidHostServiceFixtureInfoProvider fixture : ruleContext.getPrerequisites( "fixtures", - TransitionMode.TARGET, AndroidHostServiceFixtureInfoProvider.ANDROID_HOST_SERVICE_FIXTURE_INFO)) { allSupportApks.addTransitive(fixture.getSupportApks()); } @@ -251,12 +247,12 @@ private static NestedSet getAllSupportApks(RuleContext ruleContext) { /** The deploy jar that interacts with the device. */ private static FilesToRunProvider getTestEntryPoint(RuleContext ruleContext) { - return ruleContext.getExecutablePrerequisite("$test_entry_point", TransitionMode.HOST); + return ruleContext.getExecutablePrerequisite("$test_entry_point"); } /** The {@code android_device} script to launch an emulator for the test. */ private static FilesToRunProvider getTargetDevice(RuleContext ruleContext) { - return ruleContext.getExecutablePrerequisite("target_device", TransitionMode.HOST); + return ruleContext.getExecutablePrerequisite("target_device"); } /** ADB binary from the Android SDK. */ @@ -270,7 +266,7 @@ private static FilesToRunProvider getAapt(RuleContext ruleContext) { } private static ImmutableList getDataDeps(RuleContext ruleContext) { - return ruleContext.getPrerequisiteArtifacts("data", TransitionMode.DONT_CHECK).list(); + return ruleContext.getPrerequisiteArtifacts("data").list(); } /** @@ -285,7 +281,6 @@ private static AndroidHostServiceFixtureInfoProvider getHostServiceFixture( ImmutableList.copyOf( ruleContext.getPrerequisites( "fixtures", - TransitionMode.TARGET, AndroidHostServiceFixtureInfoProvider.ANDROID_HOST_SERVICE_FIXTURE_INFO)); if (hostServiceFixtures.size() > 1) { ruleContext.ruleError( @@ -298,13 +293,12 @@ private static Iterable getDeviceScriptF RuleContext ruleContext) { return ruleContext.getPrerequisites( "fixtures", - TransitionMode.TARGET, AndroidDeviceScriptFixtureInfoProvider.STARLARK_CONSTRUCTOR); } private static String getDeviceBrokerType(RuleContext ruleContext) { return ruleContext - .getPrerequisite("target_device", TransitionMode.HOST, AndroidDeviceBrokerInfo.PROVIDER) + .getPrerequisite("target_device", AndroidDeviceBrokerInfo.PROVIDER) .getDeviceBrokerType(); } @@ -336,7 +330,7 @@ private static String getTestSuitePropertyName(RuleContext ruleContext) */ private static ExecutionInfo getExecutionInfoProvider(RuleContext ruleContext) { ExecutionInfo executionInfo = - ruleContext.getPrerequisite("target_device", TransitionMode.HOST, ExecutionInfo.PROVIDER); + ruleContext.getPrerequisite("target_device", ExecutionInfo.PROVIDER); ImmutableMap executionRequirements = (executionInfo != null) ? executionInfo.getExecutionInfo() : ImmutableMap.of(); return new ExecutionInfo(executionRequirements); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java index 903316c407e2aa..39b570eb4da785 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.packages.AttributeMap; @@ -264,7 +263,7 @@ private NestedSetBuilder collectTransitiveResourceJars(RuleContext rul NestedSetBuilder builder = NestedSetBuilder.naiveLinkOrder(); Iterable providers = AndroidCommon.getTransitivePrerequisites( - ruleContext, TransitionMode.TARGET, AndroidLibraryResourceClassJarProvider.PROVIDER); + ruleContext, AndroidLibraryResourceClassJarProvider.PROVIDER); for (AndroidLibraryResourceClassJarProvider resourceJarProvider : providers) { builder.addTransitive(resourceJarProvider.getResourceClassJars()); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarInfo.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarInfo.java index c09d1fb3155fff..51e093ee7a4d02 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarInfo.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibraryAarInfo.java @@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.collect.nestedset.Depset; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; @@ -165,8 +164,7 @@ static Aar makeAar( public AndroidLibraryAarInfo toProvider( RuleContext ruleContext, boolean definesLocalResources) { return toProvider( - AndroidCommon.getTransitivePrerequisites(ruleContext, TransitionMode.TARGET, PROVIDER), - definesLocalResources); + AndroidCommon.getTransitivePrerequisites(ruleContext, PROVIDER), definesLocalResources); } public AndroidLibraryAarInfo toProvider( diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java index a3438ce79307ee..6be25d3211ec1c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java @@ -28,7 +28,6 @@ import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.RunfilesProvider; import com.google.devtools.build.lib.analysis.RunfilesSupport; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.Substitution; import com.google.devtools.build.lib.analysis.actions.Template; @@ -425,10 +424,8 @@ private Runfiles collectDefaultRunfiles( ImmutableList depsForRunfiles = ImmutableList.builder() - .addAll( - ruleContext.getPrerequisites( - "$robolectric_implicit_classpath", TransitionMode.TARGET)) - .addAll(ruleContext.getPrerequisites("runtime_deps", TransitionMode.TARGET)) + .addAll(ruleContext.getPrerequisites("$robolectric_implicit_classpath")) + .addAll(ruleContext.getPrerequisites("runtime_deps")) .build(); Artifact androidAllJarsPropertiesFile = getAndroidAllJarsPropertiesFile(ruleContext); @@ -528,7 +525,7 @@ static ResourceApk buildResourceApk( private static NestedSet getLibraryResourceJars(RuleContext ruleContext) { Iterable libraryResourceJarProviders = AndroidCommon.getTransitivePrerequisites( - ruleContext, TransitionMode.TARGET, AndroidLibraryResourceClassJarProvider.PROVIDER); + ruleContext, AndroidLibraryResourceClassJarProvider.PROVIDER); NestedSetBuilder libraryResourceJarsBuilder = NestedSetBuilder.naiveLinkOrder(); for (AndroidLibraryResourceClassJarProvider provider : libraryResourceJarProviders) { @@ -581,13 +578,12 @@ private JavaCompilationHelper getJavaCompilationHelperWithDependencies( if (ruleContext.isAttrDefined("$junit", BuildType.LABEL)) { // JUnit jar must be ahead of android runtime jars since these contain stubbed definitions // for framework.junit.* classes which Robolectric does not re-write. - javaCompilationHelper.addLibrariesToAttributes( - ruleContext.getPrerequisites("$junit", TransitionMode.TARGET)); + javaCompilationHelper.addLibrariesToAttributes(ruleContext.getPrerequisites("$junit")); } // Robolectric jars must be ahead of other potentially conflicting jars // (e.g., Android runtime jars) in the classpath to make sure they always take precedence. javaCompilationHelper.addLibrariesToAttributes( - ruleContext.getPrerequisites("$robolectric_implicit_classpath", TransitionMode.TARGET)); + ruleContext.getPrerequisites("$robolectric_implicit_classpath")); javaCompilationHelper.addLibrariesToAttributes( javaCommon.targetsTreatedAsDeps(ClasspathType.COMPILE_ONLY)); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidManifest.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidManifest.java index aebf0426b40172..ed9d097fa7a56d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidManifest.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidManifest.java @@ -20,7 +20,6 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.RuleErrorConsumer; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext; import com.google.devtools.build.lib.analysis.actions.SymlinkAction; import com.google.devtools.build.lib.cmdline.Label; @@ -82,7 +81,7 @@ public static AndroidManifest fromAttributes( Artifact rawManifest = null; if (AndroidResources.definesAndroidResources(ruleContext.attributes())) { AndroidResources.validateRuleContext(ruleContext); - rawManifest = ruleContext.getPrerequisiteArtifact("manifest", TransitionMode.TARGET); + rawManifest = ruleContext.getPrerequisiteArtifact("manifest"); } return from( diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidManifestMergeHelper.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidManifestMergeHelper.java index 06b0ddbf16b740..89df73e37800fe 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidManifestMergeHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidManifestMergeHelper.java @@ -15,7 +15,6 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; @@ -34,7 +33,7 @@ public static void createMergeManifestAction( Artifact mergedManifest) { createMergeManifestAction( ruleContext, - ruleContext.getPrerequisite("$android_manifest_merge_tool", TransitionMode.HOST), + ruleContext.getPrerequisite("$android_manifest_merge_tool"), merger, mergees, excludePermissions, diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidNeverlinkAspect.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidNeverlinkAspect.java index e1821d6a34cf4f..345451415eec02 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidNeverlinkAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidNeverlinkAspect.java @@ -19,7 +19,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredAspect; import com.google.devtools.build.lib.analysis.ConfiguredAspectFactory; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.packages.AspectDefinition; @@ -69,7 +68,7 @@ public ConfiguredAspect create( continue; } - deps.addAll(ruleContext.getPrerequisites(attribute, TransitionMode.TARGET)); + deps.addAll(ruleContext.getPrerequisites(attribute)); } NestedSetBuilder runtimeJars = NestedSetBuilder.naiveLinkOrder(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResources.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResources.java index b3a5ec41d76999..b091e5315816aa 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResources.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResources.java @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.analysis.FileProvider; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.RuleErrorConsumer; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException; import com.google.devtools.build.lib.rules.android.databinding.DataBindingContext; @@ -108,7 +107,7 @@ public static void validateRuleContext(RuleContext ruleContext) throws RuleError private static void validateNoAndroidResourcesInSources(RuleContext ruleContext) throws RuleErrorException { Iterable resources = - ruleContext.getPrerequisites("srcs", TransitionMode.TARGET, AndroidResourcesInfo.PROVIDER); + ruleContext.getPrerequisites("srcs", AndroidResourcesInfo.PROVIDER); for (AndroidResourcesInfo info : resources) { ruleContext.throwWithAttributeError( "srcs", @@ -117,7 +116,7 @@ private static void validateNoAndroidResourcesInSources(RuleContext ruleContext) } private static void validateManifest(RuleContext ruleContext) throws RuleErrorException { - if (ruleContext.getPrerequisiteArtifact("manifest", TransitionMode.TARGET) == null) { + if (ruleContext.getPrerequisiteArtifact("manifest") == null) { ruleContext.throwWithAttributeError( "manifest", "manifest is required when resource_files or assets are defined."); } @@ -131,7 +130,7 @@ public static AndroidResources from(RuleContext ruleContext, String resourcesAtt return from( ruleContext, - ruleContext.getPrerequisites(resourcesAttr, TransitionMode.TARGET, FileProvider.class), + ruleContext.getPrerequisites(resourcesAttr, FileProvider.class), resourcesAttr); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkBase.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkBase.java index b0f6a65c0cde7e..8d0f2d915faf24 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkBase.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkBase.java @@ -21,7 +21,6 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; @@ -47,36 +46,29 @@ public ConfiguredTarget create(RuleContext ruleContext) // rule. Otherwise, use what they told us to. FilesToRunProvider proguard = ruleContext.getFragment(JavaConfiguration.class).getProguardBinary() == null - ? ruleContext.getExecutablePrerequisite("proguard", TransitionMode.HOST) - : ruleContext.getExecutablePrerequisite(":proguard", TransitionMode.HOST); + ? ruleContext.getExecutablePrerequisite("proguard") + : ruleContext.getExecutablePrerequisite(":proguard"); String buildToolsVersion = AggregatingAttributeMapper.of(ruleContext.getRule()) .get("build_tools_version", Type.STRING); - FilesToRunProvider aidl = ruleContext.getExecutablePrerequisite("aidl", TransitionMode.HOST); - FilesToRunProvider aapt = ruleContext.getExecutablePrerequisite("aapt", TransitionMode.HOST); - FilesToRunProvider aapt2 = ruleContext.getExecutablePrerequisite("aapt2", TransitionMode.HOST); - FilesToRunProvider apkBuilder = - ruleContext.getExecutablePrerequisite("apkbuilder", TransitionMode.HOST); - FilesToRunProvider apkSigner = - ruleContext.getExecutablePrerequisite("apksigner", TransitionMode.HOST); + FilesToRunProvider aidl = ruleContext.getExecutablePrerequisite("aidl"); + FilesToRunProvider aapt = ruleContext.getExecutablePrerequisite("aapt"); + FilesToRunProvider aapt2 = ruleContext.getExecutablePrerequisite("aapt2"); + FilesToRunProvider apkBuilder = ruleContext.getExecutablePrerequisite("apkbuilder"); + FilesToRunProvider apkSigner = ruleContext.getExecutablePrerequisite("apksigner"); - FilesToRunProvider adb = ruleContext.getExecutablePrerequisite("adb", TransitionMode.HOST); - FilesToRunProvider dx = ruleContext.getExecutablePrerequisite("dx", TransitionMode.HOST); + FilesToRunProvider adb = ruleContext.getExecutablePrerequisite("adb"); + FilesToRunProvider dx = ruleContext.getExecutablePrerequisite("dx"); FilesToRunProvider mainDexListCreator = - ruleContext.getExecutablePrerequisite("main_dex_list_creator", TransitionMode.HOST); - FilesToRunProvider zipalign = - ruleContext.getExecutablePrerequisite("zipalign", TransitionMode.HOST); - Artifact frameworkAidl = - ruleContext.getPrerequisiteArtifact("framework_aidl", TransitionMode.HOST); - TransitiveInfoCollection aidlLib = - ruleContext.getPrerequisite("aidl_lib", TransitionMode.TARGET); - Artifact androidJar = ruleContext.getPrerequisiteArtifact("android_jar", TransitionMode.HOST); + ruleContext.getExecutablePrerequisite("main_dex_list_creator"); + FilesToRunProvider zipalign = ruleContext.getExecutablePrerequisite("zipalign"); + Artifact frameworkAidl = ruleContext.getPrerequisiteArtifact("framework_aidl"); + TransitiveInfoCollection aidlLib = ruleContext.getPrerequisite("aidl_lib"); + Artifact androidJar = ruleContext.getPrerequisiteArtifact("android_jar"); Artifact sourceProperties = ruleContext.getHostPrerequisiteArtifact("source_properties"); - Artifact shrinkedAndroidJar = - ruleContext.getPrerequisiteArtifact("shrinked_android_jar", TransitionMode.HOST); - Artifact mainDexClasses = - ruleContext.getPrerequisiteArtifact("main_dex_classes", TransitionMode.HOST); + Artifact shrinkedAndroidJar = ruleContext.getPrerequisiteArtifact("shrinked_android_jar"); + Artifact mainDexClasses = ruleContext.getPrerequisiteArtifact("main_dex_classes"); if (ruleContext.hasErrors()) { return null; diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java index 72c535ce520989..51027e9a3726c9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java @@ -18,7 +18,6 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.FilesToRunProvider; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.packages.BuiltinProvider; @@ -100,8 +99,7 @@ public AndroidSdkProvider( * not specified. */ public static AndroidSdkProvider fromRuleContext(RuleContext ruleContext) { - return ruleContext.getPrerequisite( - ":android_sdk", TransitionMode.TARGET, AndroidSdkProvider.PROVIDER); + return ruleContext.getPrerequisite(":android_sdk", AndroidSdkProvider.PROVIDER); } /** Throws an error if the Android SDK cannot be found. */ diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java b/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java index 101fb1b8cafc27..a9202b27cff5cd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java @@ -16,7 +16,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; @@ -41,8 +40,7 @@ public class AssetDependencies { public static AssetDependencies fromRuleDeps(RuleContext ruleContext, boolean neverlink) { return fromProviders( - AndroidCommon.getTransitivePrerequisites( - ruleContext, TransitionMode.TARGET, AndroidAssetsInfo.PROVIDER), + AndroidCommon.getTransitivePrerequisites(ruleContext, AndroidAssetsInfo.PROVIDER), neverlink); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java b/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java index 26062d8b0431e2..d2acd2e69e0364 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java @@ -39,7 +39,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredAspectFactory; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg; @@ -294,7 +293,7 @@ private Function desugarJarsIfRequested( private static Iterable getProducedRuntimeJars( ConfiguredTarget base, RuleContext ruleContext) { if (isProtoLibrary(ruleContext)) { - if (!ruleContext.getPrerequisites("srcs", TransitionMode.TARGET).isEmpty()) { + if (!ruleContext.getPrerequisites("srcs").isEmpty()) { JavaRuleOutputJarsProvider outputJarsProvider = base.getProvider(JavaRuleOutputJarsProvider.class); if (outputJarsProvider != null) { @@ -365,7 +364,7 @@ private static Iterable collectPrerequisit IterablesChain.Builder result = IterablesChain.builder(); for (String attr : TRANSITIVE_ATTRIBUTES) { if (ruleContext.attributes().getAttributeType(attr) != null) { - result.add(ruleContext.getPrerequisites(attr, TransitionMode.TARGET, classType)); + result.add(ruleContext.getPrerequisites(attr, classType)); } } return result.build(); @@ -381,7 +380,6 @@ private static NestedSet getBootclasspath( ruleContext .getPrerequisite( ":dex_archive_android_sdk", - TransitionMode.TARGET, AndroidSdkProvider.PROVIDER) .getAndroidJar()) .build(); @@ -449,8 +447,7 @@ private static Artifact createDesugarAction( ruleContext.registerAction( new SpawnAction.Builder() .useDefaultShellEnvironment() - .setExecutable( - ruleContext.getExecutablePrerequisite(desugarPrereqName, TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite(desugarPrereqName)) .addInput(jar) .addTransitiveInputs(bootclasspath) .addTransitiveInputs(classpath) @@ -487,8 +484,7 @@ static Artifact createDexArchiveAction( SpawnAction.Builder dexbuilder = new SpawnAction.Builder() .useDefaultShellEnvironment() - .setExecutable( - ruleContext.getExecutablePrerequisite(dexbuilderPrereq, TransitionMode.HOST)) + .setExecutable(ruleContext.getExecutablePrerequisite(dexbuilderPrereq)) // WorkerSpawnStrategy expects the last argument to be @paramfile .addInput(jar) .addOutput(dexArchive) diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ProguardHelper.java b/src/main/java/com/google/devtools/build/lib/rules/android/ProguardHelper.java index e1f7d204863350..3f2166d254a07f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ProguardHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ProguardHelper.java @@ -26,7 +26,6 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.FilesToRunProvider; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.TransitionMode; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; @@ -165,14 +164,11 @@ public static ImmutableList collectTransitiveProguardSpecs( return collectTransitiveProguardSpecs( ruleContext, Iterables.concat( - specsToInclude, - ruleContext - .getPrerequisiteArtifacts(":extra_proguard_specs", TransitionMode.TARGET) - .list()), + specsToInclude, ruleContext.getPrerequisiteArtifacts(":extra_proguard_specs").list()), ruleContext.attributes().has(PROGUARD_SPECS, BuildType.LABEL_LIST) - ? ruleContext.getPrerequisiteArtifacts(PROGUARD_SPECS, TransitionMode.TARGET).list() + ? ruleContext.getPrerequisiteArtifacts(PROGUARD_SPECS).list() : ImmutableList.of(), - ruleContext.getPrerequisites("deps", TransitionMode.TARGET, ProguardSpecProvider.PROVIDER)); + ruleContext.getPrerequisites("deps", ProguardSpecProvider.PROVIDER)); } /** @@ -385,8 +381,7 @@ public static ProguardOutput createOptimizationActions( Optional