Merge ""current" is implicitly added to stubs.versions" am: 25c47a43a5
am: 4ce23de995
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1641782 Change-Id: Iccc85ac4a2c89e360b0c82fc61c06635e896bc43
This commit is contained in:
commit
cab9b4b25c
|
@ -22,6 +22,7 @@ import (
|
|||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -801,7 +802,7 @@ func TestApexWithStubs(t *testing.T) {
|
|||
mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_apex10000").Rule("ld").Args["libFlags"]
|
||||
|
||||
// Ensure that mylib is linking with the latest version of stubs for mylib2
|
||||
ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_3/mylib2.so")
|
||||
ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_current/mylib2.so")
|
||||
// ... and not linking to the non-stub (impl) variant of mylib2
|
||||
ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared/mylib2.so")
|
||||
|
||||
|
@ -1279,15 +1280,15 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
|
|||
name: "unspecified version links to the latest",
|
||||
minSdkVersion: "",
|
||||
apexVariant: "apex10000",
|
||||
shouldLink: "30",
|
||||
shouldNotLink: []string{"29"},
|
||||
shouldLink: "current",
|
||||
shouldNotLink: []string{"29", "30"},
|
||||
},
|
||||
{
|
||||
name: "always use the latest",
|
||||
minSdkVersion: "min_sdk_version: \"29\",",
|
||||
apexVariant: "apex29",
|
||||
shouldLink: "30",
|
||||
shouldNotLink: []string{"29"},
|
||||
shouldLink: "current",
|
||||
shouldNotLink: []string{"29", "30"},
|
||||
},
|
||||
}
|
||||
for _, tc := range testcases {
|
||||
|
@ -1354,7 +1355,11 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
|
|||
}
|
||||
|
||||
mylibCFlags := ctx.ModuleForTests("mylib", "android_vendor.VER_arm64_armv8-a_static_"+tc.apexVariant).Rule("cc").Args["cFlags"]
|
||||
ensureContains(t, mylibCFlags, "__LIBBAR_API__="+tc.shouldLink)
|
||||
ver := tc.shouldLink
|
||||
if tc.shouldLink == "current" {
|
||||
ver = strconv.Itoa(android.FutureApiLevelInt)
|
||||
}
|
||||
ensureContains(t, mylibCFlags, "__LIBBAR_API__="+ver)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1416,12 +1421,12 @@ func TestApexWithSystemLibsStubs(t *testing.T) {
|
|||
|
||||
// For dependency to libc
|
||||
// Ensure that mylib is linking with the latest version of stubs
|
||||
ensureContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_shared_29/libc.so")
|
||||
ensureContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_shared_current/libc.so")
|
||||
// ... and not linking to the non-stub (impl) variant
|
||||
ensureNotContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_shared/libc.so")
|
||||
// ... Cflags from stub is correctly exported to mylib
|
||||
ensureContains(t, mylibCFlags, "__LIBC_API__=29")
|
||||
ensureContains(t, mylibSharedCFlags, "__LIBC_API__=29")
|
||||
ensureContains(t, mylibCFlags, "__LIBC_API__=10000")
|
||||
ensureContains(t, mylibSharedCFlags, "__LIBC_API__=10000")
|
||||
|
||||
// For dependency to libm
|
||||
// Ensure that mylib is linking with the non-stub (impl) variant
|
||||
|
@ -1527,12 +1532,14 @@ func TestApexMinSdkVersion_NativeModulesShouldBeBuiltAgainstStubs(t *testing.T)
|
|||
}
|
||||
// platform liba is linked to non-stub version
|
||||
expectLink("liba", "shared", "libz", "shared")
|
||||
// liba in myapex is linked to #30
|
||||
expectLink("liba", "shared_apex29", "libz", "shared_30")
|
||||
// liba in myapex is linked to current
|
||||
expectLink("liba", "shared_apex29", "libz", "shared_current")
|
||||
expectNoLink("liba", "shared_apex29", "libz", "shared_30")
|
||||
expectNoLink("liba", "shared_apex29", "libz", "shared_28")
|
||||
expectNoLink("liba", "shared_apex29", "libz", "shared")
|
||||
// liba in otherapex is linked to #30
|
||||
expectLink("liba", "shared_apex30", "libz", "shared_30")
|
||||
// liba in otherapex is linked to current
|
||||
expectLink("liba", "shared_apex30", "libz", "shared_current")
|
||||
expectNoLink("liba", "shared_apex30", "libz", "shared_30")
|
||||
expectNoLink("liba", "shared_apex30", "libz", "shared_28")
|
||||
expectNoLink("liba", "shared_apex30", "libz", "shared")
|
||||
}
|
||||
|
@ -1583,7 +1590,8 @@ func TestApexMinSdkVersion_SupportsCodeNames(t *testing.T) {
|
|||
ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
|
||||
ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
|
||||
}
|
||||
expectLink("libx", "shared_apex10000", "libz", "shared_R")
|
||||
expectLink("libx", "shared_apex10000", "libz", "shared_current")
|
||||
expectNoLink("libx", "shared_apex10000", "libz", "shared_R")
|
||||
expectNoLink("libx", "shared_apex10000", "libz", "shared_29")
|
||||
expectNoLink("libx", "shared_apex10000", "libz", "shared")
|
||||
}
|
||||
|
@ -1629,8 +1637,9 @@ func TestApexMinSdkVersion_DefaultsToLatest(t *testing.T) {
|
|||
ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
|
||||
ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
|
||||
}
|
||||
expectLink("libx", "shared_apex10000", "libz", "shared_2")
|
||||
expectLink("libx", "shared_apex10000", "libz", "shared_current")
|
||||
expectNoLink("libx", "shared_apex10000", "libz", "shared_1")
|
||||
expectNoLink("libx", "shared_apex10000", "libz", "shared_2")
|
||||
expectNoLink("libx", "shared_apex10000", "libz", "shared")
|
||||
}
|
||||
|
||||
|
@ -1677,7 +1686,8 @@ func TestPlatformUsesLatestStubsFromApexes(t *testing.T) {
|
|||
ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
|
||||
ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
|
||||
}
|
||||
expectLink("libz", "shared", "libx", "shared_2")
|
||||
expectLink("libz", "shared", "libx", "shared_current")
|
||||
expectNoLink("libz", "shared", "libx", "shared_2")
|
||||
expectNoLink("libz", "shared", "libz", "shared_1")
|
||||
expectNoLink("libz", "shared", "libz", "shared")
|
||||
}
|
||||
|
@ -1724,7 +1734,7 @@ func TestQApexesUseLatestStubsInBundledBuildsAndHWASAN(t *testing.T) {
|
|||
libFlags := ld.Args["libFlags"]
|
||||
ensureContains(t, libFlags, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
|
||||
}
|
||||
expectLink("libx", "shared_hwasan_apex29", "libbar", "shared_30")
|
||||
expectLink("libx", "shared_hwasan_apex29", "libbar", "shared_current")
|
||||
}
|
||||
|
||||
func TestQTargetApexUsesStaticUnwinder(t *testing.T) {
|
||||
|
@ -2072,7 +2082,7 @@ func TestApexMinSdkVersion_OkayEvenWhenDepIsNewer_IfItSatisfiesApexMinSdkVersion
|
|||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
// mylib in myapex will link to mylib2#30
|
||||
// mylib in myapex will link to mylib2#current
|
||||
// mylib in otherapex will link to mylib2(non-stub) in otherapex as well
|
||||
cc_library {
|
||||
name: "mylib",
|
||||
|
@ -2106,7 +2116,7 @@ func TestApexMinSdkVersion_OkayEvenWhenDepIsNewer_IfItSatisfiesApexMinSdkVersion
|
|||
libFlags := ld.Args["libFlags"]
|
||||
ensureContains(t, libFlags, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
|
||||
}
|
||||
expectLink("mylib", "shared_apex29", "mylib2", "shared_30")
|
||||
expectLink("mylib", "shared_apex29", "mylib2", "shared_current")
|
||||
expectLink("mylib", "shared_apex30", "mylib2", "shared_apex30")
|
||||
}
|
||||
|
||||
|
@ -2174,10 +2184,10 @@ func TestApexMinSdkVersion_WorksWithActiveCodenames(t *testing.T) {
|
|||
}
|
||||
`, withSAsActiveCodeNames)
|
||||
|
||||
// ensure libfoo is linked with "S" version of libbar stub
|
||||
// ensure libfoo is linked with current version of libbar stub
|
||||
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared_apex10000")
|
||||
libFlags := libfoo.Rule("ld").Args["libFlags"]
|
||||
ensureContains(t, libFlags, "android_arm64_armv8-a_shared_T/libbar.so")
|
||||
ensureContains(t, libFlags, "android_arm64_armv8-a_shared_current/libbar.so")
|
||||
}
|
||||
|
||||
func TestFilesInSubDir(t *testing.T) {
|
||||
|
@ -7391,7 +7401,7 @@ func TestPrebuiltStubLibDep(t *testing.T) {
|
|||
t.Errorf("AndroidMk entry for \"stublib\" has LOCAL_NOT_AVAILABLE_FOR_PLATFORM set: %+v", entry.mkEntries)
|
||||
}
|
||||
cflags := entry.mkEntries.EntryMap["LOCAL_EXPORT_CFLAGS"]
|
||||
expected := "-D__STUBLIB_API__=1"
|
||||
expected := "-D__STUBLIB_API__=10000"
|
||||
if !android.InList(expected, cflags) {
|
||||
t.Errorf("LOCAL_EXPORT_CFLAGS expected to have %q, but got %q", expected, cflags)
|
||||
}
|
||||
|
|
|
@ -2672,9 +2672,11 @@ func TestLlndkLibrary(t *testing.T) {
|
|||
expected := []string{
|
||||
"android_vendor.VER_arm64_armv8-a_shared_1",
|
||||
"android_vendor.VER_arm64_armv8-a_shared_2",
|
||||
"android_vendor.VER_arm64_armv8-a_shared_current",
|
||||
"android_vendor.VER_arm64_armv8-a_shared",
|
||||
"android_vendor.VER_arm_armv7-a-neon_shared_1",
|
||||
"android_vendor.VER_arm_armv7-a-neon_shared_2",
|
||||
"android_vendor.VER_arm_armv7-a-neon_shared_current",
|
||||
"android_vendor.VER_arm_armv7-a-neon_shared",
|
||||
}
|
||||
checkEquals(t, "variants for llndk stubs", expected, actual)
|
||||
|
@ -3174,10 +3176,12 @@ func TestVersionedStubs(t *testing.T) {
|
|||
"android_arm64_armv8-a_shared_1",
|
||||
"android_arm64_armv8-a_shared_2",
|
||||
"android_arm64_armv8-a_shared_3",
|
||||
"android_arm64_armv8-a_shared_current",
|
||||
"android_arm_armv7-a-neon_shared",
|
||||
"android_arm_armv7-a-neon_shared_1",
|
||||
"android_arm_armv7-a-neon_shared_2",
|
||||
"android_arm_armv7-a-neon_shared_3",
|
||||
"android_arm_armv7-a-neon_shared_current",
|
||||
}
|
||||
variantsMismatch := false
|
||||
if len(variants) != len(expectedVariants) {
|
||||
|
|
|
@ -65,7 +65,8 @@ type LibraryProperties struct {
|
|||
// symbols that are exported for stubs variant of this library.
|
||||
Symbol_file *string `android:"path"`
|
||||
|
||||
// List versions to generate stubs libs for.
|
||||
// List versions to generate stubs libs for. The version name "current" is always
|
||||
// implicitly added.
|
||||
Versions []string
|
||||
}
|
||||
|
||||
|
@ -171,6 +172,8 @@ type LibraryMutatedProperties struct {
|
|||
|
||||
// This variant is a stubs lib
|
||||
BuildStubs bool `blueprint:"mutated"`
|
||||
// This variant is the latest version
|
||||
IsLatestVersion bool `blueprint:"mutated"`
|
||||
// Version of the stubs lib
|
||||
StubsVersion string `blueprint:"mutated"`
|
||||
// List of all stubs versions associated with an implementation lib
|
||||
|
@ -775,7 +778,7 @@ type libraryInterface interface {
|
|||
|
||||
type versionedInterface interface {
|
||||
buildStubs() bool
|
||||
setBuildStubs()
|
||||
setBuildStubs(isLatest bool)
|
||||
hasStubsVariants() bool
|
||||
setStubsVersion(string)
|
||||
stubsVersion() string
|
||||
|
@ -1493,7 +1496,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
|
|||
if ctx.isVndk() && !ctx.IsVndkExt() {
|
||||
return
|
||||
}
|
||||
} else if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.directlyInAnyApex() {
|
||||
} else if library.hasStubsVariants() && !ctx.Host() && ctx.directlyInAnyApex() {
|
||||
// Bionic libraries (e.g. libc.so) is installed to the bootstrap subdirectory.
|
||||
// The original path becomes a symlink to the corresponding file in the
|
||||
// runtime APEX.
|
||||
|
@ -1609,11 +1612,29 @@ func (library *libraryDecorator) symbolFileForAbiCheck(ctx ModuleContext) *strin
|
|||
}
|
||||
|
||||
func (library *libraryDecorator) hasStubsVariants() bool {
|
||||
return len(library.Properties.Stubs.Versions) > 0
|
||||
// Just having stubs.symbol_file is enough to create a stub variant. In that case
|
||||
// the stub for the future API level is created.
|
||||
return library.Properties.Stubs.Symbol_file != nil ||
|
||||
len(library.Properties.Stubs.Versions) > 0
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) stubsVersions(ctx android.BaseMutatorContext) []string {
|
||||
return library.Properties.Stubs.Versions
|
||||
if !library.hasStubsVariants() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Future API level is implicitly added if there isn't
|
||||
vers := library.Properties.Stubs.Versions
|
||||
if inList(android.FutureApiLevel.String(), vers) {
|
||||
return vers
|
||||
}
|
||||
// In some cases, people use the raw value "10000" in the versions property.
|
||||
// We shouldn't add the future API level in that case, otherwise there will
|
||||
// be two identical versions.
|
||||
if inList(strconv.Itoa(android.FutureApiLevel.FinalOrFutureInt()), vers) {
|
||||
return vers
|
||||
}
|
||||
return append(vers, android.FutureApiLevel.String())
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) setStubsVersion(version string) {
|
||||
|
@ -1624,8 +1645,9 @@ func (library *libraryDecorator) stubsVersion() string {
|
|||
return library.MutatedProperties.StubsVersion
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) setBuildStubs() {
|
||||
func (library *libraryDecorator) setBuildStubs(isLatest bool) {
|
||||
library.MutatedProperties.BuildStubs = true
|
||||
library.MutatedProperties.IsLatestVersion = isLatest
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) setAllStubsVersions(versions []string) {
|
||||
|
@ -1637,8 +1659,7 @@ func (library *libraryDecorator) allStubsVersions() []string {
|
|||
}
|
||||
|
||||
func (library *libraryDecorator) isLatestStubVersion() bool {
|
||||
versions := library.Properties.Stubs.Versions
|
||||
return versions[len(versions)-1] == library.stubsVersion()
|
||||
return library.MutatedProperties.IsLatestVersion
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) availableFor(what string) bool {
|
||||
|
@ -1881,7 +1902,8 @@ func createVersionVariations(mctx android.BottomUpMutatorContext, versions []str
|
|||
c.stl = nil
|
||||
c.Properties.PreventInstall = true
|
||||
lib := moduleLibraryInterface(m)
|
||||
lib.setBuildStubs()
|
||||
isLatest := i == (len(versions) - 1)
|
||||
lib.setBuildStubs(isLatest)
|
||||
|
||||
if variants[i] != "" {
|
||||
// A non-LLNDK stubs module is hidden from make and has a dependency from the
|
||||
|
|
|
@ -2407,6 +2407,7 @@ cc_prebuilt_library_shared {
|
|||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"current",
|
||||
],
|
||||
},
|
||||
arch: {
|
||||
|
@ -2461,6 +2462,7 @@ cc_prebuilt_library_shared {
|
|||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"current",
|
||||
],
|
||||
},
|
||||
target: {
|
||||
|
@ -2500,6 +2502,7 @@ cc_prebuilt_library_shared {
|
|||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"current",
|
||||
],
|
||||
},
|
||||
target: {
|
||||
|
|
Loading…
Reference in New Issue