Add cc_library.target.vendor.no_stubs am: 85707de8c1

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2853091

Change-Id: I68411c3ff51a8f61f08f471cb8da31b79c252867
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jooyung Han 2023-12-05 05:57:01 +00:00 committed by Automerger Merge Worker
commit 578c212857
3 changed files with 83 additions and 0 deletions

View file

@ -4710,6 +4710,72 @@ func TestTestApex(t *testing.T) {
ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_shared")
}
func TestLibzVendorIsntStable(t *testing.T) {
ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
updatable: false,
binaries: ["mybin"],
}
apex {
name: "myvendorapex",
key: "myapex.key",
file_contexts: "myvendorapex_file_contexts",
vendor: true,
updatable: false,
binaries: ["mybin"],
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
cc_binary {
name: "mybin",
vendor_available: true,
system_shared_libs: [],
stl: "none",
shared_libs: ["libz"],
apex_available: ["//apex_available:anyapex"],
}
cc_library {
name: "libz",
vendor_available: true,
system_shared_libs: [],
stl: "none",
stubs: {
versions: ["28", "30"],
},
target: {
vendor: {
no_stubs: true,
},
},
}
`, withFiles(map[string][]byte{
"myvendorapex_file_contexts": nil,
}))
// libz provides stubs for core variant.
{
ensureExactContents(t, ctx, "myapex", "android_common_myapex", []string{
"bin/mybin",
})
apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexManifestRule")
android.AssertStringEquals(t, "should require libz", apexManifestRule.Args["requireNativeLibs"], "libz.so")
}
// libz doesn't provide stubs for vendor variant.
{
ensureExactContents(t, ctx, "myvendorapex", "android_common_myvendorapex", []string{
"bin/mybin",
"lib64/libz.so",
})
apexManifestRule := ctx.ModuleForTests("myvendorapex", "android_common_myvendorapex").Rule("apexManifestRule")
android.AssertStringEquals(t, "should not require libz", apexManifestRule.Args["requireNativeLibs"], "")
}
}
func TestApexWithTarget(t *testing.T) {
ctx := testApex(t, `
apex {

View file

@ -23,6 +23,8 @@ import (
"android/soong/android"
"android/soong/snapshot"
"github.com/google/blueprint/proptools"
)
var _ android.ImageInterface = (*Module)(nil)
@ -622,6 +624,10 @@ func squashVendorSrcs(m *Module) {
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
if lib.Properties.Target.Vendor.No_stubs {
proptools.Clear(&lib.Properties.Stubs)
}
}
}
@ -635,6 +641,10 @@ func squashProductSrcs(m *Module) {
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
lib.baseCompiler.Properties.Target.Product.Exclude_generated_sources...)
if lib.Properties.Target.Product.No_stubs {
proptools.Clear(&lib.Properties.Stubs)
}
}
}

View file

@ -107,6 +107,13 @@ type LibraryProperties struct {
Suffix *string `android:"arch_variant"`
Header_abi_checker headerAbiCheckerProperties
// Disable stubs for vendor/product variants
// This is a workaround to keep `stubs` only for "core" variant (not product/vendor).
// It would be nice if we could put `stubs` into a `target: { core: {} }`
// block but it's not supported in soong yet. This could be removed/simplified once we have
// a better syntax.
No_stubs bool
}
Platform struct {