|
@@ -26,6 +26,7 @@ type AndroidLibraryDependency interface {
|
|
|
Dependency
|
|
|
ExportPackage() android.Path
|
|
|
ExportedProguardFlagFiles() android.Paths
|
|
|
+ ExportedStaticPackages() android.Paths
|
|
|
}
|
|
|
|
|
|
func init() {
|
|
@@ -58,12 +59,13 @@ type aaptProperties struct {
|
|
|
}
|
|
|
|
|
|
type aapt struct {
|
|
|
- aaptSrcJar android.Path
|
|
|
- exportPackage android.Path
|
|
|
- manifestPath android.Path
|
|
|
- proguardOptionsFile android.Path
|
|
|
- rroDirs android.Paths
|
|
|
- rTxt android.Path
|
|
|
+ aaptSrcJar android.Path
|
|
|
+ exportPackage android.Path
|
|
|
+ manifestPath android.Path
|
|
|
+ proguardOptionsFile android.Path
|
|
|
+ rroDirs android.Paths
|
|
|
+ rTxt android.Path
|
|
|
+ extraAaptPackagesFile android.Path
|
|
|
|
|
|
aaptProperties aaptProperties
|
|
|
}
|
|
@@ -123,9 +125,9 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkVersion string) (flags [
|
|
|
linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A "))
|
|
|
linkDeps = append(linkDeps, assetFiles...)
|
|
|
|
|
|
- staticLibs, libDeps, libFlags := aaptLibs(ctx, sdkVersion)
|
|
|
+ transitiveStaticLibs, libDeps, libFlags := aaptLibs(ctx, sdkVersion)
|
|
|
|
|
|
- overlayFiles = append(overlayFiles, staticLibs...)
|
|
|
+ overlayFiles = append(overlayFiles, transitiveStaticLibs...)
|
|
|
linkDeps = append(linkDeps, libDeps...)
|
|
|
linkFlags = append(linkFlags, libFlags...)
|
|
|
|
|
@@ -178,6 +180,8 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkVersion string, extraL
|
|
|
srcJar := android.PathForModuleGen(ctx, "R.jar")
|
|
|
proguardOptionsFile := android.PathForModuleGen(ctx, "proguard.options")
|
|
|
rTxt := android.PathForModuleOut(ctx, "R.txt")
|
|
|
+ // This file isn't used by Soong, but is generated for exporting
|
|
|
+ extraPackages := android.PathForModuleOut(ctx, "extra_packages")
|
|
|
|
|
|
var compiledRes, compiledOverlay android.Paths
|
|
|
for _, dir := range resDirs {
|
|
@@ -189,7 +193,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkVersion string, extraL
|
|
|
|
|
|
compiledOverlay = append(compiledOverlay, overlayFiles...)
|
|
|
|
|
|
- aapt2Link(ctx, packageRes, srcJar, proguardOptionsFile, rTxt,
|
|
|
+ aapt2Link(ctx, packageRes, srcJar, proguardOptionsFile, rTxt, extraPackages,
|
|
|
linkFlags, linkDeps, compiledRes, compiledOverlay)
|
|
|
|
|
|
a.aaptSrcJar = srcJar
|
|
@@ -197,11 +201,14 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkVersion string, extraL
|
|
|
a.manifestPath = manifestPath
|
|
|
a.proguardOptionsFile = proguardOptionsFile
|
|
|
a.rroDirs = rroDirs
|
|
|
+ a.extraAaptPackagesFile = extraPackages
|
|
|
a.rTxt = rTxt
|
|
|
}
|
|
|
|
|
|
// aaptLibs collects libraries from dependencies and sdk_version and converts them into paths
|
|
|
-func aaptLibs(ctx android.ModuleContext, sdkVersion string) (staticLibs, deps android.Paths, flags []string) {
|
|
|
+func aaptLibs(ctx android.ModuleContext, sdkVersion string) (transitiveStaticLibs, deps android.Paths,
|
|
|
+ flags []string) {
|
|
|
+
|
|
|
var sharedLibs android.Paths
|
|
|
|
|
|
sdkDep := decodeSdkDep(ctx, sdkVersion)
|
|
@@ -211,7 +218,8 @@ func aaptLibs(ctx android.ModuleContext, sdkVersion string) (staticLibs, deps an
|
|
|
|
|
|
ctx.VisitDirectDeps(func(module android.Module) {
|
|
|
var exportPackage android.Path
|
|
|
- if aarDep, ok := module.(AndroidLibraryDependency); ok {
|
|
|
+ aarDep, _ := module.(AndroidLibraryDependency)
|
|
|
+ if aarDep != nil {
|
|
|
exportPackage = aarDep.ExportPackage()
|
|
|
}
|
|
|
|
|
@@ -222,15 +230,16 @@ func aaptLibs(ctx android.ModuleContext, sdkVersion string) (staticLibs, deps an
|
|
|
}
|
|
|
case staticLibTag:
|
|
|
if exportPackage != nil {
|
|
|
- staticLibs = append(staticLibs, exportPackage)
|
|
|
+ transitiveStaticLibs = append(transitiveStaticLibs, exportPackage)
|
|
|
+ transitiveStaticLibs = append(transitiveStaticLibs, aarDep.ExportedStaticPackages()...)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
deps = append(deps, sharedLibs...)
|
|
|
- deps = append(deps, staticLibs...)
|
|
|
+ deps = append(deps, transitiveStaticLibs...)
|
|
|
|
|
|
- if len(staticLibs) > 0 {
|
|
|
+ if len(transitiveStaticLibs) > 0 {
|
|
|
flags = append(flags, "--auto-add-overlay")
|
|
|
}
|
|
|
|
|
@@ -238,7 +247,9 @@ func aaptLibs(ctx android.ModuleContext, sdkVersion string) (staticLibs, deps an
|
|
|
flags = append(flags, "-I "+sharedLib.String())
|
|
|
}
|
|
|
|
|
|
- return staticLibs, deps, flags
|
|
|
+ transitiveStaticLibs = android.FirstUniquePaths(transitiveStaticLibs)
|
|
|
+
|
|
|
+ return transitiveStaticLibs, deps, flags
|
|
|
}
|
|
|
|
|
|
type AndroidLibrary struct {
|
|
@@ -250,12 +261,17 @@ type AndroidLibrary struct {
|
|
|
aarFile android.WritablePath
|
|
|
|
|
|
exportedProguardFlagFiles android.Paths
|
|
|
+ exportedStaticPackages android.Paths
|
|
|
}
|
|
|
|
|
|
func (a *AndroidLibrary) ExportedProguardFlagFiles() android.Paths {
|
|
|
return a.exportedProguardFlagFiles
|
|
|
}
|
|
|
|
|
|
+func (a *AndroidLibrary) ExportedStaticPackages() android.Paths {
|
|
|
+ return a.exportedStaticPackages
|
|
|
+}
|
|
|
+
|
|
|
var _ AndroidLibraryDependency = (*AndroidLibrary)(nil)
|
|
|
|
|
|
func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
@@ -290,10 +306,13 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|
|
ctx.VisitDirectDeps(func(m android.Module) {
|
|
|
if lib, ok := m.(AndroidLibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
|
|
|
a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
|
|
|
+ a.exportedStaticPackages = append(a.exportedStaticPackages, lib.ExportPackage())
|
|
|
+ a.exportedStaticPackages = append(a.exportedStaticPackages, lib.ExportedStaticPackages()...)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
a.exportedProguardFlagFiles = android.FirstUniquePaths(a.exportedProguardFlagFiles)
|
|
|
+ a.exportedStaticPackages = android.FirstUniquePaths(a.exportedStaticPackages)
|
|
|
}
|
|
|
|
|
|
func AndroidLibraryFactory() android.Module {
|
|
@@ -331,9 +350,12 @@ type AARImport struct {
|
|
|
|
|
|
properties AARImportProperties
|
|
|
|
|
|
- classpathFile android.WritablePath
|
|
|
- proguardFlags android.WritablePath
|
|
|
- exportPackage android.WritablePath
|
|
|
+ classpathFile android.WritablePath
|
|
|
+ proguardFlags android.WritablePath
|
|
|
+ exportPackage android.WritablePath
|
|
|
+ extraAaptPackagesFile android.WritablePath
|
|
|
+
|
|
|
+ exportedStaticPackages android.Paths
|
|
|
}
|
|
|
|
|
|
var _ AndroidLibraryDependency = (*AARImport)(nil)
|
|
@@ -346,6 +368,10 @@ func (a *AARImport) ExportedProguardFlagFiles() android.Paths {
|
|
|
return android.Paths{a.proguardFlags}
|
|
|
}
|
|
|
|
|
|
+func (a *AARImport) ExportedStaticPackages() android.Paths {
|
|
|
+ return a.exportedStaticPackages
|
|
|
+}
|
|
|
+
|
|
|
func (a *AARImport) Prebuilt() *android.Prebuilt {
|
|
|
return &a.prebuilt
|
|
|
}
|
|
@@ -362,7 +388,7 @@ func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ctx.AddDependency(ctx.Module(), staticLibTag, a.properties.Libs...)
|
|
|
+ ctx.AddDependency(ctx.Module(), libTag, a.properties.Libs...)
|
|
|
ctx.AddDependency(ctx.Module(), staticLibTag, a.properties.Static_libs...)
|
|
|
}
|
|
|
|
|
@@ -410,6 +436,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
srcJar := android.PathForModuleGen(ctx, "R.jar")
|
|
|
proguardOptionsFile := android.PathForModuleGen(ctx, "proguard.options")
|
|
|
rTxt := android.PathForModuleOut(ctx, "R.txt")
|
|
|
+ a.extraAaptPackagesFile = android.PathForModuleOut(ctx, "extra_packages")
|
|
|
|
|
|
var linkDeps android.Paths
|
|
|
|
|
@@ -422,14 +449,14 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
linkFlags = append(linkFlags, "--manifest "+manifest.String())
|
|
|
linkDeps = append(linkDeps, manifest)
|
|
|
|
|
|
- staticLibs, libDeps, libFlags := aaptLibs(ctx, String(a.properties.Sdk_version))
|
|
|
+ transitiveStaticLibs, libDeps, libFlags := aaptLibs(ctx, String(a.properties.Sdk_version))
|
|
|
|
|
|
linkDeps = append(linkDeps, libDeps...)
|
|
|
linkFlags = append(linkFlags, libFlags...)
|
|
|
|
|
|
- overlayRes := append(android.Paths{flata}, staticLibs...)
|
|
|
+ overlayRes := append(android.Paths{flata}, transitiveStaticLibs...)
|
|
|
|
|
|
- aapt2Link(ctx, a.exportPackage, srcJar, proguardOptionsFile, rTxt,
|
|
|
+ aapt2Link(ctx, a.exportPackage, srcJar, proguardOptionsFile, rTxt, a.extraAaptPackagesFile,
|
|
|
linkFlags, linkDeps, nil, overlayRes)
|
|
|
}
|
|
|
|