Skip to content

Commit

Permalink
Remove getAaptSupportsMainDexCreation from AndroidSdkProvider.
Browse files Browse the repository at this point in the history
All android_sdk rules are required to have the apksigner binary, which was not included in the build tools until version 24.0.3. So this check is no longer necessary. Instead, we check in AndroidSdkRepositoryFunction.

RELNOTES: None
PiperOrigin-RevId: 152498753
  • Loading branch information
aj-michael authored and hlopko committed Apr 7, 2017
1 parent e59d3a0 commit d6fec93
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1741,11 +1741,8 @@ private static Artifact createSplitApkResources(RuleContext ruleContext,
return splitResources;
}

@Nullable
private static Artifact createMainDexProguardSpec(RuleContext ruleContext) {
return AndroidSdkProvider.fromRuleContext(ruleContext).getAaptSupportsMainDexGeneration()
? ProguardHelper.getProguardConfigArtifact(ruleContext, "main_dex")
: null;
return ProguardHelper.getProguardConfigArtifact(ruleContext, "main_dex");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
// limitations under the License.
package com.google.devtools.build.lib.rules.android;

import com.android.repository.Revision;
import com.google.common.base.Strings;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.FilesToRunProvider;
Expand Down Expand Up @@ -46,18 +44,6 @@ public ConfiguredTarget create(RuleContext ruleContext)

String buildToolsVersion = AggregatingAttributeMapper.of(ruleContext.getRule())
.get("build_tools_version", Type.STRING);
Revision parsedBuildToolsVersion = null;
try {
parsedBuildToolsVersion =
Strings.isNullOrEmpty(buildToolsVersion)
? null
: Revision.parseRevision(buildToolsVersion);
} catch (NumberFormatException nfe) {
ruleContext.attributeError("build_tools_version", "Invalid version: " + buildToolsVersion);
}
boolean aaptSupportsMainDexGeneration =
parsedBuildToolsVersion == null
|| parsedBuildToolsVersion.compareTo(new Revision(24)) >= 0;
FilesToRunProvider aidl = ruleContext.getExecutablePrerequisite("aidl", Mode.HOST);
FilesToRunProvider aapt = ruleContext.getExecutablePrerequisite("aapt", Mode.HOST);
FilesToRunProvider apkBuilder = ruleContext.getExecutablePrerequisite(
Expand Down Expand Up @@ -88,7 +74,6 @@ public ConfiguredTarget create(RuleContext ruleContext)
AndroidSdkProvider.class,
AndroidSdkProvider.create(
buildToolsVersion,
aaptSupportsMainDexGeneration,
frameworkAidl,
aidlLib,
androidJar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public abstract class AndroidSdkProvider implements TransitiveInfoProvider {

public static AndroidSdkProvider create(
String buildToolsVersion,
boolean aaptSupportsMainDexGeneration,
Artifact frameworkAidl,
@Nullable TransitiveInfoCollection aidlLib,
Artifact androidJar,
Expand All @@ -50,7 +49,6 @@ public static AndroidSdkProvider create(

return new AutoValue_AndroidSdkProvider(
buildToolsVersion,
aaptSupportsMainDexGeneration,
frameworkAidl,
aidlLib,
androidJar,
Expand Down Expand Up @@ -98,8 +96,6 @@ public static boolean verifyPresence(RuleContext ruleContext) {
/** The value of build_tools_version. May be null or empty. */
public abstract String getBuildToolsVersion();

public abstract boolean getAaptSupportsMainDexGeneration();

public abstract Artifact getFrameworkAidl();

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import com.google.devtools.build.lib.vfs.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.junit.Before;
Expand Down Expand Up @@ -2068,49 +2067,6 @@ public void testMainDexAaptGenerationSupported() throws Exception {
targetConfig.getBinFragment() + "/java/a/proguard/a/main_dex_a_proguard.cfg"));
}

@Test
public void testMainDexAaptGenerationUnsupported() throws Exception {
scratch.file("sdk/BUILD",
"android_sdk(",
" name = 'sdk',",
" build_tools_version = '24.0.0-rc3',",
" aapt = 'aapt',",
" adb = 'adb',",
" aidl = 'aidl',",
" android_jar = 'android.jar',",
" annotations_jar = 'annotations_jar',",
" apkbuilder = 'apkbuilder',",
" apksigner = 'apksigner',",
" dx = 'dx',",
" framework_aidl = 'framework_aidl',",
" main_dex_classes = 'main_dex_classes',",
" main_dex_list_creator = 'main_dex_list_creator',",
" proguard = 'proguard',",
" shrinked_android_jar = 'shrinked_android_jar',",
" zipalign = 'zipalign',",
" resource_extractor = 'resource_extractor')");

scratch.file("java/a/BUILD",
"android_binary(",
" name = 'a',",
" srcs = ['A.java'],",
" manifest = 'AndroidManifest.xml',",
" multidex = 'legacy')");

useConfiguration(
"--android_sdk=//sdk:sdk", "--experimental_android_use_singlejar_for_multidex");
ConfiguredTarget a = getConfiguredTarget("//java/a:a");
Artifact intermediateJar = artifactByPath(ImmutableList.of(getCompressedUnsignedApk(a)),
".apk", ".dex.zip", ".dex.zip", "main_dex_list.txt", "_intermediate.jar");
List<String> args = getGeneratingSpawnAction(intermediateJar).getArguments();
assertEquals(-1,
Collections.indexOfSubList(
args,
ImmutableList.of(
"-include",
targetConfig.getBinFragment() + "/java/a/proguard/a/main_dex_a_proguard.cfg")));
}

@Test
public void testMainDexGenerationWithoutProguardMap() throws Exception {
useConfiguration("--experimental_android_use_singlejar_for_multidex");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public void testActionKey() throws Exception {
Artifact outputFile = createArtifact("/workspace/java/test/manifest");
AndroidSdkProvider sdk =
AndroidSdkProvider.create(
"23.0.0",
false, // aapt_supports_main_dex_generation
"24.0.3",
createArtifact("/workspace/androidsdk/frameworkAidl"),
null, // aidlLib, optional
createArtifact("/workspace/androidsdk/androidJar"),
Expand Down

0 comments on commit d6fec93

Please sign in to comment.