From 618b671bf40a5b3240b83e0e645a8ce35945c4ff Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Thu, 24 Sep 2020 16:53:04 +0100 Subject: [PATCH] Retain all stubs versions in the snapshot. This is a quick fix to avoid build failures due to prebuilts lacking stubs versions that the sources have, which causes dependencies on older version stubs fail on master-art-host where the sources of e.g. Bionic are no longer available. More work is required to make the version handling of stubs DTRT - a TODO comment outlines it. Test: m nothing Test: `m runtime-module-sdk`, check that the generated Android.bp has the full stubs.versions list like the sources. Bug: 169373910 Change-Id: I0ebfaf94f9d45a0e58d9785c40e7cea626f0ab83 --- cc/library_sdk_member.go | 18 +++++++++++------- sdk/cc_sdk_test.go | 24 ++++++++++++++++++++---- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go index 2f1554427..d72050cbe 100644 --- a/cc/library_sdk_member.go +++ b/cc/library_sdk_member.go @@ -295,9 +295,9 @@ func addPossiblyArchSpecificProperties(sdkModuleContext android.ModuleContext, b outputProperties.AddProperty(property, includeDirs[property]) } - if len(libInfo.StubsVersion) > 0 { + if len(libInfo.StubsVersions) > 0 { stubsSet := outputProperties.AddPropertySet("stubs") - stubsSet.AddProperty("versions", []string{libInfo.StubsVersion}) + stubsSet.AddProperty("versions", libInfo.StubsVersions) } } @@ -368,10 +368,10 @@ type nativeLibInfoProperties struct { // The specific stubs version for the lib variant, or empty string if stubs // are not in use. // - // Marked 'ignored-on-host' as the StubsVersion() from which this is initialized is - // not set on host and the stubs.versions property which this is written to is does - // not vary by arch so cannot be android specific. - StubsVersion string `sdk:"ignored-on-host"` + // Marked 'ignored-on-host' as the AllStubsVersions() from which this is + // initialized is not set on host and the stubs.versions property which this + // is written to does not vary by arch so cannot be android specific. + StubsVersions []string `sdk:"ignored-on-host"` // Value of SanitizeProperties.Sanitize.Never. Needs to be propagated for CRT objects. SanitizeNever bool `android:"arch_variant"` @@ -420,7 +420,11 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte p.exportedGeneratedHeaders = ccModule.ExportedGeneratedHeaders() if ccModule.HasStubsVariants() { - p.StubsVersion = ccModule.StubsVersion() + // TODO(b/169373910): 1. Only output the specific version (from + // ccModule.StubsVersion()) if the module is versioned. 2. Ensure that all + // the versioned stub libs are retained in the prebuilt tree; currently only + // the stub corresponding to ccModule.StubsVersion() is. + p.StubsVersions = ccModule.AllStubsVersions() } if ccModule.sanitize != nil && proptools.Bool(ccModule.sanitize.Properties.Sanitize.Never) { diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go index 8c9e2285d..a12bc6f91 100644 --- a/sdk/cc_sdk_test.go +++ b/sdk/cc_sdk_test.go @@ -2330,7 +2330,11 @@ cc_prebuilt_library_shared { installable: false, compile_multilib: "both", stubs: { - versions: ["3"], + versions: [ + "1", + "2", + "3", + ], }, arch: { arm64: { @@ -2347,7 +2351,11 @@ cc_prebuilt_library_shared { prefer: false, compile_multilib: "both", stubs: { - versions: ["3"], + versions: [ + "1", + "2", + "3", + ], }, arch: { arm64: { @@ -2401,7 +2409,11 @@ cc_prebuilt_library_shared { installable: false, compile_multilib: "both", stubs: { - versions: ["3"], + versions: [ + "1", + "2", + "3", + ], }, target: { host: { @@ -2431,7 +2443,11 @@ cc_prebuilt_library_shared { host_supported: true, compile_multilib: "both", stubs: { - versions: ["3"], + versions: [ + "1", + "2", + "3", + ], }, target: { host: {