Refactor .aar resource compilation
Instead of extracting the aar, and passing the res directory to another rule (along with a dependency to a different known file), don't keep the extracted res directory, and pass the aar directly to the resource compliation rule, which will extract just the res directory. I need this for my RBE experiments, where non-listed output files won't exist in other rules. Test: m Change-Id: I99074381052cbcebb6a402484abae9ab2e40284f
This commit is contained in:
18
java/aar.go
18
java/aar.go
@@ -244,7 +244,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex
|
||||
|
||||
for i, zip := range resZips {
|
||||
flata := android.PathForModuleOut(ctx, fmt.Sprintf("reszip.%d.flata", i))
|
||||
aapt2CompileZip(ctx, flata, zip)
|
||||
aapt2CompileZip(ctx, flata, zip, "")
|
||||
compiledResDirs = append(compiledResDirs, android.Paths{flata})
|
||||
}
|
||||
|
||||
@@ -555,13 +555,13 @@ func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
|
||||
// Unzip an AAR into its constituent files and directories. Any files in Outputs that don't exist in the AAR will be
|
||||
// touched to create an empty file, and any directories in $expectedDirs will be created.
|
||||
// touched to create an empty file. The res directory is not extracted, as it will be extracted in its own rule.
|
||||
var unzipAAR = pctx.AndroidStaticRule("unzipAAR",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf $outDir && mkdir -p $outDir $expectedDirs && ` +
|
||||
`unzip -qo -d $outDir $in && touch $out`,
|
||||
Command: `rm -rf $outDir && mkdir -p $outDir && ` +
|
||||
`unzip -qo -d $outDir $in && rm -rf $outDir/res && touch $out`,
|
||||
},
|
||||
"expectedDirs", "outDir")
|
||||
"outDir")
|
||||
|
||||
func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
if len(a.properties.Aars) != 1 {
|
||||
@@ -579,7 +579,6 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
extractedAARDir := android.PathForModuleOut(ctx, "aar")
|
||||
extractedResDir := extractedAARDir.Join(ctx, "res")
|
||||
a.classpathFile = extractedAARDir.Join(ctx, "classes.jar")
|
||||
a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt")
|
||||
a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml")
|
||||
@@ -590,16 +589,13 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
Outputs: android.WritablePaths{a.classpathFile, a.proguardFlags, a.manifest},
|
||||
Description: "unzip AAR",
|
||||
Args: map[string]string{
|
||||
"expectedDirs": extractedResDir.String(),
|
||||
"outDir": extractedAARDir.String(),
|
||||
"outDir": extractedAARDir.String(),
|
||||
},
|
||||
})
|
||||
|
||||
compiledResDir := android.PathForModuleOut(ctx, "flat-res")
|
||||
aaptCompileDeps := android.Paths{a.classpathFile}
|
||||
aaptCompileDirs := android.Paths{extractedResDir}
|
||||
flata := compiledResDir.Join(ctx, "gen_res.flata")
|
||||
aapt2CompileDirs(ctx, flata, aaptCompileDirs, aaptCompileDeps)
|
||||
aapt2CompileZip(ctx, flata, aar, "res")
|
||||
|
||||
a.exportPackage = android.PathForModuleOut(ctx, "package-res.apk")
|
||||
srcJar := android.PathForModuleGen(ctx, "R.jar")
|
||||
|
Reference in New Issue
Block a user