Define product_available property

To make a module available to product variants, it must define
`product_available: true`. `vendor_available: true` will not create
product variants any more.
However, in this CL, we don't change the behavior of
`vendor_available` property. It still creates both variants. After we
update all Android.bp files that need to provide product variants
with `product_available: true`, we may upload the remaining patches.

Bug: 150902910
Test: lunch aosp_arm64-userdebug && m
Change-Id: I0fd5be7bbae2c45d5cab3c3c2ca49f53a9b6f975
This commit is contained in:
Justin Yun
2020-10-29 16:49:43 +09:00
parent b0a713acf9
commit 63e9ec70bb
16 changed files with 344 additions and 102 deletions

View File

@@ -46,6 +46,7 @@ toolchain_library {
name: "libatomic", name: "libatomic",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
product_available: true,
ramdisk_available: true, ramdisk_available: true,
vendor_ramdisk_available: true, vendor_ramdisk_available: true,
recovery_available: true, recovery_available: true,
@@ -71,6 +72,7 @@ toolchain_library {
name: "libgcc", name: "libgcc",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
native_bridge_supported: true, native_bridge_supported: true,
@@ -94,6 +96,7 @@ toolchain_library {
name: "libgcc_stripped", name: "libgcc_stripped",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
product_available: true,
ramdisk_available: true, ramdisk_available: true,
vendor_ramdisk_available: true, vendor_ramdisk_available: true,
recovery_available: true, recovery_available: true,

View File

@@ -2349,6 +2349,7 @@ func TestVendorApex_use_vndk_as_stable(t *testing.T) {
enabled: true, enabled: true,
}, },
vendor_available: true, vendor_available: true,
product_available: true,
} }
cc_library { cc_library {
name: "libvendor", name: "libvendor",
@@ -3022,6 +3023,7 @@ func TestVndkApexCurrent(t *testing.T) {
name: "libvndk", name: "libvndk",
srcs: ["mylib.cpp"], srcs: ["mylib.cpp"],
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3034,6 +3036,7 @@ func TestVndkApexCurrent(t *testing.T) {
name: "libvndksp", name: "libvndksp",
srcs: ["mylib.cpp"], srcs: ["mylib.cpp"],
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -3075,6 +3078,7 @@ func TestVndkApexWithPrebuilt(t *testing.T) {
name: "libvndk", name: "libvndk",
srcs: ["libvndk.so"], srcs: ["libvndk.so"],
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3087,6 +3091,7 @@ func TestVndkApexWithPrebuilt(t *testing.T) {
name: "libvndk.arm", name: "libvndk.arm",
srcs: ["libvndk.arm.so"], srcs: ["libvndk.arm.so"],
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3159,6 +3164,7 @@ func TestVndkApexVersion(t *testing.T) {
name: "libvndk27", name: "libvndk27",
version: "27", version: "27",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3178,6 +3184,7 @@ func TestVndkApexVersion(t *testing.T) {
name: "libvndk27", name: "libvndk27",
version: "27", version: "27",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3231,6 +3238,7 @@ func TestVndkApexErrorWithDuplicateVersion(t *testing.T) {
name: "libvndk", name: "libvndk",
srcs: ["mylib.cpp"], srcs: ["mylib.cpp"],
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3242,6 +3250,7 @@ func TestVndkApexErrorWithDuplicateVersion(t *testing.T) {
name: "libvndk", name: "libvndk",
version: "27", version: "27",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3301,6 +3310,7 @@ func TestVndkApexSkipsNativeBridgeSupportedModules(t *testing.T) {
name: "libvndk", name: "libvndk",
srcs: ["mylib.cpp"], srcs: ["mylib.cpp"],
vendor_available: true, vendor_available: true,
product_available: true,
native_bridge_supported: true, native_bridge_supported: true,
host_supported: true, host_supported: true,
vndk: { vndk: {
@@ -3340,6 +3350,7 @@ func TestVndkApexDoesntSupportNativeBridgeSupported(t *testing.T) {
name: "libvndk", name: "libvndk",
srcs: ["mylib.cpp"], srcs: ["mylib.cpp"],
vendor_available: true, vendor_available: true,
product_available: true,
native_bridge_supported: true, native_bridge_supported: true,
host_supported: true, host_supported: true,
vndk: { vndk: {
@@ -3371,6 +3382,7 @@ func TestVndkApexWithBinder32(t *testing.T) {
version: "27", version: "27",
target_arch: "arm", target_arch: "arm",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3387,6 +3399,7 @@ func TestVndkApexWithBinder32(t *testing.T) {
target_arch: "arm", target_arch: "arm",
binder32bit: true, binder32bit: true,
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -3434,6 +3447,7 @@ func TestVndkApexShouldNotProvideNativeLibs(t *testing.T) {
cc_library { cc_library {
name: "libz", name: "libz",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },

View File

@@ -25,6 +25,7 @@ func TestVndkApexForVndkLite(t *testing.T) {
name: "libvndk", name: "libvndk",
srcs: ["mylib.cpp"], srcs: ["mylib.cpp"],
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -37,6 +38,7 @@ func TestVndkApexForVndkLite(t *testing.T) {
name: "libvndksp", name: "libvndksp",
srcs: ["mylib.cpp"], srcs: ["mylib.cpp"],
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -73,6 +75,7 @@ func TestVndkApexUsesVendorVariant(t *testing.T) {
cc_library { cc_library {
name: "libfoo", name: "libfoo",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },

View File

@@ -314,26 +314,39 @@ type BaseProperties struct {
type VendorProperties struct { type VendorProperties struct {
// whether this module should be allowed to be directly depended by other // whether this module should be allowed to be directly depended by other
// modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`. // modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`.
// In addition, this module should be allowed to be directly depended by // If set to true, two variants will be built separately, one like
// product modules with `product_specific: true`. // normal, and the other limited to the set of libraries and headers
// If set to true, three variants will be built separately, one like // that are exposed to /vendor modules.
// normal, another limited to the set of libraries and headers
// that are exposed to /vendor modules, and the other to /product modules.
// //
// The vendor and product variants may be used with a different (newer) /system, // The vendor variant may be used with a different (newer) /system,
// so it shouldn't have any unversioned runtime dependencies, or // so it shouldn't have any unversioned runtime dependencies, or
// make assumptions about the system that may not be true in the // make assumptions about the system that may not be true in the
// future. // future.
// //
// If set to false, this module becomes inaccessible from /vendor or /product // If set to false, this module becomes inaccessible from /vendor modules.
// modules.
// //
// Default value is true when vndk: {enabled: true} or vendor: true. // Default value is true when vndk: {enabled: true} or vendor: true.
// //
// Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
// If PRODUCT_PRODUCT_VNDK_VERSION isn't set, product variant will not be used.
Vendor_available *bool Vendor_available *bool
// whether this module should be allowed to be directly depended by other
// modules with `product_specific: true` or `product_available: true`.
// If set to true, an additional product variant will be built separately
// that is limited to the set of libraries and headers that are exposed to
// /product modules.
//
// The product variant may be used with a different (newer) /system,
// so it shouldn't have any unversioned runtime dependencies, or
// make assumptions about the system that may not be true in the
// future.
//
// It must be set to true by default for vndk: {enabled: true} modules.
//
// Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
// and PRODUCT_PRODUCT_VNDK_VERSION isn't set.
Product_available *bool
// whether this module is capable of being loaded with other instance // whether this module is capable of being loaded with other instance
// (possibly an older version) of the same module in the same process. // (possibly an older version) of the same module in the same process.
// Currently, a shared library that is a member of VNDK (vndk: {enabled: true}) // Currently, a shared library that is a member of VNDK (vndk: {enabled: true})
@@ -899,7 +912,7 @@ func (c *Module) isDependencyRoot() bool {
// "product" and "vendor" variant modules return true for this function. // "product" and "vendor" variant modules return true for this function.
// When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true", // When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true",
// "soc_specific: true" and more vendor installed modules are included here. // "soc_specific: true" and more vendor installed modules are included here.
// When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "vendor_available: true" or // When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "product_available: true" or
// "product_specific: true" modules are included here. // "product_specific: true" modules are included here.
func (c *Module) UseVndk() bool { func (c *Module) UseVndk() bool {
return c.Properties.VndkVersion != "" return c.Properties.VndkVersion != ""
@@ -1352,7 +1365,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
_, llndk := c.linker.(*llndkStubDecorator) _, llndk := c.linker.(*llndkStubDecorator)
_, llndkHeader := c.linker.(*llndkHeadersDecorator) _, llndkHeader := c.linker.(*llndkHeadersDecorator)
if llndk || llndkHeader || (c.UseVndk() && c.HasVendorVariant()) { if llndk || llndkHeader || (c.UseVndk() && c.HasNonSystemVariants()) {
// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is // .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
// added for product variant only when we have vendor and product variants with core // added for product variant only when we have vendor and product variants with core
// variant. The suffix is not added for vendor-only or product-only module. // variant. The suffix is not added for vendor-only or product-only module.
@@ -1993,9 +2006,9 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
// VNDK is cc.Module supported only for now. // VNDK is cc.Module supported only for now.
if ccFrom, ok := from.(*Module); ok && from.UseVndk() { if ccFrom, ok := from.(*Module); ok && from.UseVndk() {
// Though vendor code is limited by the vendor mutator, // Though allowed dependency is limited by the image mutator,
// each vendor-available module needs to check // each vendor and product module needs to check link-type
// link-type for VNDK. // for VNDK.
if ccTo, ok := to.(*Module); ok { if ccTo, ok := to.(*Module); ok {
if ccFrom.vndkdep != nil { if ccFrom.vndkdep != nil {
ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag) ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag)
@@ -2126,9 +2139,10 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
return false return false
} }
// Even if target lib has no vendor variant, keep checking dependency graph // Even if target lib has no vendor variant, keep checking dependency
// in case it depends on vendor_available but not double_loadable transtively. // graph in case it depends on vendor_available or product_available
if !to.HasVendorVariant() { // but not double_loadable transtively.
if !to.HasNonSystemVariants() {
return true return true
} }
@@ -2771,6 +2785,7 @@ func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
return "native:vndk_private" return "native:vndk_private"
} }
if c.IsVndk() && !c.isVndkExt() { if c.IsVndk() && !c.isVndkExt() {
// Product_available, if defined, must have the same value with Vendor_available.
if Bool(c.VendorProperties.Vendor_available) { if Bool(c.VendorProperties.Vendor_available) {
return "native:vndk" return "native:vndk"
} }
@@ -3008,38 +3023,6 @@ func DefaultsFactory(props ...interface{}) android.Module {
return module return module
} }
func squashVendorSrcs(m *Module) {
if lib, ok := m.compiler.(*libraryDecorator); ok {
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
lib.baseCompiler.Properties.Target.Vendor.Srcs...)
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
}
}
func squashRecoverySrcs(m *Module) {
if lib, ok := m.compiler.(*libraryDecorator); ok {
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
lib.baseCompiler.Properties.Target.Recovery.Srcs...)
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...)
}
}
func squashVendorRamdiskSrcs(m *Module) {
if lib, ok := m.compiler.(*libraryDecorator); ok {
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...)
}
}
func (c *Module) IsSdkVariant() bool { func (c *Module) IsSdkVariant() bool {
return c.Properties.IsSdkVariant || c.AlwaysSdk() return c.Properties.IsSdkVariant || c.AlwaysSdk()
} }

View File

@@ -326,6 +326,7 @@ func TestVndk(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -335,6 +336,7 @@ func TestVndk(t *testing.T) {
cc_library { cc_library {
name: "libvndk_private", name: "libvndk_private",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -345,6 +347,7 @@ func TestVndk(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -356,6 +359,7 @@ func TestVndk(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp_private", name: "libvndk_sp_private",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -386,6 +390,7 @@ func TestVndk(t *testing.T) {
config := TestConfig(buildDir, android.Android, nil, bp, nil) config := TestConfig(buildDir, android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current") config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("VER") config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
ctx := testCcWithConfig(t, config) ctx := testCcWithConfig(t, config)
@@ -397,6 +402,11 @@ func TestVndk(t *testing.T) {
checkVndkModule(t, ctx, "libvndk_sp", "", true, "", vendorVariant) checkVndkModule(t, ctx, "libvndk_sp", "", true, "", vendorVariant)
checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", vendorVariant) checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", vendorVariant)
checkVndkModule(t, ctx, "libvndk", "", false, "", productVariant)
checkVndkModule(t, ctx, "libvndk_private", "", false, "", productVariant)
checkVndkModule(t, ctx, "libvndk_sp", "", true, "", productVariant)
checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", productVariant)
// Check VNDK snapshot output. // Check VNDK snapshot output.
snapshotDir := "vndk-snapshot" snapshotDir := "vndk-snapshot"
@@ -454,6 +464,7 @@ func TestVndkWithHostSupported(t *testing.T) {
cc_library { cc_library {
name: "libvndk_host_supported", name: "libvndk_host_supported",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -463,6 +474,7 @@ func TestVndkWithHostSupported(t *testing.T) {
cc_library { cc_library {
name: "libvndk_host_supported_but_disabled_on_device", name: "libvndk_host_supported_but_disabled_on_device",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -503,6 +515,7 @@ func TestVndkUsingCoreVariant(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -512,6 +525,7 @@ func TestVndkUsingCoreVariant(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -522,6 +536,7 @@ func TestVndkUsingCoreVariant(t *testing.T) {
cc_library { cc_library {
name: "libvndk2", name: "libvndk2",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -647,6 +662,7 @@ func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -665,12 +681,28 @@ func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
}) })
} }
func TestVndkModuleError(t *testing.T) {
// Check the error message for vendor_available and product_available properties.
testCcError(t, "product_available: may not have different value than `vendor_available`", `
cc_library {
name: "libvndk",
vendor_available: true,
product_available: false,
vndk: {
enabled: true,
},
nocrt: true,
}
`)
}
func TestVndkDepError(t *testing.T) { func TestVndkDepError(t *testing.T) {
// Check whether an error is emitted when a VNDK lib depends on a system lib. // Check whether an error is emitted when a VNDK lib depends on a system lib.
testCcError(t, "dependency \".*\" of \".*\" missing variant", ` testCcError(t, "dependency \".*\" of \".*\" missing variant", `
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -689,6 +721,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -708,6 +741,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -727,6 +761,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -747,6 +782,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -758,6 +794,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -770,6 +807,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -789,6 +827,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndkprivate", name: "libvndkprivate",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -808,6 +847,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndksp", name: "libvndksp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -828,6 +868,7 @@ func TestVndkDepError(t *testing.T) {
cc_library { cc_library {
name: "libvndkspprivate", name: "libvndkspprivate",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -861,6 +902,7 @@ func TestDoubleLoadbleDep(t *testing.T) {
cc_library { cc_library {
name: "libdoubleloadable", name: "libdoubleloadable",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -883,6 +925,7 @@ func TestDoubleLoadbleDep(t *testing.T) {
cc_library { cc_library {
name: "libvndksp", name: "libvndksp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -909,6 +952,7 @@ func TestDoubleLoadbleDep(t *testing.T) {
cc_library { cc_library {
name: "libdoubleloadable", name: "libdoubleloadable",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -919,6 +963,7 @@ func TestDoubleLoadbleDep(t *testing.T) {
cc_library { cc_library {
name: "libnondoubleloadable", name: "libnondoubleloadable",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -957,6 +1002,7 @@ func TestVendorSnapshotCapture(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1090,6 +1136,7 @@ func TestVendorSnapshotUse(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1124,6 +1171,7 @@ func TestVendorSnapshotUse(t *testing.T) {
version: "BOARD", version: "BOARD",
target_arch: "arm64", target_arch: "arm64",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1566,6 +1614,7 @@ func TestDoubleLoadableDepError(t *testing.T) {
cc_library { cc_library {
name: "libnondoubleloadable", name: "libnondoubleloadable",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1619,6 +1668,7 @@ func TestDoubleLoadableDepError(t *testing.T) {
cc_library { cc_library {
name: "libnondoubleloadable", name: "libnondoubleloadable",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1630,6 +1680,7 @@ func TestDoubleLoadableDepError(t *testing.T) {
cc_library { cc_library {
name: "libdoubleloadable", name: "libdoubleloadable",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1640,6 +1691,7 @@ func TestDoubleLoadableDepError(t *testing.T) {
cc_library { cc_library {
name: "libnondoubleloadable", name: "libnondoubleloadable",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1678,6 +1730,7 @@ func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) {
name: "libvndksp", name: "libvndksp",
shared_libs: ["libanothervndksp"], shared_libs: ["libanothervndksp"],
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -1707,6 +1760,7 @@ func TestVndkExt(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1715,6 +1769,7 @@ func TestVndkExt(t *testing.T) {
cc_library { cc_library {
name: "libvndk2", name: "libvndk2",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1722,6 +1777,9 @@ func TestVndkExt(t *testing.T) {
vendor: { vendor: {
suffix: "-suffix", suffix: "-suffix",
}, },
product: {
suffix: "-suffix",
},
}, },
nocrt: true, nocrt: true,
} }
@@ -1789,6 +1847,7 @@ func TestVndkExtWithoutBoardVndkVersion(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1819,6 +1878,7 @@ func TestVndkExtWithoutProductVndkVersion(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1849,6 +1909,7 @@ func TestVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1869,6 +1930,7 @@ func TestVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1889,6 +1951,7 @@ func TestVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1909,6 +1972,7 @@ func TestVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1919,6 +1983,7 @@ func TestVndkExtError(t *testing.T) {
name: "libvndk_ext_product", name: "libvndk_ext_product",
product_specific: true, product_specific: true,
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
extends: "libvndk", extends: "libvndk",
@@ -1934,6 +1999,7 @@ func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -1956,6 +2022,7 @@ func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -1982,6 +2049,7 @@ func TestVndkExtVendorAvailableFalseError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2003,6 +2071,7 @@ func TestVndkExtVendorAvailableFalseError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2027,6 +2096,7 @@ func TestVendorModuleUseVndkExt(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2046,6 +2116,7 @@ func TestVendorModuleUseVndkExt(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2079,6 +2150,7 @@ func TestVndkExtUseVendorLib(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2108,6 +2180,7 @@ func TestVndkExtUseVendorLib(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2140,6 +2213,7 @@ func TestProductVndkExtDependency(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2160,6 +2234,7 @@ func TestProductVndkExtDependency(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2207,6 +2282,7 @@ func TestVndkSpExtUseVndkError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2216,6 +2292,7 @@ func TestVndkSpExtUseVndkError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2242,6 +2319,7 @@ func TestVndkSpExtUseVndkError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2261,6 +2339,7 @@ func TestVndkSpExtUseVndkError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2289,6 +2368,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2308,6 +2388,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk2", name: "libvndk2",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2320,6 +2401,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2339,6 +2421,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk2", name: "libvndk2",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2355,6 +2438,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2376,6 +2460,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp_2", name: "libvndk_sp_2",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2389,6 +2474,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2408,6 +2494,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp2", name: "libvndk_sp2",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2434,6 +2521,7 @@ func TestEnforceProductVndkVersion(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2442,6 +2530,7 @@ func TestEnforceProductVndkVersion(t *testing.T) {
cc_library { cc_library {
name: "libvndk_sp", name: "libvndk_sp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2453,6 +2542,11 @@ func TestEnforceProductVndkVersion(t *testing.T) {
vendor_available: true, vendor_available: true,
nocrt: true, nocrt: true,
} }
cc_library {
name: "libpa",
product_available: true,
nocrt: true,
}
cc_library { cc_library {
name: "libproduct_va", name: "libproduct_va",
product_specific: true, product_specific: true,
@@ -2466,7 +2560,7 @@ func TestEnforceProductVndkVersion(t *testing.T) {
"libllndk", "libllndk",
"libvndk", "libvndk",
"libvndk_sp", "libvndk_sp",
"libva", "libpa",
"libproduct_va", "libproduct_va",
], ],
nocrt: true, nocrt: true,
@@ -2538,6 +2632,7 @@ func TestEnforceProductVndkVersionErrors(t *testing.T) {
cc_library { cc_library {
name: "libvndk_private", name: "libvndk_private",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2581,6 +2676,7 @@ func TestMakeLinkType(t *testing.T) {
cc_library { cc_library {
name: "libvndk", name: "libvndk",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2588,6 +2684,7 @@ func TestMakeLinkType(t *testing.T) {
cc_library { cc_library {
name: "libvndksp", name: "libvndksp",
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
support_system_process: true, support_system_process: true,
@@ -2596,6 +2693,7 @@ func TestMakeLinkType(t *testing.T) {
cc_library { cc_library {
name: "libvndkprivate", name: "libvndkprivate",
vendor_available: false, vendor_available: false,
product_available: false,
vndk: { vndk: {
enabled: true, enabled: true,
}, },
@@ -2618,6 +2716,7 @@ func TestMakeLinkType(t *testing.T) {
target_arch: "arm", target_arch: "arm",
binder32bit: true, binder32bit: true,
vendor_available: true, vendor_available: true,
product_available: true,
vndk: { vndk: {
enabled: true, enabled: true,
}, },

View File

@@ -143,21 +143,21 @@ type BaseCompilerProperties struct {
} `android:"arch_variant"` } `android:"arch_variant"`
Target struct { Target struct {
Vendor struct { Vendor, Product struct {
// list of source files that should only be used in the // list of source files that should only be used in vendor or
// vendor variant of the C/C++ module. // product variant of the C/C++ module.
Srcs []string `android:"path"` Srcs []string `android:"path"`
// list of source files that should not be used to // list of source files that should not be used to build vendor
// build the vendor variant of the C/C++ module. // or product variant of the C/C++ module.
Exclude_srcs []string `android:"path"` Exclude_srcs []string `android:"path"`
// List of additional cflags that should be used to build the vendor // List of additional cflags that should be used to build vendor
// variant of the C/C++ module. // or product variant of the C/C++ module.
Cflags []string Cflags []string
// list of generated sources that should not be used to // list of generated sources that should not be used to build
// build the vendor variant of the C/C++ module. // vendor or product variant of the C/C++ module.
Exclude_generated_sources []string Exclude_generated_sources []string
} }
Recovery struct { Recovery struct {
@@ -298,6 +298,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
CheckBadCompilerFlags(ctx, "conlyflags", compiler.Properties.Conlyflags) CheckBadCompilerFlags(ctx, "conlyflags", compiler.Properties.Conlyflags)
CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags) CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags)
CheckBadCompilerFlags(ctx, "vendor.cflags", compiler.Properties.Target.Vendor.Cflags) CheckBadCompilerFlags(ctx, "vendor.cflags", compiler.Properties.Target.Vendor.Cflags)
CheckBadCompilerFlags(ctx, "product.cflags", compiler.Properties.Target.Product.Cflags)
CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags) CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags)
CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags) CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags)
@@ -473,7 +474,12 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.Local.ConlyFlags = append([]string{"-std=" + cStd}, flags.Local.ConlyFlags...) flags.Local.ConlyFlags = append([]string{"-std=" + cStd}, flags.Local.ConlyFlags...)
flags.Local.CppFlags = append([]string{"-std=" + cppStd}, flags.Local.CppFlags...) flags.Local.CppFlags = append([]string{"-std=" + cppStd}, flags.Local.CppFlags...)
if ctx.useVndk() { if ctx.inVendor() {
flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...)
}
if ctx.inProduct() {
// TODO(b/150902910): must use 'compiler.Properties.Target.Product.Cflags'
flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...) flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...)
} }

View File

@@ -25,6 +25,7 @@ func init() {
type GenruleExtraProperties struct { type GenruleExtraProperties struct {
Vendor_available *bool Vendor_available *bool
Product_available *bool
Ramdisk_available *bool Ramdisk_available *bool
Vendor_ramdisk_available *bool Vendor_ramdisk_available *bool
Recovery_available *bool Recovery_available *bool
@@ -62,7 +63,7 @@ func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext
return false return false
} }
return Bool(g.Vendor_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific()) return Bool(g.Vendor_available) || Bool(g.Product_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific())
} }
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool { func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
@@ -100,7 +101,8 @@ func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleCont
return variants return variants
} }
if Bool(g.Vendor_available) || ctx.ProductSpecific() { // TODO(b/150902910): vendor_available will not create product variant. Remove Bool(g.Vendor_available)
if Bool(g.Vendor_available) || Bool(g.Product_available) || ctx.ProductSpecific() {
variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion()) variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
if vndkVersion := ctx.DeviceConfig().ProductVndkVersion(); vndkVersion != "current" { if vndkVersion := ctx.DeviceConfig().ProductVndkVersion(); vndkVersion != "current" {
variants = append(variants, ProductVariationPrefix+vndkVersion) variants = append(variants, ProductVariationPrefix+vndkVersion)

View File

@@ -65,8 +65,9 @@ const (
) )
func (ctx *moduleContext) ProductSpecific() bool { func (ctx *moduleContext) ProductSpecific() bool {
//TODO(b/150902910): Replace HasNonSystemVariants() with HasProductVariant()
return ctx.ModuleContext.ProductSpecific() || return ctx.ModuleContext.ProductSpecific() ||
(ctx.mod.HasVendorVariant() && ctx.mod.inProduct()) (ctx.mod.HasNonSystemVariants() && ctx.mod.inProduct())
} }
func (ctx *moduleContext) SocSpecific() bool { func (ctx *moduleContext) SocSpecific() bool {
@@ -94,12 +95,21 @@ func (ctx *moduleContextImpl) inRecovery() bool {
return ctx.mod.InRecovery() return ctx.mod.InRecovery()
} }
// Returns true only when this module is configured to have core, product and vendor // Returns true when this module is configured to have core and vendor variants.
// variants.
func (c *Module) HasVendorVariant() bool { func (c *Module) HasVendorVariant() bool {
return c.IsVndk() || Bool(c.VendorProperties.Vendor_available) return c.IsVndk() || Bool(c.VendorProperties.Vendor_available)
} }
// Returns true when this module is configured to have core and product variants.
func (c *Module) HasProductVariant() bool {
return c.IsVndk() || Bool(c.VendorProperties.Product_available)
}
// Returns true when this module is configured to have core and either product or vendor variants.
func (c *Module) HasNonSystemVariants() bool {
return c.IsVndk() || Bool(c.VendorProperties.Vendor_available) || Bool(c.VendorProperties.Product_available)
}
// Returns true if the module is "product" variant. Usually these modules are installed in /product // Returns true if the module is "product" variant. Usually these modules are installed in /product
func (c *Module) inProduct() bool { func (c *Module) inProduct() bool {
return c.Properties.ImageVariationPrefix == ProductVariationPrefix return c.Properties.ImageVariationPrefix == ProductVariationPrefix
@@ -139,9 +149,30 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific() vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
productSpecific := mctx.ProductSpecific() productSpecific := mctx.ProductSpecific()
if m.VendorProperties.Vendor_available != nil && vendorSpecific { if m.VendorProperties.Vendor_available != nil {
mctx.PropertyErrorf("vendor_available", if vendorSpecific {
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`") mctx.PropertyErrorf("vendor_available",
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
}
// If defined, make sure vendor_available and product_available has the
// same value since `false` for these properties means the module is
// for system only but provides the variant.
if m.VendorProperties.Product_available != nil {
if Bool(m.VendorProperties.Vendor_available) != Bool(m.VendorProperties.Product_available) {
mctx.PropertyErrorf("product_available", "may not have different value than `vendor_available`")
}
}
}
if m.VendorProperties.Product_available != nil {
if productSpecific {
mctx.PropertyErrorf("product_available",
"doesn't make sense at the same time as `product_specific: true`")
}
if vendorSpecific {
mctx.PropertyErrorf("product_available",
"cannot provide product variant from a vendor module. Please use `product_specific: true` with `vendor_available: true`")
}
} }
if vndkdep := m.vndkdep; vndkdep != nil { if vndkdep := m.vndkdep; vndkdep != nil {
@@ -153,6 +184,9 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
} else if m.VendorProperties.Vendor_available != nil { } else if m.VendorProperties.Vendor_available != nil {
mctx.PropertyErrorf("vendor_available", mctx.PropertyErrorf("vendor_available",
"must not set at the same time as `vndk: {extends: \"...\"}`") "must not set at the same time as `vndk: {extends: \"...\"}`")
} else if m.VendorProperties.Product_available != nil {
mctx.PropertyErrorf("product_available",
"must not set at the same time as `vndk: {extends: \"...\"}`")
} }
} else { } else {
if vndkdep.isVndkExt() { if vndkdep.isVndkExt() {
@@ -231,21 +265,25 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
} else { } else {
mctx.ModuleErrorf("version is unknown for snapshot prebuilt") mctx.ModuleErrorf("version is unknown for snapshot prebuilt")
} }
} else if m.HasVendorVariant() && !m.isVndkExt() { } else if m.HasNonSystemVariants() && !m.isVndkExt() {
// This will be available in /system, /vendor and /product // This will be available to /system unless it is product_specific
// or a /system directory that is available to vendor and product. // which will be handled later.
coreVariantNeeded = true coreVariantNeeded = true
// We assume that modules under proprietary paths are compatible for // We assume that modules under proprietary paths are compatible for
// BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
// PLATFORM_VNDK_VERSION. // PLATFORM_VNDK_VERSION.
if isVendorProprietaryModule(mctx) { if m.HasVendorVariant() {
vendorVariants = append(vendorVariants, boardVndkVersion) if isVendorProprietaryModule(mctx) {
} else { vendorVariants = append(vendorVariants, boardVndkVersion)
vendorVariants = append(vendorVariants, platformVndkVersion) } else {
vendorVariants = append(vendorVariants, platformVndkVersion)
}
} }
// vendor_available modules are also available to /product. // vendor_available modules are also available to /product.
// TODO(b/150902910): product variant will be created only if
// m.HasProductVariant() is true.
productVariants = append(productVariants, platformVndkVersion) productVariants = append(productVariants, platformVndkVersion)
// VNDK is always PLATFORM_VNDK_VERSION // VNDK is always PLATFORM_VNDK_VERSION
if !m.IsVndk() { if !m.IsVndk() {
@@ -351,6 +389,51 @@ func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
return c.Properties.ExtraVariants return c.Properties.ExtraVariants
} }
func squashVendorSrcs(m *Module) {
if lib, ok := m.compiler.(*libraryDecorator); ok {
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
lib.baseCompiler.Properties.Target.Vendor.Srcs...)
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
}
}
func squashProductSrcs(m *Module) {
if lib, ok := m.compiler.(*libraryDecorator); ok {
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
lib.baseCompiler.Properties.Target.Product.Srcs...)
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
lib.baseCompiler.Properties.Target.Product.Exclude_srcs...)
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
lib.baseCompiler.Properties.Target.Product.Exclude_generated_sources...)
}
}
func squashRecoverySrcs(m *Module) {
if lib, ok := m.compiler.(*libraryDecorator); ok {
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
lib.baseCompiler.Properties.Target.Recovery.Srcs...)
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...)
}
}
func squashVendorRamdiskSrcs(m *Module) {
if lib, ok := m.compiler.(*libraryDecorator); ok {
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...)
}
}
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) { func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module) m := module.(*Module)
if variant == android.RamdiskVariation { if variant == android.RamdiskVariation {
@@ -376,6 +459,7 @@ func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string
} else if strings.HasPrefix(variant, ProductVariationPrefix) { } else if strings.HasPrefix(variant, ProductVariationPrefix) {
m.Properties.ImageVariationPrefix = ProductVariationPrefix m.Properties.ImageVariationPrefix = ProductVariationPrefix
m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix) m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
// TODO (b/150902910): This will be replaced with squashProductSrcs(m).
squashVendorSrcs(m) squashVendorSrcs(m)
} }
} }

View File

@@ -72,7 +72,7 @@ type LibraryProperties struct {
Suffix *string `android:"arch_variant"` Suffix *string `android:"arch_variant"`
Target struct { Target struct {
Vendor struct { Vendor, Product struct {
// set suffix of the name of the output // set suffix of the name of the output
Suffix *string `android:"arch_variant"` Suffix *string `android:"arch_variant"`
} }
@@ -172,11 +172,11 @@ type FlagExporterProperties struct {
Export_system_include_dirs []string `android:"arch_variant"` Export_system_include_dirs []string `android:"arch_variant"`
Target struct { Target struct {
Vendor struct { Vendor, Product struct {
// list of exported include directories, like // list of exported include directories, like
// export_include_dirs, that will be applied to the // export_include_dirs, that will be applied to
// vendor variant of this library. This will overwrite // vendor or product variant of this library.
// any other declarations. // This will overwrite any other declarations.
Override_export_include_dirs []string Override_export_include_dirs []string
} }
} }
@@ -253,6 +253,7 @@ type flagExporter struct {
} }
func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths { func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
// TODO(b/150902910): product variant must use Target.Product
if ctx.useVndk() && f.Properties.Target.Vendor.Override_export_include_dirs != nil { if ctx.useVndk() && f.Properties.Target.Vendor.Override_export_include_dirs != nil {
return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Override_export_include_dirs) return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Override_export_include_dirs)
} else { } else {
@@ -716,6 +717,7 @@ func (library *libraryDecorator) getLibNameHelper(baseModuleName string, useVndk
suffix := "" suffix := ""
if useVndk { if useVndk {
// TODO(b/150902910): product variant must use Target.Product
suffix = String(library.Properties.Target.Vendor.Suffix) suffix = String(library.Properties.Target.Vendor.Suffix)
} }
if suffix == "" { if suffix == "" {
@@ -812,6 +814,7 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, library.SharedProperties.Shared.Export_shared_lib_headers...) deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, library.SharedProperties.Shared.Export_shared_lib_headers...)
deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, library.SharedProperties.Shared.Export_static_lib_headers...) deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, library.SharedProperties.Shared.Export_static_lib_headers...)
} }
// TODO(b/150902910): product variant must use Target.Product
if ctx.useVndk() { if ctx.useVndk() {
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs)
deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Vendor.Exclude_shared_libs) deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Vendor.Exclude_shared_libs)

View File

@@ -130,6 +130,10 @@ func (mt *librarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext,
pbm.AddProperty("vendor_available", true) pbm.AddProperty("vendor_available", true)
} }
if proptools.Bool(ccModule.VendorProperties.Product_available) {
pbm.AddProperty("product_available", true)
}
sdkVersion := ccModule.SdkVersion() sdkVersion := ccModule.SdkVersion()
if sdkVersion != "" { if sdkVersion != "" {
pbm.AddProperty("sdk_version", sdkVersion) pbm.AddProperty("sdk_version", sdkVersion)

View File

@@ -96,32 +96,32 @@ type BaseLinkerProperties struct {
Runtime_libs []string `android:"arch_variant"` Runtime_libs []string `android:"arch_variant"`
Target struct { Target struct {
Vendor struct { Vendor, Product struct {
// list of shared libs that only should be used to build the vendor // list of shared libs that only should be used to build vendor or
// variant of the C/C++ module. // product variant of the C/C++ module.
Shared_libs []string Shared_libs []string
// list of static libs that only should be used to build the vendor // list of static libs that only should be used to build vendor or
// variant of the C/C++ module. // product variant of the C/C++ module.
Static_libs []string Static_libs []string
// list of shared libs that should not be used to build the vendor variant // list of shared libs that should not be used to build vendor or
// of the C/C++ module. // product variant of the C/C++ module.
Exclude_shared_libs []string Exclude_shared_libs []string
// list of static libs that should not be used to build the vendor variant // list of static libs that should not be used to build vendor or
// of the C/C++ module. // product variant of the C/C++ module.
Exclude_static_libs []string Exclude_static_libs []string
// list of header libs that should not be used to build the vendor variant // list of header libs that should not be used to build vendor or
// of the C/C++ module. // product variant of the C/C++ module.
Exclude_header_libs []string Exclude_header_libs []string
// list of runtime libs that should not be installed along with the vendor // list of runtime libs that should not be installed along with
// variant of the C/C++ module. // vendor or variant of the C/C++ module.
Exclude_runtime_libs []string Exclude_runtime_libs []string
// version script for this vendor variant // version script for vendor or product variant
Version_script *string `android:"arch_variant"` Version_script *string `android:"arch_variant"`
} }
Recovery struct { Recovery struct {
@@ -243,6 +243,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.WholeStaticLibs = append(deps.WholeStaticLibs, "libbuildversion") deps.WholeStaticLibs = append(deps.WholeStaticLibs, "libbuildversion")
} }
// TODO(b/150902910): product variant must use Target.Product
if ctx.useVndk() { if ctx.useVndk() {
deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Vendor.Shared_libs...) deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Vendor.Shared_libs...)
deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Vendor.Exclude_shared_libs) deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Vendor.Exclude_shared_libs)
@@ -479,6 +480,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
versionScript := ctx.ExpandOptionalSource( versionScript := ctx.ExpandOptionalSource(
linker.Properties.Version_script, "version_script") linker.Properties.Version_script, "version_script")
// TODO(b/150902910): product variant must use Target.Product
if ctx.useVndk() && linker.Properties.Target.Vendor.Version_script != nil { if ctx.useVndk() && linker.Properties.Target.Vendor.Version_script != nil {
versionScript = ctx.ExpandOptionalSource( versionScript = ctx.ExpandOptionalSource(
linker.Properties.Target.Vendor.Version_script, linker.Properties.Target.Vendor.Version_script,

View File

@@ -55,9 +55,11 @@ type llndkLibraryProperties struct {
// Whether the system library uses symbol versions. // Whether the system library uses symbol versions.
Unversioned *bool Unversioned *bool
// whether this module can be directly depended upon by libs that are installed to /vendor. // whether this module can be directly depended upon by libs that are installed
// When set to false, this module can only be depended on by VNDK libraries, not vendor // to /vendor and /product.
// libraries. This effectively hides this module from vendors. Default value is true. // When set to false, this module can only be depended on by VNDK libraries, not
// vendor nor product libraries. This effectively hides this module from
// non-system modules. Default value is true.
Vendor_available *bool Vendor_available *bool
// list of llndk headers to re-export include directories from. // list of llndk headers to re-export include directories from.

View File

@@ -40,6 +40,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
name: "libatomic", name: "libatomic",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
native_bridge_supported: true, native_bridge_supported: true,
src: "", src: "",
@@ -48,6 +49,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
toolchain_library { toolchain_library {
name: "libcompiler_rt-extras", name: "libcompiler_rt-extras",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
src: "", src: "",
} }
@@ -55,6 +57,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
toolchain_library { toolchain_library {
name: "libclang_rt.builtins-arm-android", name: "libclang_rt.builtins-arm-android",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
native_bridge_supported: true, native_bridge_supported: true,
src: "", src: "",
@@ -63,6 +66,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
toolchain_library { toolchain_library {
name: "libclang_rt.builtins-aarch64-android", name: "libclang_rt.builtins-aarch64-android",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
native_bridge_supported: true, native_bridge_supported: true,
src: "", src: "",
@@ -72,6 +76,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
name: "libclang_rt.hwasan-aarch64-android", name: "libclang_rt.hwasan-aarch64-android",
nocrt: true, nocrt: true,
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
system_shared_libs: [], system_shared_libs: [],
stl: "none", stl: "none",
@@ -85,6 +90,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
toolchain_library { toolchain_library {
name: "libclang_rt.builtins-i686-android", name: "libclang_rt.builtins-i686-android",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
native_bridge_supported: true, native_bridge_supported: true,
src: "", src: "",
@@ -94,6 +100,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
name: "libclang_rt.builtins-x86_64-android", name: "libclang_rt.builtins-x86_64-android",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
native_bridge_supported: true, native_bridge_supported: true,
src: "", src: "",
@@ -102,6 +109,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
toolchain_library { toolchain_library {
name: "libclang_rt.fuzzer-arm-android", name: "libclang_rt.fuzzer-arm-android",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
src: "", src: "",
} }
@@ -109,6 +117,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
toolchain_library { toolchain_library {
name: "libclang_rt.fuzzer-aarch64-android", name: "libclang_rt.fuzzer-aarch64-android",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
src: "", src: "",
} }
@@ -116,6 +125,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
toolchain_library { toolchain_library {
name: "libclang_rt.fuzzer-i686-android", name: "libclang_rt.fuzzer-i686-android",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
src: "", src: "",
} }
@@ -124,6 +134,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
name: "libclang_rt.fuzzer-x86_64-android", name: "libclang_rt.fuzzer-x86_64-android",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
src: "", src: "",
} }
@@ -131,6 +142,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
toolchain_library { toolchain_library {
name: "libclang_rt.fuzzer-x86_64", name: "libclang_rt.fuzzer-x86_64",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
src: "", src: "",
} }
@@ -139,6 +151,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "libclang_rt.ubsan_standalone-aarch64-android", name: "libclang_rt.ubsan_standalone-aarch64-android",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
system_shared_libs: [], system_shared_libs: [],
srcs: [""], srcs: [""],
@@ -148,6 +161,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
name: "libgcc", name: "libgcc",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
src: "", src: "",
} }
@@ -156,6 +170,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
name: "libgcc_stripped", name: "libgcc_stripped",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
sdk_version: "current", sdk_version: "current",
src: "", src: "",
@@ -173,7 +188,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
versions: ["27", "28", "29"], versions: ["27", "28", "29"],
}, },
llndk_stubs: "libc.llndk", llndk_stubs: "libc.llndk",
} }
llndk_library { llndk_library {
name: "libc.llndk", name: "libc.llndk",
symbol_file: "", symbol_file: "",
@@ -206,6 +221,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
cc_library { cc_library {
name: "libprofile-extras", name: "libprofile-extras",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
native_coverage: false, native_coverage: false,
system_shared_libs: [], system_shared_libs: [],
@@ -215,6 +231,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
cc_library { cc_library {
name: "libprofile-clang-extras", name: "libprofile-clang-extras",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
native_coverage: false, native_coverage: false,
system_shared_libs: [], system_shared_libs: [],
@@ -224,6 +241,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
cc_library { cc_library {
name: "libprofile-extras_ndk", name: "libprofile-extras_ndk",
vendor_available: true, vendor_available: true,
product_available: true,
native_coverage: false, native_coverage: false,
system_shared_libs: [], system_shared_libs: [],
stl: "none", stl: "none",
@@ -233,6 +251,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
cc_library { cc_library {
name: "libprofile-clang-extras_ndk", name: "libprofile-clang-extras_ndk",
vendor_available: true, vendor_available: true,
product_available: true,
native_coverage: false, native_coverage: false,
system_shared_libs: [], system_shared_libs: [],
stl: "none", stl: "none",
@@ -283,6 +302,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
system_shared_libs: [], system_shared_libs: [],
stl: "none", stl: "none",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
host_supported: true, host_supported: true,
min_sdk_version: "29", min_sdk_version: "29",
@@ -298,6 +318,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
system_shared_libs: [], system_shared_libs: [],
stl: "none", stl: "none",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
host_supported: true, host_supported: true,
min_sdk_version: "29", min_sdk_version: "29",
@@ -318,6 +339,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
stl: "none", stl: "none",
host_supported: false, host_supported: false,
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
min_sdk_version: "29", min_sdk_version: "29",
apex_available: [ apex_available: [
@@ -332,6 +354,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
system_shared_libs: [], system_shared_libs: [],
stl: "none", stl: "none",
vendor_available: true, vendor_available: true,
product_available: true,
recovery_available: true, recovery_available: true,
} }
@@ -340,6 +363,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
recovery_available: true, recovery_available: true,
vendor_available: true, vendor_available: true,
product_available: true,
native_bridge_supported: true, native_bridge_supported: true,
stl: "none", stl: "none",
min_sdk_version: "16", min_sdk_version: "16",

View File

@@ -62,8 +62,8 @@ type VndkProperties struct {
// declared as a VNDK or VNDK-SP module. The vendor variant // declared as a VNDK or VNDK-SP module. The vendor variant
// will be installed in /system instead of /vendor partition. // will be installed in /system instead of /vendor partition.
// //
// `vendor_available` must be explicitly set to either true or // `vendor_available` and `product_available` must be explicitly
// false together with `vndk: {enabled: true}`. // set to either true or false together with `vndk: {enabled: true}`.
Enabled *bool Enabled *bool
// declared as a VNDK-SP module, which is a subset of VNDK. // declared as a VNDK-SP module, which is a subset of VNDK.
@@ -129,13 +129,16 @@ func (vndk *vndkdep) typeName() string {
return "native:vendor:vndkspext" return "native:vendor:vndkspext"
} }
// VNDK link type check from a module with UseVndk() == true.
func (vndk *vndkdep) vndkCheckLinkType(ctx android.BaseModuleContext, to *Module, tag blueprint.DependencyTag) { func (vndk *vndkdep) vndkCheckLinkType(ctx android.BaseModuleContext, to *Module, tag blueprint.DependencyTag) {
if to.linker == nil { if to.linker == nil {
return return
} }
if !vndk.isVndk() { if !vndk.isVndk() {
// Non-VNDK modules (those installed to /vendor, /product, or /system/product) can't depend // Non-VNDK modules those installed to /vendor or /system/vendor
// on modules marked with vendor_available: false. // can't depend on modules marked with vendor_available: false;
// or those installed to /product or /system/product can't depend
// on modules marked with product_available: false.
violation := false violation := false
if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) { if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) {
violation = true violation = true
@@ -174,6 +177,7 @@ func (vndk *vndkdep) vndkCheckLinkType(ctx android.BaseModuleContext, to *Module
to.Name()) to.Name())
return return
} }
// TODO(b/150902910): vndk-ext for product must check product_available.
if !Bool(to.VendorProperties.Vendor_available) { if !Bool(to.VendorProperties.Vendor_available) {
ctx.ModuleErrorf( ctx.ModuleErrorf(
"`extends` refers module %q which does not have `vendor_available: true`", "`extends` refers module %q which does not have `vendor_available: true`",
@@ -338,6 +342,8 @@ func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
} else { } else {
vndkCoreLibraries(mctx.Config())[name] = filename vndkCoreLibraries(mctx.Config())[name] = filename
} }
// As `vendor_available` and `product_available` has the same value for VNDK modules,
// we don't need to check both values.
if !Bool(m.VendorProperties.Vendor_available) { if !Bool(m.VendorProperties.Vendor_available) {
vndkPrivateLibraries(mctx.Config())[name] = filename vndkPrivateLibraries(mctx.Config())[name] = filename
} }

View File

@@ -34,6 +34,7 @@ var (
// version: "27", // version: "27",
// target_arch: "arm64", // target_arch: "arm64",
// vendor_available: true, // vendor_available: true,
// product_available: true,
// vndk: { // vndk: {
// enabled: true, // enabled: true,
// }, // },
@@ -251,6 +252,7 @@ func vndkPrebuiltSharedLibrary() *Module {
// version: "27", // version: "27",
// target_arch: "arm64", // target_arch: "arm64",
// vendor_available: true, // vendor_available: true,
// product_available: true,
// vndk: { // vndk: {
// enabled: true, // enabled: true,
// }, // },

View File

@@ -143,6 +143,9 @@ type syspropLibraryProperties struct {
// Make this module available when building for vendor // Make this module available when building for vendor
Vendor_available *bool Vendor_available *bool
// Make this module available when building for product
Product_available *bool
// list of .sysprop files which defines the properties. // list of .sysprop files which defines the properties.
Srcs []string `android:"path"` Srcs []string `android:"path"`
@@ -353,6 +356,7 @@ type ccLibraryProperties struct {
Recovery *bool Recovery *bool
Recovery_available *bool Recovery_available *bool
Vendor_available *bool Vendor_available *bool
Product_available *bool
Host_supported *bool Host_supported *bool
Apex_available []string Apex_available []string
Min_sdk_version *string Min_sdk_version *string
@@ -449,6 +453,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
ccProps.Target.Host.Static_libs = []string{"libbase", "liblog"} ccProps.Target.Host.Static_libs = []string{"libbase", "liblog"}
ccProps.Recovery_available = m.properties.Recovery_available ccProps.Recovery_available = m.properties.Recovery_available
ccProps.Vendor_available = m.properties.Vendor_available ccProps.Vendor_available = m.properties.Vendor_available
ccProps.Product_available = m.properties.Product_available
ccProps.Host_supported = m.properties.Host_supported ccProps.Host_supported = m.properties.Host_supported
ccProps.Apex_available = m.ApexProperties.Apex_available ccProps.Apex_available = m.ApexProperties.Apex_available
ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version