From f51768abcef98514f18bcd2d998545c8c7f6593e Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 4 Mar 2020 14:52:46 +0000 Subject: [PATCH] Disable installation for sdk snapshot versioned prebuilts The sdk snapshot creates two prebuilts for each member one that is versioned and one that is not. If they are both installed then they lead to duplicate rules in make for creating the same installed file. This change adds an installable property to cc modules that will prevent the installation of the file and then adds installable: false on the versioned prebuilt for cc modules. Bug: 142935992 Bug: 153306490 Test: m nothing Merged-In: I4cb294c2b0c8a3f411eea569775835d9e41726d6 Change-Id: I4cb294c2b0c8a3f411eea569775835d9e41726d6 --- cc/cc.go | 22 +++++++++++++++++++++- cc/installer.go | 5 +++++ cc/library.go | 6 ++++++ sdk/cc_sdk_test.go | 9 +++++++++ sdk/update.go | 21 +++++++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/cc/cc.go b/cc/cc.go index be6ab4d30..778531ad5 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -250,6 +250,8 @@ type BaseProperties struct { // Used by vendor snapshot to record dependencies from snapshot modules. SnapshotSharedLibs []string `blueprint:"mutated"` SnapshotRuntimeLibs []string `blueprint:"mutated"` + + Installable *bool } type VendorProperties struct { @@ -373,6 +375,7 @@ type linker interface { type installer interface { installerProps() []interface{} install(ctx ModuleContext, path android.Path) + everInstallable() bool inData() bool inSanitizerDir() bool hostToolPath() android.OptionalPath @@ -1513,6 +1516,13 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { 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() } } @@ -2705,8 +2715,18 @@ func (c *Module) AvailableFor(what string) bool { } } +// Return true if the module is ever installable. +func (c *Module) EverInstallable() bool { + return c.installer != nil && + // Check to see whether the module is actually ever installable. + c.installer.everInstallable() +} + func (c *Module) installable() bool { - ret := c.installer != nil && !c.Properties.PreventInstall && c.outputFile.Valid() + ret := c.EverInstallable() && + // Check to see whether the module has been configured to not be installed. + proptools.BoolDefault(c.Properties.Installable, true) && + !c.Properties.PreventInstall && c.outputFile.Valid() // The platform variant doesn't need further condition. Apex variants however might not // be installable because it will likely to be included in the APEX and won't appear diff --git a/cc/installer.go b/cc/installer.go index 13a411915..0b4a68cc8 100644 --- a/cc/installer.go +++ b/cc/installer.go @@ -86,6 +86,11 @@ func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) { installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file) } +func (installer *baseInstaller) everInstallable() bool { + // Most cc modules are installable. + return true +} + func (installer *baseInstaller) inData() bool { return installer.location == InstallInData } diff --git a/cc/library.go b/cc/library.go index c0d0d54f7..7a406bfe0 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1221,6 +1221,12 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { } } +func (library *libraryDecorator) everInstallable() bool { + // Only shared and static libraries are installed. Header libraries (which are + // neither static or shared) are not installed. + return library.shared() || library.static() +} + func (library *libraryDecorator) static() bool { return library.MutatedProperties.VariantIsStatic } diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go index 11bc90238..2b0fd3c93 100644 --- a/sdk/cc_sdk_test.go +++ b/sdk/cc_sdk_test.go @@ -297,6 +297,7 @@ func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) { cc_prebuilt_library_shared { name: "mysdk_mynativelib@current", sdk_member_name: "mynativelib", + installable: false, export_include_dirs: ["include/include"], arch: { arm64: { @@ -366,6 +367,7 @@ func TestSnapshotWithCcBinary(t *testing.T) { cc_prebuilt_binary { name: "mymodule_exports_mynativebinary@current", sdk_member_name: "mynativebinary", + installable: false, compile_multilib: "both", arch: { arm64: { @@ -447,6 +449,7 @@ cc_prebuilt_binary { sdk_member_name: "mynativebinary", device_supported: false, host_supported: true, + installable: false, target: { linux_glibc: { compile_multilib: "both", @@ -539,6 +542,7 @@ cc_prebuilt_library_shared { "apex1", "apex2", ], + installable: false, export_include_dirs: ["include/include"], arch: { arm64: { @@ -634,6 +638,7 @@ cc_prebuilt_library_shared { sdk_member_name: "mynativelib", device_supported: false, host_supported: true, + installable: false, sdk_version: "minimum", export_include_dirs: ["include/include"], arch: { @@ -735,6 +740,7 @@ cc_prebuilt_library_shared { sdk_member_name: "mynativelib", device_supported: false, host_supported: true, + installable: false, target: { linux_glibc_x86_64: { srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], @@ -814,6 +820,7 @@ func TestSnapshotWithCcStaticLibrary(t *testing.T) { cc_prebuilt_library_static { name: "myexports_mynativelib@current", sdk_member_name: "mynativelib", + installable: false, export_include_dirs: ["include/include"], arch: { arm64: { @@ -904,6 +911,7 @@ cc_prebuilt_library_static { sdk_member_name: "mynativelib", device_supported: false, host_supported: true, + installable: false, export_include_dirs: ["include/include"], arch: { x86_64: { @@ -1003,6 +1011,7 @@ cc_prebuilt_library_static { sdk_member_name: "mynativelib", device_supported: false, host_supported: true, + installable: false, export_include_dirs: ["include/include"], arch: { x86_64: { diff --git a/sdk/update.go b/sdk/update.go index a43a14b85..27a700327 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -409,8 +409,19 @@ type propertyTag struct { name string } +// A BpPropertyTag to add to a property that contains references to other sdk members. +// +// This will cause the references to be rewritten to a versioned reference in the version +// specific instance of a snapshot module. var sdkMemberReferencePropertyTag = propertyTag{"sdkMemberReferencePropertyTag"} +// A BpPropertyTag that indicates the property should only be present in the versioned +// module. +// +// This will cause the property to be removed from the unversioned instance of a +// snapshot module. +var sdkVersionedOnlyPropertyTag = propertyTag{"sdkVersionedOnlyPropertyTag"} + type unversionedToVersionedTransformation struct { identityTransformation builder *snapshotBuilder @@ -452,6 +463,9 @@ func (t unversionedTransformation) transformModule(module *bpModule) *bpModule { func (t unversionedTransformation) transformProperty(name string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) { if tag == sdkMemberReferencePropertyTag { return t.builder.unversionedSdkMemberNames(value.([]string)), tag + } else if tag == sdkVersionedOnlyPropertyTag { + // The property is not allowed in the unversioned module so remove it. + return nil, nil } else { return value, tag } @@ -631,6 +645,13 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType } } + // Disable installation in the versioned module of those modules that are ever installable. + if installable, ok := variant.(interface{ EverInstallable() bool }); ok { + if installable.EverInstallable() { + m.AddPropertyWithTag("installable", false, sdkVersionedOnlyPropertyTag) + } + } + s.prebuiltModules[name] = m s.prebuiltOrder = append(s.prebuiltOrder, m) return m