Define __ANDROID_VENDOR_API__
cc modules can use __ANDROID_VENDOR_API__ to read BOARD_API_LEVEL that is the API level of the vendor surface. Bug: 313822931 Test: check ninja commands to have -D__ANDROID_VENDOR_API__=<version> Change-Id: Iceb5918cbfce0f24929d02d7e3caf1e9942b88e8
This commit is contained in:
@@ -40,6 +40,7 @@ func TestMain(m *testing.M) {
|
||||
var prepareForCcTest = android.GroupFixturePreparers(
|
||||
PrepareForTestWithCcIncludeVndk,
|
||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||
variables.VendorApiLevel = StringPtr("202404")
|
||||
variables.DeviceVndkVersion = StringPtr("current")
|
||||
variables.Platform_vndk_version = StringPtr("29")
|
||||
}),
|
||||
@@ -2131,11 +2132,13 @@ func TestEnforceProductVndkVersion(t *testing.T) {
|
||||
ensureStringContains(t, vendor_cflags, "-D__ANDROID_VNDK__")
|
||||
ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR__")
|
||||
ensureStringNotContains(t, vendor_cflags, "-D__ANDROID_PRODUCT__")
|
||||
ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR_API__=202404")
|
||||
|
||||
product_cflags := product_static.Rule("cc").Args["cFlags"]
|
||||
ensureStringContains(t, product_cflags, "-D__ANDROID_VNDK__")
|
||||
ensureStringContains(t, product_cflags, "-D__ANDROID_PRODUCT__")
|
||||
ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR__")
|
||||
ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR_API__=202404")
|
||||
}
|
||||
|
||||
func TestEnforceProductVndkVersionErrors(t *testing.T) {
|
||||
|
@@ -406,6 +406,15 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
||||
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__")
|
||||
if ctx.inVendor() {
|
||||
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR__")
|
||||
|
||||
vendorApiLevel := ctx.Config().VendorApiLevel()
|
||||
if vendorApiLevel == "" {
|
||||
// TODO(b/314036847): This is a fallback for UDC targets.
|
||||
// This must be a build failure when UDC is no longer built
|
||||
// from this source tree.
|
||||
vendorApiLevel = ctx.Config().PlatformSdkVersion().String()
|
||||
}
|
||||
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR_API__="+vendorApiLevel)
|
||||
} else if ctx.inProduct() {
|
||||
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_PRODUCT__")
|
||||
}
|
||||
|
Reference in New Issue
Block a user