Call ctx.InstallFile for uninstallable cc modules

SkipInstall is actually primarily used to prevent making a module
visible to Make, rename it and add new SkipInstall that actually
skips installation without affecting Make.

Call c.SkipInstall() for uninstallable cc modules to allow calling
c.installer.install, which will collect PackagingSpecs for
uninstallable cc modules, allowing them to be used by genrules.

Bug: 124313442
Test: m checkbuild
Change-Id: I8038ed5c6f05c989ac21ec06c4552fb3136b9a7a
This commit is contained in:
Colin Cross 2020-12-16 10:20:23 -08:00
parent 95b07f2b59
commit a9c8c9f145
15 changed files with 63 additions and 38 deletions

View file

@ -820,7 +820,7 @@ func shouldSkipAndroidMkProcessing(module *ModuleBase) bool {
}
return !module.Enabled() ||
module.commonProperties.SkipInstall ||
module.commonProperties.HideFromMake ||
// Make does not understand LinuxBionic
module.Os() == LinuxBionic
}

View file

@ -452,8 +452,8 @@ type Module interface {
InstallInRoot() bool
InstallBypassMake() bool
InstallForceOS() (*OsType, *ArchType)
SkipInstall()
IsSkipInstall() bool
HideFromMake()
IsHideFromMake() bool
MakeUninstallable()
ReplacedByPrebuilt()
IsReplacedByPrebuilt() bool
@ -751,6 +751,13 @@ type commonProperties struct {
// Set by osMutator.
CommonOSVariant bool `blueprint:"mutated"`
// When HideFromMake is set to true, no entry for this variant will be emitted in the
// generated Android.mk file.
HideFromMake bool `blueprint:"mutated"`
// When SkipInstall is set to true, calls to ctx.InstallFile, ctx.InstallExecutable,
// ctx.InstallSymlink and ctx.InstallAbsoluteSymlink act like calls to ctx.PackageFile
// and don't create a rule to install the file.
SkipInstall bool `blueprint:"mutated"`
// Whether the module has been replaced by a prebuilt
@ -1355,26 +1362,33 @@ func (m *ModuleBase) Disable() {
m.commonProperties.ForcedDisabled = true
}
// HideFromMake marks this variant so that it is not emitted in the generated Android.mk file.
func (m *ModuleBase) HideFromMake() {
m.commonProperties.HideFromMake = true
}
// IsHideFromMake returns true if HideFromMake was previously called.
func (m *ModuleBase) IsHideFromMake() bool {
return m.commonProperties.HideFromMake == true
}
// SkipInstall marks this variant to not create install rules when ctx.Install* are called.
func (m *ModuleBase) SkipInstall() {
m.commonProperties.SkipInstall = true
}
func (m *ModuleBase) IsSkipInstall() bool {
return m.commonProperties.SkipInstall == true
}
// Similar to SkipInstall, but if the AndroidMk entry would set
// Similar to HideFromMake, but if the AndroidMk entry would set
// LOCAL_UNINSTALLABLE_MODULE then this variant may still output that entry
// rather than leaving it out altogether. That happens in cases where it would
// have other side effects, in particular when it adds a NOTICE file target,
// which other install targets might depend on.
func (m *ModuleBase) MakeUninstallable() {
m.SkipInstall()
m.HideFromMake()
}
func (m *ModuleBase) ReplacedByPrebuilt() {
m.commonProperties.ReplacedByPrebuilt = true
m.SkipInstall()
m.HideFromMake()
}
func (m *ModuleBase) IsReplacedByPrebuilt() bool {
@ -2440,11 +2454,15 @@ func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
return m.module.InstallForceOS()
}
func (m *moduleContext) skipInstall(fullInstallPath InstallPath) bool {
func (m *moduleContext) skipInstall() bool {
if m.module.base().commonProperties.SkipInstall {
return true
}
if m.module.base().commonProperties.HideFromMake {
return true
}
// We'll need a solution for choosing which of modules with the same name in different
// namespaces to install. For now, reuse the list of namespaces exported to Make as the
// list of namespaces to install in a Soong-only build.
@ -2492,7 +2510,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
if !m.skipInstall(fullInstallPath) {
if !m.skipInstall() {
deps = append(deps, m.module.base().installFilesDepSet.ToList().Paths()...)
var implicitDeps, orderOnlyDeps Paths
@ -2526,6 +2544,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
m.packageFile(fullInstallPath, srcPath, executable)
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
return fullInstallPath
}
@ -2537,7 +2556,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src
if err != nil {
panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
}
if !m.skipInstall(fullInstallPath) {
if !m.skipInstall() {
m.Build(pctx, BuildParams{
Rule: Symlink,
@ -2570,7 +2589,7 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str
fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true)
if !m.skipInstall(fullInstallPath) {
if !m.skipInstall() {
m.Build(pctx, BuildParams{
Rule: Symlink,
Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,

View file

@ -235,7 +235,7 @@ func overrideModuleDepsMutator(ctx BottomUpMutatorContext) {
return
}
// See if there's a prebuilt module that overrides this override module with prefer flag,
// in which case we call SkipInstall on the corresponding variant later.
// in which case we call HideFromMake on the corresponding variant later.
ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(dep Module) {
prebuilt, ok := dep.(PrebuiltInterface)
if !ok {
@ -284,7 +284,7 @@ func performOverrideMutator(ctx BottomUpMutatorContext) {
mods[i+1].(OverridableModule).override(ctx, o)
if o.getOverriddenByPrebuilt() {
// The overriding module itself, too, is overridden by a prebuilt. Skip its installation.
mods[i+1].SkipInstall()
mods[i+1].HideFromMake()
}
}
} else if o, ok := ctx.Module().(OverrideModule); ok {

View file

@ -289,7 +289,7 @@ func PrebuiltPostDepsMutator(ctx BottomUpMutatorContext) {
})
}
} else {
m.SkipInstall()
m.HideFromMake()
}
}
}

View file

@ -6578,7 +6578,7 @@ func TestPrebuiltStubLibDep(t *testing.T) {
continue
}
mod := ctx.ModuleForTests(modName, variant).Module().(*cc.Module)
if !mod.Enabled() || mod.IsSkipInstall() {
if !mod.Enabled() || mod.IsHideFromMake() {
continue
}
for _, ent := range android.AndroidMkEntriesForTest(t, config, "", mod) {

View file

@ -218,7 +218,7 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
})
if p.prebuiltCommon.checkForceDisable(ctx) {
p.SkipInstall()
p.HideFromMake()
return
}
@ -392,7 +392,7 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
})
if a.prebuiltCommon.checkForceDisable(ctx) {
a.SkipInstall()
a.HideFromMake()
return
}

View file

@ -273,7 +273,7 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
entries.SubName = "." + library.stubsVersion()
}
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
// library.makeUninstallable() depends on this to bypass SkipInstall() for
// library.makeUninstallable() depends on this to bypass HideFromMake() for
// static libraries.
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
if library.buildStubs() {

View file

@ -1580,18 +1580,24 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
}
}
if c.installable(apexInfo) {
if !proptools.BoolDefault(c.Properties.Installable, true) {
// If the module has been specifically configure to not be installed then
// hide from make as otherwise it will break when running inside make
// as the output path to install will not be specified. Not all uninstallable
// modules can be hidden from make as some are needed for resolving make side
// dependencies.
c.HideFromMake()
} else if !c.installable(apexInfo) {
c.SkipInstall()
}
// Still call c.installer.install though, the installs will be stored as PackageSpecs
// to allow using the outputs in a genrule.
if c.installer != nil && c.outputFile.Valid() {
c.installer.install(ctx, c.outputFile.Path())
if ctx.Failed() {
return
}
} else if !proptools.BoolDefault(c.Properties.Installable, true) {
// If the module has been specifically configure to not be installed then
// skip the installation as otherwise it will break when running inside make
// as the output path to install will not be specified. Not all uninstallable
// modules can skip installation as some are needed for resolving make side
// dependencies.
c.SkipInstall()
}
}

View file

@ -454,7 +454,7 @@ func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string
vndkVersion := ctx.DeviceConfig().VndkVersion()
if vndkVersion != "current" && vndkVersion != "" && vndkVersion != m.Properties.VndkVersion {
m.Properties.HideFromMake = true
m.SkipInstall()
m.HideFromMake()
}
} else if strings.HasPrefix(variant, ProductVariationPrefix) {
m.Properties.ImageVariationPrefix = ProductVariationPrefix

View file

@ -1336,7 +1336,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
}
} else if ctx.directlyInAnyApex() && ctx.isLlndk(ctx.Config()) && !isBionic(ctx.baseModuleName()) {
// Skip installing LLNDK (non-bionic) libraries moved to APEX.
ctx.Module().SkipInstall()
ctx.Module().HideFromMake()
}
library.baseInstaller.install(ctx, file)

View file

@ -131,7 +131,7 @@ func shouldCreateSourceAbiDumpForLibrary(ctx android.BaseModuleContext) bool {
// Module is shared library type.
// Don't check uninstallable modules.
if m.IsSkipInstall() {
if m.IsHideFromMake() {
return false
}

View file

@ -836,7 +836,7 @@ func VendorSnapshotSourceMutator(ctx android.BottomUpMutatorContext) {
// Disables source modules if corresponding snapshot exists.
if lib, ok := module.linker.(libraryInterface); ok && lib.buildStatic() && lib.buildShared() {
// But do not disable because the shared variant depends on the static variant.
module.SkipInstall()
module.HideFromMake()
module.Properties.HideFromMake = true
} else {
module.Disable()

View file

@ -181,8 +181,8 @@ func isSnapshotAware(m *Module, inProprietaryPath bool, apexInfo android.ApexInf
return false
}
// When android/prebuilt.go selects between source and prebuilt, it sets
// SkipInstall on the other one to avoid duplicate install rules in make.
if m.IsSkipInstall() {
// HideFromMake on the other one to avoid duplicate install rules in make.
if m.IsHideFromMake() {
return false
}
// skip proprietary modules, but (for the vendor snapshot only)

View file

@ -130,7 +130,7 @@ func (p *vndkPrebuiltLibraryDecorator) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
if !p.matchesWithDevice(ctx.DeviceConfig()) {
ctx.Module().SkipInstall()
ctx.Module().HideFromMake()
return nil
}
@ -175,7 +175,7 @@ func (p *vndkPrebuiltLibraryDecorator) link(ctx ModuleContext,
return in
}
ctx.Module().SkipInstall()
ctx.Module().HideFromMake()
return nil
}

View file

@ -90,7 +90,7 @@ func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant stri
vndkVersion := ctx.DeviceConfig().VndkVersion()
if vndkVersion != "current" && vndkVersion != "" && vndkVersion != m.Properties.VndkVersion {
m.Properties.HideFromMake = true
m.SkipInstall()
m.HideFromMake()
}
}
}