Skip to content

Commit

Permalink
Rollback of commit a58f245.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

broke over 100k targets, in the depot, see []

*** Original change description ***

Move library R generation to a separate action, ensuring the merging happens
off the java critical path.

--
PiperOrigin-RevId: 150602545
MOS_MIGRATED_REVID=150602545
  • Loading branch information
meisterT authored and hermione521 committed Mar 20, 2017
1 parent c6a6a77 commit bd40871
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 295 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,17 @@ public ConfiguredTarget create(RuleContext ruleContext)
Artifact resourcesZip =
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP);

ResourceApk resourceApk =
androidManifest.packWithDataAndResources(
ruleContext,
new LocalResourceContainer.Builder(ruleContext)
.withResources(ImmutableList.of(resourcesProvider))
.build(),
ResourceDependencies.fromRuleDeps(ruleContext, JavaCommon.isNeverLink(ruleContext)),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_LOCAL_SYMBOLS),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),
resourcesZip,
/* alwaysExportManifest = */ true);
ResourceApk resourceApk = androidManifest.packWithDataAndResources(
ruleContext,
new LocalResourceContainer.Builder(ruleContext)
.withResources(ImmutableList.of(resourcesProvider))
.build(),
ResourceDependencies.fromRuleDeps(ruleContext, JavaCommon.isNeverLink(ruleContext)),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_SYMBOLS),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),
resourcesZip,
/* alwaysExportManifest = */ true);

// There isn't really any use case for building an aar_import target on its own, so the files to
// build could be empty. The resources zip and merged jars are added here as a sanity check for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,23 @@ public ConfiguredTarget create(RuleContext ruleContext)
if (definesLocalResources) {
ApplicationManifest applicationManifest = androidSemantics.getManifestForRule(ruleContext)
.renamePackage(ruleContext, AndroidCommon.getJavaPackage(ruleContext));
resourceApk =
applicationManifest.packWithDataAndResources(
null, /* resourceApk -- not needed for library */
ruleContext,
true, /* isLibrary */
ResourceDependencies.fromRuleDeps(ruleContext, JavaCommon.isNeverLink(ruleContext)),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_LOCAL_SYMBOLS),
ResourceConfigurationFilter.empty(ruleContext),
ImmutableList.<String>of(), /* uncompressedExtensions */
false, /* crunchPng */
ImmutableList.<String>of(), /* densities */
false, /* incremental */
null, /* proguardCfgOut */
null, /* mainDexProguardCfg */
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP),
DataBinding.isEnabled(ruleContext)
? DataBinding.getLayoutInfoFile(ruleContext)
: null);
resourceApk = applicationManifest.packWithDataAndResources(
null, /* resourceApk -- not needed for library */
ruleContext,
true, /* isLibrary */
ResourceDependencies.fromRuleDeps(ruleContext, JavaCommon.isNeverLink(ruleContext)),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_SYMBOLS),
ResourceConfigurationFilter.empty(ruleContext),
ImmutableList.<String>of(), /* uncompressedExtensions */
false, /* crunchPng */
ImmutableList.<String>of(), /* densities */
false, /* incremental */
null, /* proguardCfgOut */
null, /* mainDexProguardCfg */
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP),
DataBinding.isEnabled(ruleContext) ? DataBinding.getLayoutInfoFile(ruleContext) : null);
if (ruleContext.hasErrors()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,10 @@ public ResourceContainer build(ActionConstructionContext context) {
ResourceContainerConverter.convertDependencies(
dependencies, builder, inputs, RESOURCE_CONTAINER_TO_ARG, RESOURCE_CONTAINER_TO_ARTIFACTS);

Preconditions.checkNotNull(classJarOut);
List<Artifact> outs = new ArrayList<>();
if (classJarOut != null) {
builder.addExecPath("--classJarOutput", classJarOut);
outs.add(classJarOut);
}
builder.addExecPath("--classJarOutput", classJarOut);
outs.add(classJarOut);

if (mergedResourcesOut != null) {
builder.addExecPath("--resourcesOutput", mergedResourcesOut);
Expand Down Expand Up @@ -188,11 +187,8 @@ public ResourceContainer build(ActionConstructionContext context) {
.build(context));

// Return the full set of processed transitive dependencies.
ResourceContainer.Builder result = primary.toBuilder();
if (classJarOut != null) {
// ensure the classJar is propgated if it exists. Otherwise, AndroidCommon tries to make it.
result.setJavaClassJar(classJarOut);
}
ResourceContainer.Builder result = primary.toBuilder()
.setJavaClassJar(classJarOut);
if (manifestOut != null) {
result.setManifest(manifestOut);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public final class AndroidRuleClasses {
fromTemplates("%{name}_symbols/R.txt");
public static final SafeImplicitOutputsFunction ANDROID_LOCAL_SYMBOLS =
fromTemplates("%{name}_symbols/local.bin");
public static final SafeImplicitOutputsFunction ANDROID_MERGED_SYMBOLS =
fromTemplates("%{name}_symbols/merged.bin");
public static final SafeImplicitOutputsFunction ANDROID_SYMBOLS =
fromTemplates("%{name}_symbols/symbols.bin");
public static final ImplicitOutputsFunction ANDROID_PROCESSED_MANIFEST =
fromTemplates("%{name}_processed_manifest/AndroidManifest.xml");
public static final SafeImplicitOutputsFunction MOBILE_INSTALL_STUB_APPLICATION_MANIFEST =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,43 +453,38 @@ private ResourceApk createApk(
if (isLibrary && AndroidCommon.getAndroidConfig(ruleContext).useParallelResourceProcessing()) {
// android_library should only build the APK one way (!incremental).
Preconditions.checkArgument(!incremental);
Artifact rJavaClassJar =
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_CLASS_JAR);

ResourceContainer parsed =
new AndroidResourceParsingActionBuilder(ruleContext)
.setParse(data)
.withPrimary(resourceContainer)
.setOutput(resourceContainer.getSymbols())
.build(ruleContext);

ResourceContainer generated =
new LibraryRGeneratorActionBuilder()
.setJavaPackage(resourceContainer.getJavaPackage())
.withPrimary(parsed)
.withDependencies(resourceDeps)
.setClassJarOut(rJavaClassJar)
.build(ruleContext);
Artifact rJavaClassJar = ruleContext.getImplicitOutputArtifact(
AndroidRuleClasses.ANDROID_RESOURCES_CLASS_JAR);

if (resourceContainer.getSymbols() != null) {
new AndroidResourceParsingActionBuilder(ruleContext)
.withPrimary(resourceContainer)
.setParse(data)
.setOutput(resourceContainer.getSymbols())
.build(ruleContext);
}

ResourceContainer merged =
AndroidResourceMergingActionBuilder resourcesMergerBuilder =
new AndroidResourceMergingActionBuilder(ruleContext)
.setJavaPackage(generated.getJavaPackage())
.withPrimary(generated)
.setJavaPackage(resourceContainer.getJavaPackage())
.withPrimary(resourceContainer)
.withDependencies(resourceDeps)
.setMergedResourcesOut(mergedResources)
.setManifestOut(manifestOut)
.setDataBindingInfoZip(dataBindingInfoZip)
.build(ruleContext);
.setClassJarOut(rJavaClassJar)
.setDataBindingInfoZip(dataBindingInfoZip);
ResourceContainer merged = resourcesMergerBuilder.build(ruleContext);

processed =
AndroidResourceValidatorActionBuilder validatorBuilder =
new AndroidResourceValidatorActionBuilder(ruleContext)
.setJavaPackage(merged.getJavaPackage())
.setDebug(ruleContext.getConfiguration().getCompilationMode() != CompilationMode.OPT)
.setDebug(
ruleContext.getConfiguration().getCompilationMode() != CompilationMode.OPT)
.setMergedResources(mergedResources)
.withPrimary(merged)
.setSourceJarOut(merged.getJavaSourceJar())
.setRTxtOut(merged.getRTxt())
.build(ruleContext);
.setRTxtOut(merged.getRTxt());
processed = validatorBuilder.build(ruleContext);
} else {
AndroidResourcesProcessorBuilder builder =
new AndroidResourcesProcessorBuilder(ruleContext)
Expand Down Expand Up @@ -635,16 +630,14 @@ public ResourceApk packWithResources(
aaptActionHelper.createGenerateApkAction(resourceApk,
resourceContainer.getRenameManifestPackage(), additionalAaptOpts.build(), densities);

ResourceContainer updatedResources =
resourceContainer
.toBuilder()
.setLabel(ruleContext.getLabel())
.setApk(resourceApk)
.setManifest(getManifest())
.setJavaSourceJar(javaSourcesJar)
.setJavaClassJar(null)
.setSymbols(null)
.build();
ResourceContainer updatedResources = resourceContainer.toBuilder()
.setLabel(ruleContext.getLabel())
.setApk(resourceApk)
.setManifest(getManifest())
.setJavaSourceJar(javaSourcesJar)
.setJavaClassJar(null)
.setSymbols(null)
.build();

aaptActionHelper.createGenerateProguardAction(proguardCfg, mainDexProguardCfg);

Expand Down

This file was deleted.

Loading

0 comments on commit bd40871

Please sign in to comment.