Merge "Reland "use symlink for bundled APEX"" am: 21e40ce36e
am: af01efec1c
am: bdc7e0f9e2
Change-Id: I470306a8a80efc73318b793cb51eed6f89bdb440
This commit is contained in:
62
apex/apex.go
62
apex/apex.go
@@ -751,6 +751,30 @@ func (af *apexFile) Ok() bool {
|
||||
return af.builtFile != nil && af.builtFile.String() != ""
|
||||
}
|
||||
|
||||
// Path() returns path of this apex file relative to the APEX root
|
||||
func (af *apexFile) Path() string {
|
||||
return filepath.Join(af.installDir, af.builtFile.Base())
|
||||
}
|
||||
|
||||
// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
|
||||
func (af *apexFile) SymlinkPaths() []string {
|
||||
var ret []string
|
||||
for _, symlink := range af.symlinks {
|
||||
ret = append(ret, filepath.Join(af.installDir, symlink))
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (af *apexFile) AvailableToPlatform() bool {
|
||||
if af.module == nil {
|
||||
return false
|
||||
}
|
||||
if am, ok := af.module.(android.ApexModule); ok {
|
||||
return am.AvailableFor(android.AvailableToPlatform)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type apexBundle struct {
|
||||
android.ModuleBase
|
||||
android.DefaultableModuleBase
|
||||
@@ -808,6 +832,10 @@ type apexBundle struct {
|
||||
suffix string
|
||||
|
||||
installedFilesFile android.WritablePath
|
||||
|
||||
// Whether to create symlink to the system file instead of having a file
|
||||
// inside the apex or not
|
||||
linkToSystemLib bool
|
||||
}
|
||||
|
||||
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
|
||||
@@ -1432,7 +1460,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
// of the original test module (`depName`, shared by all `test_per_src`
|
||||
// variations of that module).
|
||||
af.moduleName = filepath.Base(af.builtFile.String())
|
||||
af.transitiveDep = true
|
||||
// these are not considered transitive dep
|
||||
af.transitiveDep = false
|
||||
filesInfo = append(filesInfo, af)
|
||||
return true // track transitive dependencies
|
||||
}
|
||||
@@ -1470,15 +1499,22 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
// remove duplicates in filesInfo
|
||||
removeDup := func(filesInfo []apexFile) []apexFile {
|
||||
encountered := make(map[string]bool)
|
||||
result := []apexFile{}
|
||||
encountered := make(map[string]apexFile)
|
||||
for _, f := range filesInfo {
|
||||
dest := filepath.Join(f.installDir, f.builtFile.Base())
|
||||
if !encountered[dest] {
|
||||
encountered[dest] = true
|
||||
result = append(result, f)
|
||||
if e, ok := encountered[dest]; !ok {
|
||||
encountered[dest] = f
|
||||
} else {
|
||||
// If a module is directly included and also transitively depended on
|
||||
// consider it as directly included.
|
||||
e.transitiveDep = e.transitiveDep && f.transitiveDep
|
||||
encountered[dest] = e
|
||||
}
|
||||
}
|
||||
var result []apexFile
|
||||
for _, v := range encountered {
|
||||
result = append(result, v)
|
||||
}
|
||||
return result
|
||||
}
|
||||
filesInfo = removeDup(filesInfo)
|
||||
@@ -1505,12 +1541,6 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
}
|
||||
|
||||
// prepend the name of this APEX to the module names. These names will be the names of
|
||||
// modules that will be defined if the APEX is flattened.
|
||||
for i := range filesInfo {
|
||||
filesInfo[i].moduleName = filesInfo[i].moduleName + "." + a.Name() + a.suffix
|
||||
}
|
||||
|
||||
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
||||
a.filesInfo = filesInfo
|
||||
|
||||
@@ -1530,6 +1560,14 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
return
|
||||
}
|
||||
}
|
||||
// Optimization. If we are building bundled APEX, for the files that are gathered due to the
|
||||
// transitive dependencies, don't place them inside the APEX, but place a symlink pointing
|
||||
// the same library in the system partition, thus effectively sharing the same libraries
|
||||
// across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
|
||||
// in the APEX.
|
||||
a.linkToSystemLib = !ctx.Config().UnbundledBuild() &&
|
||||
a.installable() &&
|
||||
!proptools.Bool(a.properties.Use_vendor)
|
||||
|
||||
// prepare apex_manifest.json
|
||||
a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
|
||||
|
Reference in New Issue
Block a user