Support passing resource zips to aapt2 am: a592e3eae9
am: 089d22dec0
Change-Id: I3d368cf2d23fdc6cf0a1120bf64d2eb5b3ccf239
This commit is contained in:
@@ -109,6 +109,31 @@ func aapt2CompileDirs(ctx android.ModuleContext, flata android.WritablePath, dir
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var aapt2CompileZipRule = pctx.AndroidStaticRule("aapt2CompileZip",
|
||||||
|
blueprint.RuleParams{
|
||||||
|
Command: `${config.ZipSyncCmd} -d $resZipDir $in && ` +
|
||||||
|
`${config.Aapt2Cmd} compile -o $out $cFlags --legacy --dir $resZipDir`,
|
||||||
|
CommandDeps: []string{
|
||||||
|
"${config.Aapt2Cmd}",
|
||||||
|
"${config.ZipSyncCmd}",
|
||||||
|
},
|
||||||
|
}, "cFlags", "resZipDir")
|
||||||
|
|
||||||
|
func aapt2CompileZip(ctx android.ModuleContext, flata android.WritablePath, zip android.Path) {
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: aapt2CompileZipRule,
|
||||||
|
Description: "aapt2 compile zip",
|
||||||
|
Input: zip,
|
||||||
|
Output: flata,
|
||||||
|
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(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var aapt2LinkRule = pctx.AndroidStaticRule("aapt2Link",
|
var aapt2LinkRule = pctx.AndroidStaticRule("aapt2Link",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `rm -rf $genDir && ` +
|
Command: `rm -rf $genDir && ` +
|
||||||
|
19
java/aar.go
19
java/aar.go
@@ -16,6 +16,7 @@ package java
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
@@ -62,6 +63,9 @@ type aaptProperties struct {
|
|||||||
// Set to [] to disable the default.
|
// Set to [] to disable the default.
|
||||||
Resource_dirs []string
|
Resource_dirs []string
|
||||||
|
|
||||||
|
// list of zip files containing Android resources.
|
||||||
|
Resource_zips []string
|
||||||
|
|
||||||
// path to AndroidManifest.xml. If unset, defaults to "AndroidManifest.xml".
|
// path to AndroidManifest.xml. If unset, defaults to "AndroidManifest.xml".
|
||||||
Manifest *string
|
Manifest *string
|
||||||
}
|
}
|
||||||
@@ -95,7 +99,7 @@ func (a *aapt) ExportedManifest() android.Path {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, manifestPath android.Path) (flags []string,
|
func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, manifestPath android.Path) (flags []string,
|
||||||
deps android.Paths, resDirs, overlayDirs []globbedResourceDir, rroDirs android.Paths) {
|
deps android.Paths, resDirs, overlayDirs []globbedResourceDir, rroDirs, resZips android.Paths) {
|
||||||
|
|
||||||
hasVersionCode := false
|
hasVersionCode := false
|
||||||
hasVersionName := false
|
hasVersionName := false
|
||||||
@@ -117,6 +121,7 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, mani
|
|||||||
// Find implicit or explicit asset and resource dirs
|
// Find implicit or explicit asset and resource dirs
|
||||||
assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Asset_dirs, "assets")
|
assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Asset_dirs, "assets")
|
||||||
resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Resource_dirs, "res")
|
resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Resource_dirs, "res")
|
||||||
|
resourceZips := ctx.ExpandSources(a.aaptProperties.Resource_zips, nil)
|
||||||
|
|
||||||
var linkDeps android.Paths
|
var linkDeps android.Paths
|
||||||
|
|
||||||
@@ -167,7 +172,7 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, mani
|
|||||||
linkFlags = append(linkFlags, "--version-name ", versionName)
|
linkFlags = append(linkFlags, "--version-name ", versionName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return linkFlags, linkDeps, resDirs, overlayDirs, rroDirs
|
return linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resourceZips
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkContext sdkContext) {
|
func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkContext sdkContext) {
|
||||||
@@ -175,6 +180,8 @@ func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkContext sdkContext) {
|
|||||||
if sdkDep.frameworkResModule != "" {
|
if sdkDep.frameworkResModule != "" {
|
||||||
ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
|
ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
android.ExtractSourcesDeps(ctx, a.aaptProperties.Resource_zips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, extraLinkFlags ...string) {
|
func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, extraLinkFlags ...string) {
|
||||||
@@ -187,7 +194,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex
|
|||||||
manifestPath := manifestMerger(ctx, manifestSrcPath, sdkContext, staticLibManifests, a.isLibrary,
|
manifestPath := manifestMerger(ctx, manifestSrcPath, sdkContext, staticLibManifests, a.isLibrary,
|
||||||
a.uncompressedJNI, a.useEmbeddedDex, a.usesNonSdkApis)
|
a.uncompressedJNI, a.useEmbeddedDex, a.usesNonSdkApis)
|
||||||
|
|
||||||
linkFlags, linkDeps, resDirs, overlayDirs, rroDirs := a.aapt2Flags(ctx, sdkContext, manifestPath)
|
linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resZips := a.aapt2Flags(ctx, sdkContext, manifestPath)
|
||||||
|
|
||||||
rroDirs = append(rroDirs, staticRRODirs...)
|
rroDirs = append(rroDirs, staticRRODirs...)
|
||||||
linkFlags = append(linkFlags, libFlags...)
|
linkFlags = append(linkFlags, libFlags...)
|
||||||
@@ -209,6 +216,12 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex
|
|||||||
compiledResDirs = append(compiledResDirs, aapt2Compile(ctx, dir.dir, dir.files).Paths())
|
compiledResDirs = append(compiledResDirs, aapt2Compile(ctx, dir.dir, dir.files).Paths())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i, zip := range resZips {
|
||||||
|
flata := android.PathForModuleOut(ctx, fmt.Sprintf("reszip.%d.flata", i))
|
||||||
|
aapt2CompileZip(ctx, flata, zip)
|
||||||
|
compiledResDirs = append(compiledResDirs, android.Paths{flata})
|
||||||
|
}
|
||||||
|
|
||||||
var compiledRes, compiledOverlay android.Paths
|
var compiledRes, compiledOverlay android.Paths
|
||||||
|
|
||||||
compiledOverlay = append(compiledOverlay, transitiveStaticLibs...)
|
compiledOverlay = append(compiledOverlay, transitiveStaticLibs...)
|
||||||
|
Reference in New Issue
Block a user