Merge "Fix overlaying android resources from static libraries" am: 9af53b4795
am: 26d7533901
Change-Id: Ia2bc610d3cc0fd2ac6d365b1496e2eeb1c35ead0
This commit is contained in:
31
java/aar.go
31
java/aar.go
@@ -186,16 +186,39 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex
|
|||||||
// This file isn't used by Soong, but is generated for exporting
|
// This file isn't used by Soong, but is generated for exporting
|
||||||
extraPackages := android.PathForModuleOut(ctx, "extra_packages")
|
extraPackages := android.PathForModuleOut(ctx, "extra_packages")
|
||||||
|
|
||||||
var compiledRes, compiledOverlay android.Paths
|
var compiledResDirs []android.Paths
|
||||||
for _, dir := range resDirs {
|
for _, dir := range resDirs {
|
||||||
compiledRes = append(compiledRes, aapt2Compile(ctx, dir.dir, dir.files).Paths()...)
|
compiledResDirs = append(compiledResDirs, aapt2Compile(ctx, dir.dir, dir.files).Paths())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var compiledRes, compiledOverlay android.Paths
|
||||||
|
|
||||||
|
compiledOverlay = append(compiledOverlay, transitiveStaticLibs...)
|
||||||
|
|
||||||
|
if a.isLibrary {
|
||||||
|
// For a static library we treat all the resources equally with no overlay.
|
||||||
|
for _, compiledResDir := range compiledResDirs {
|
||||||
|
compiledRes = append(compiledRes, compiledResDir...)
|
||||||
|
}
|
||||||
|
} else if len(transitiveStaticLibs) > 0 {
|
||||||
|
// If we are using static android libraries, every source file becomes an overlay.
|
||||||
|
// This is to emulate old AAPT behavior which simulated library support.
|
||||||
|
for _, compiledResDir := range compiledResDirs {
|
||||||
|
compiledOverlay = append(compiledOverlay, compiledResDir...)
|
||||||
|
}
|
||||||
|
} else if len(compiledResDirs) > 0 {
|
||||||
|
// Without static libraries, the first directory is our directory, which can then be
|
||||||
|
// overlaid by the rest.
|
||||||
|
compiledRes = append(compiledRes, compiledResDirs[0]...)
|
||||||
|
for _, compiledResDir := range compiledResDirs[1:] {
|
||||||
|
compiledOverlay = append(compiledOverlay, compiledResDir...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, dir := range overlayDirs {
|
for _, dir := range overlayDirs {
|
||||||
compiledOverlay = append(compiledOverlay, aapt2Compile(ctx, dir.dir, dir.files).Paths()...)
|
compiledOverlay = append(compiledOverlay, aapt2Compile(ctx, dir.dir, dir.files).Paths()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
compiledOverlay = append(compiledOverlay, transitiveStaticLibs...)
|
|
||||||
|
|
||||||
aapt2Link(ctx, packageRes, srcJar, proguardOptionsFile, rTxt, extraPackages,
|
aapt2Link(ctx, packageRes, srcJar, proguardOptionsFile, rTxt, extraPackages,
|
||||||
linkFlags, linkDeps, compiledRes, compiledOverlay)
|
linkFlags, linkDeps, compiledRes, compiledOverlay)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user