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. This relands If65d283abc86f18ad266da0bf16fe95971a0bf9c with fixes to install files into $OUT/apex. Bug: 204136549 Test: m checkbuild Change-Id: I606286e971b55d9d1fc4dcd0fbd476962de5fa79
This commit is contained in:
@@ -17,11 +17,13 @@ package apex
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/java"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
@@ -53,18 +55,17 @@ type prebuiltCommon struct {
|
||||
|
||||
installDir android.InstallPath
|
||||
installFilename string
|
||||
installedFile android.InstallPath
|
||||
outputApex android.WritablePath
|
||||
|
||||
// A list of apexFile objects created in prebuiltCommon.initApexFilesForAndroidMk which are used
|
||||
// to create make modules in prebuiltCommon.AndroidMkEntries.
|
||||
apexFilesForAndroidMk []apexFile
|
||||
|
||||
// list of commands to create symlinks for backward compatibility.
|
||||
// these commands will be attached as LOCAL_POST_INSTALL_CMD
|
||||
compatSymlinks []string
|
||||
// Installed locations of symlinks for backward compatibility.
|
||||
compatSymlinks android.InstallPaths
|
||||
|
||||
hostRequired []string
|
||||
postInstallCommands []string
|
||||
hostRequired []string
|
||||
}
|
||||
|
||||
type sanitizedPrebuilt interface {
|
||||
@@ -223,13 +224,10 @@ func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries {
|
||||
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
|
||||
entries.SetString("LOCAL_MODULE_PATH", p.installDir.ToMakePath().String())
|
||||
entries.SetString("LOCAL_MODULE_STEM", p.installFilename)
|
||||
entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", p.installedFile)
|
||||
entries.SetString("LOCAL_SOONG_INSTALL_PAIRS", p.outputApex.String()+":"+p.installedFile.String())
|
||||
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable())
|
||||
entries.AddStrings("LOCAL_OVERRIDES_MODULES", p.prebuiltCommonProperties.Overrides...)
|
||||
postInstallCommands := append([]string{}, p.postInstallCommands...)
|
||||
postInstallCommands = append(postInstallCommands, p.compatSymlinks...)
|
||||
if len(postInstallCommands) > 0 {
|
||||
entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(postInstallCommands, " && "))
|
||||
}
|
||||
p.addRequiredModules(entries)
|
||||
},
|
||||
},
|
||||
@@ -259,6 +257,9 @@ func (p *prebuiltCommon) createEntriesForApexFile(fi apexFile, apexName string)
|
||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
|
||||
entries.SetString("LOCAL_MODULE_PATH", p.installDir.ToMakePath().String())
|
||||
entries.SetString("LOCAL_SOONG_INSTALLED_MODULE :=", filepath.Join(p.installDir.String(), fi.stem()))
|
||||
entries.SetString("LOCAL_SOONG_INSTALL_PAIRS :=",
|
||||
fi.builtFile.String()+":"+filepath.Join(p.installDir.String(), fi.stem()))
|
||||
|
||||
// soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
|
||||
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
|
||||
@@ -471,6 +472,10 @@ type Prebuilt struct {
|
||||
inputApex android.Path
|
||||
}
|
||||
|
||||
func (p *Prebuilt) InstallBypassMake() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
type ApexFileProperties struct {
|
||||
// the path to the prebuilt .apex file to import.
|
||||
//
|
||||
@@ -756,15 +761,15 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
// Save the files that need to be made available to Make.
|
||||
p.initApexFilesForAndroidMk(ctx)
|
||||
|
||||
if p.installable() {
|
||||
ctx.InstallFile(p.installDir, p.installFilename, p.inputApex)
|
||||
}
|
||||
|
||||
// in case that prebuilt_apex replaces source apex (using prefer: prop)
|
||||
p.compatSymlinks = makeCompatSymlinks(p.BaseModuleName(), ctx)
|
||||
p.compatSymlinks = makeCompatSymlinks(p.BaseModuleName(), ctx, true)
|
||||
// or that prebuilt_apex overrides other apexes (using overrides: prop)
|
||||
for _, overridden := range p.prebuiltCommonProperties.Overrides {
|
||||
p.compatSymlinks = append(p.compatSymlinks, makeCompatSymlinks(overridden, ctx)...)
|
||||
p.compatSymlinks = append(p.compatSymlinks, makeCompatSymlinks(overridden, ctx, true)...)
|
||||
}
|
||||
|
||||
if p.installable() {
|
||||
p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks.Paths()...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,10 +969,10 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
// in case that apex_set replaces source apex (using prefer: prop)
|
||||
a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
|
||||
a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx, true)
|
||||
// or that apex_set overrides other apexes (using overrides: prop)
|
||||
for _, overridden := range a.prebuiltCommonProperties.Overrides {
|
||||
a.compatSymlinks = append(a.compatSymlinks, makeCompatSymlinks(overridden, ctx)...)
|
||||
a.compatSymlinks = append(a.compatSymlinks, makeCompatSymlinks(overridden, ctx, true)...)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user