diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/aapt2.go | 29 | ||||
| -rw-r--r-- | java/aar.go | 18 |
2 files changed, 16 insertions, 31 deletions
diff --git a/java/aapt2.go b/java/aapt2.go index bcc8e9765..a8151608f 100644 --- a/java/aapt2.go +++ b/java/aapt2.go @@ -94,32 +94,20 @@ func aapt2Compile(ctx android.ModuleContext, dir android.Path, paths android.Pat return ret } -func aapt2CompileDirs(ctx android.ModuleContext, flata android.WritablePath, dirs android.Paths, deps android.Paths) { - ctx.Build(pctx, android.BuildParams{ - Rule: aapt2CompileRule, - Description: "aapt2 compile dirs", - Implicits: deps, - Output: flata, - Args: map[string]string{ - "outDir": flata.String(), - // Always set --pseudo-localize, it will be stripped out later for release - // builds that don't want it. - "cFlags": "--pseudo-localize " + android.JoinWithPrefix(dirs.Strings(), "--dir "), - }, - }) -} - var aapt2CompileZipRule = pctx.AndroidStaticRule("aapt2CompileZip", blueprint.RuleParams{ - Command: `${config.ZipSyncCmd} -d $resZipDir $in && ` + + Command: `${config.ZipSyncCmd} -d $resZipDir $zipSyncFlags $in && ` + `${config.Aapt2Cmd} compile -o $out $cFlags --legacy --dir $resZipDir`, CommandDeps: []string{ "${config.Aapt2Cmd}", "${config.ZipSyncCmd}", }, - }, "cFlags", "resZipDir") + }, "cFlags", "resZipDir", "zipSyncFlags") -func aapt2CompileZip(ctx android.ModuleContext, flata android.WritablePath, zip android.Path) { +func aapt2CompileZip(ctx android.ModuleContext, flata android.WritablePath, zip android.Path, zipPrefix string) { + if zipPrefix != "" { + zipPrefix = "--zip-prefix " + zipPrefix + } ctx.Build(pctx, android.BuildParams{ Rule: aapt2CompileZipRule, Description: "aapt2 compile zip", @@ -128,8 +116,9 @@ func aapt2CompileZip(ctx android.ModuleContext, flata android.WritablePath, zip Args: map[string]string{ // Always set --pseudo-localize, it will be stripped out later for release // builds that don't want it. - "cFlags": "--pseudo-localize", - "resZipDir": android.PathForModuleOut(ctx, "aapt2", "reszip", flata.Base()).String(), + "cFlags": "--pseudo-localize", + "resZipDir": android.PathForModuleOut(ctx, "aapt2", "reszip", flata.Base()).String(), + "zipSyncFlags": zipPrefix, }, }) } diff --git a/java/aar.go b/java/aar.go index 1b84a47b0..1e8e6d8c4 100644 --- a/java/aar.go +++ b/java/aar.go @@ -245,7 +245,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}) } @@ -556,13 +556,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 { @@ -580,7 +580,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") @@ -591,16 +590,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") |