From 9e9bb7f2239b96773946d4c3ba6187e6f5fd3ffa Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Thu, 6 Aug 2020 22:34:42 +0100 Subject: [PATCH] Only output make targets for uninstallable static libs in the APEX unavailable-to-platform case. This removes the special case added in https://r.android.com/1274763 from SkipInstall(), so that it doesn't cause conflicting AndroidMk entries when a cc_prebuilt_library_static module has prefer:true and the corresponding source module exists. Test: `m` in a tree with a snapshot created from art-module-sdk where the libartimagevalues module has prefer:true Bug: 151303681 Change-Id: I651ae325753b707296892adb4cae80daaddb6af2 --- android/apex.go | 5 ++++- android/module.go | 10 ++++++++++ cc/androidmk.go | 6 ++---- cc/cc.go | 8 ++++---- cc/installer.go | 4 ++-- cc/library.go | 13 ++++++------- cc/prebuilt.go | 5 ----- 7 files changed, 28 insertions(+), 23 deletions(-) diff --git a/android/apex.go b/android/apex.go index cd84f8aa5..8c06b63f4 100644 --- a/android/apex.go +++ b/android/apex.go @@ -296,7 +296,10 @@ func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []Mod for i, mod := range modules { platformVariation := i == 0 if platformVariation && !mctx.Host() && !mod.(ApexModule).AvailableFor(AvailableToPlatform) { - mod.SkipInstall() + // Do not install the module for platform, but still allow it to output + // uninstallable AndroidMk entries in certain cases when they have + // side effects. + mod.MakeUninstallable() } if !platformVariation { mod.(ApexModule).apexModuleBase().ApexProperties.Info = m.apexVariations[i-1] diff --git a/android/module.go b/android/module.go index 8605954a2..2dc2ac754 100644 --- a/android/module.go +++ b/android/module.go @@ -256,6 +256,7 @@ type Module interface { InstallForceOS() *OsType SkipInstall() IsSkipInstall() bool + MakeUninstallable() ExportedToMake() bool InitRc() Paths VintfFragments() Paths @@ -1046,6 +1047,15 @@ func (m *ModuleBase) IsSkipInstall() bool { return m.commonProperties.SkipInstall == true } +// Similar to SkipInstall, 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() +} + func (m *ModuleBase) ExportedToMake() bool { return m.commonProperties.NamespaceExportedToMake } diff --git a/cc/androidmk.go b/cc/androidmk.go index e91b40ad8..ae8a16c50 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -286,10 +286,8 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries entries.SubName = "." + library.stubsVersion() } entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { - // Note library.skipInstall() has a special case to get here for static - // libraries that otherwise would have skipped installation and hence not - // have executed AndroidMkEntries at all. The reason is to ensure they get - // a NOTICE file make target which other libraries might depend on. + // library.makeUninstallable() depends on this to bypass SkipInstall() for + // static libraries. entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) if library.buildStubs() { entries.SetBool("LOCAL_NO_NOTICE_FILE", true) diff --git a/cc/cc.go b/cc/cc.go index 4b362184a..6f1a06d99 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -418,7 +418,7 @@ type installer interface { inSanitizerDir() bool hostToolPath() android.OptionalPath relativeInstallPath() string - skipInstall(mod *Module) + makeUninstallable(mod *Module) } type xref interface { @@ -2730,12 +2730,12 @@ func (c *Module) InstallInRecovery() bool { return c.InRecovery() } -func (c *Module) SkipInstall() { +func (c *Module) MakeUninstallable() { if c.installer == nil { - c.ModuleBase.SkipInstall() + c.ModuleBase.MakeUninstallable() return } - c.installer.skipInstall(c) + c.installer.makeUninstallable(c) } func (c *Module) HostToolPath() android.OptionalPath { diff --git a/cc/installer.go b/cc/installer.go index 0b4a68cc8..e551c63e2 100644 --- a/cc/installer.go +++ b/cc/installer.go @@ -107,6 +107,6 @@ func (installer *baseInstaller) relativeInstallPath() string { return String(installer.Properties.Relative_install_path) } -func (installer *baseInstaller) skipInstall(mod *Module) { - mod.ModuleBase.SkipInstall() +func (installer *baseInstaller) makeUninstallable(mod *Module) { + mod.ModuleBase.MakeUninstallable() } diff --git a/cc/library.go b/cc/library.go index 2a329ac3c..441c7b835 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1365,16 +1365,15 @@ func (library *libraryDecorator) availableFor(what string) bool { return android.CheckAvailableForApex(what, list) } -func (library *libraryDecorator) skipInstall(mod *Module) { +func (library *libraryDecorator) makeUninstallable(mod *Module) { if library.static() && library.buildStatic() && !library.buildStubs() { - // If we're asked to skip installation of a static library (in particular - // when it's not //apex_available:platform) we still want an AndroidMk entry - // for it to ensure we get the relevant NOTICE file targets (cf. - // notice_files.mk) that other libraries might depend on. AndroidMkEntries - // always sets LOCAL_UNINSTALLABLE_MODULE for these entries. + // If we're asked to make a static library uninstallable we don't do + // anything since AndroidMkEntries always sets LOCAL_UNINSTALLABLE_MODULE + // for these entries. This is done to still get the make targets for NOTICE + // files from notice_files.mk, which other libraries might depend on. return } - mod.ModuleBase.SkipInstall() + mod.ModuleBase.MakeUninstallable() } var versioningMacroNamesListKey = android.NewOnceKey("versioningMacroNamesList") diff --git a/cc/prebuilt.go b/cc/prebuilt.go index 653b43ef0..baf43ce0f 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -199,10 +199,6 @@ func (p *prebuiltLibraryLinker) disablePrebuilt() { p.properties.Srcs = nil } -func (p *prebuiltLibraryLinker) skipInstall(mod *Module) { - mod.ModuleBase.SkipInstall() -} - func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) { module, library := NewLibrary(hod) module.compiler = nil @@ -211,7 +207,6 @@ func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDec libraryDecorator: library, } module.linker = prebuilt - module.installer = prebuilt module.AddProperties(&prebuilt.properties)