Move apex module installation into Soong
Move apex module installation rules into Soong by overriding InstallBypassMake. Soong installs don't support post install commands, so move the symlinks into separate rules and add dependencies on them. Bug: 204136549 Test: m checkbuild Change-Id: If65d283abc86f18ad266da0bf16fe95971a0bf9c
This commit is contained in:
@@ -823,47 +823,55 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
||||
a.outputFile = signedCompressedOutputFile
|
||||
}
|
||||
|
||||
installSuffix := suffix
|
||||
if a.isCompressed {
|
||||
installSuffix = imageCapexSuffix
|
||||
}
|
||||
|
||||
// Install to $OUT/soong/{target,host}/.../apex.
|
||||
ctx.InstallFile(a.installDir, a.Name()+suffix, a.outputFile)
|
||||
a.installedFile = ctx.InstallFile(a.installDir, a.Name()+installSuffix, a.outputFile,
|
||||
a.compatSymlinks.Paths()...)
|
||||
|
||||
// installed-files.txt is dist'ed
|
||||
a.installedFilesFile = a.buildInstalledFilesFile(ctx, a.outputFile, imageDir)
|
||||
}
|
||||
|
||||
// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
|
||||
type flattenedApexContext struct {
|
||||
android.ModuleContext
|
||||
}
|
||||
|
||||
func (c *flattenedApexContext) InstallBypassMake() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// buildFlattenedApex creates rules for a flattened APEX. Flattened APEX actually doesn't have a
|
||||
// single output file. It is a phony target for all the files under /system/apex/<name> directory.
|
||||
// This function creates the installation rules for the files.
|
||||
func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
|
||||
bundleName := a.Name()
|
||||
installedSymlinks := append(android.InstallPaths(nil), a.compatSymlinks...)
|
||||
if a.installable() {
|
||||
for _, fi := range a.filesInfo {
|
||||
dir := filepath.Join("apex", bundleName, fi.installDir)
|
||||
target := ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.stem(), fi.builtFile)
|
||||
for _, sym := range fi.symlinks {
|
||||
ctx.InstallSymlink(android.PathForModuleInstall(ctx, dir), sym, target)
|
||||
installDir := android.PathForModuleInstall(ctx, dir)
|
||||
if a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform() {
|
||||
// TODO(jiyong): pathOnDevice should come from fi.module, not being calculated here
|
||||
pathOnDevice := filepath.Join("/system", fi.path())
|
||||
installedSymlinks = append(installedSymlinks,
|
||||
ctx.InstallAbsoluteSymlink(installDir, fi.stem(), pathOnDevice))
|
||||
} else {
|
||||
target := ctx.InstallFile(installDir, fi.stem(), fi.builtFile)
|
||||
for _, sym := range fi.symlinks {
|
||||
installedSymlinks = append(installedSymlinks,
|
||||
ctx.InstallSymlink(installDir, sym, target))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create install rules for the files added in GenerateAndroidBuildActions after
|
||||
// buildFlattenedApex is called. Add the links to system libs (if any) as dependencies
|
||||
// of the apex_manifest.pb file since it is always present.
|
||||
dir := filepath.Join("apex", bundleName)
|
||||
installDir := android.PathForModuleInstall(ctx, dir)
|
||||
ctx.InstallFile(installDir, "apex_manifest.pb", a.manifestPbOut, installedSymlinks.Paths()...)
|
||||
ctx.InstallFile(installDir, "apex_pubkey", a.publicKeyFile)
|
||||
}
|
||||
|
||||
a.fileContexts = a.buildFileContexts(ctx)
|
||||
|
||||
// Temporarily wrap the original `ctx` into a `flattenedApexContext` to have it reply true
|
||||
// to `InstallBypassMake()` (thus making the call `android.PathForModuleInstall` below use
|
||||
// `android.pathForInstallInMakeDir` instead of `android.PathForOutput`) to return the
|
||||
// correct path to the flattened APEX (as its contents is installed by Make, not Soong).
|
||||
// TODO(jiyong): Why do we need to set outputFile for flattened APEX? We don't seem to use
|
||||
// it and it actually points to a path that can never be built. Remove this.
|
||||
factx := flattenedApexContext{ctx}
|
||||
a.outputFile = android.PathForModuleInstall(&factx, "apex", bundleName)
|
||||
a.outputFile = android.PathForModuleInstall(ctx, "apex", bundleName)
|
||||
}
|
||||
|
||||
// getCertificateAndPrivateKey retrieves the cert and the private key that will be used to sign
|
||||
|
Reference in New Issue
Block a user