Pass min_sdk_version to cc __ANDROID_SDK_VERSION__
The macro is required only for apex variants regardless of useVndk.
Before the enforcement of LLNDK sdk version, the macro was not passed to
vendor variants.
Bug: 151689896
Test: TARGET_BUILD_APPS=com.android.media.swcodec m
libbase in swcodec apex is linked with liblog#29
(compiled with __ANDROID_SDK_VERSIO__=29)
Change-Id: I57fa4afe027eb39b98bd94d534be9ebe11713f19
diff --git a/cc/compiler.go b/cc/compiler.go
index fe81bd0..681b1ab 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -315,18 +315,6 @@
"-isystem "+getCurrentIncludePath(ctx).Join(ctx, config.NDKTriple(tc)).String())
}
- if ctx.canUseSdk() {
- sdkVersion := ctx.sdkVersion()
- if sdkVersion == "" || sdkVersion == "current" {
- if ctx.isForPlatform() {
- sdkVersion = strconv.Itoa(android.FutureApiLevel)
- } else {
- sdkVersion = strconv.Itoa(ctx.apexSdkVersion())
- }
- }
- flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_SDK_VERSION__="+sdkVersion)
- }
-
if ctx.useVndk() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__")
}
@@ -340,6 +328,9 @@
if Bool(compiler.Properties.Use_apex_name_macro) {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX_"+makeDefineString(ctx.apexName())+"__")
}
+ if ctx.Device() {
+ flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_SDK_VERSION__="+strconv.Itoa(ctx.apexSdkVersion()))
+ }
}
instructionSet := String(compiler.Properties.Instruction_set)