Merge "Delete __ANDROID_APEX_MIN_SDK_VERSION__ from Soong"

This commit is contained in:
Vinh Tran 2023-01-25 19:09:27 +00:00 committed by Gerrit Code Review
commit ba46e76622
3 changed files with 4 additions and 19 deletions

View file

@ -3328,17 +3328,14 @@ func TestMacro(t *testing.T) {
// non-APEX variant does not have __ANDROID_APEX__ defined // non-APEX variant does not have __ANDROID_APEX__ defined
mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"] mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__") ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__")
// APEX variant has __ANDROID_APEX__ and __ANDROID_APEX_SDK__ defined // APEX variant has __ANDROID_APEX__ and __ANDROID_APEX__ defined
mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_apex10000").Rule("cc").Args["cFlags"] mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_apex10000").Rule("cc").Args["cFlags"]
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__") ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__=10000")
// APEX variant has __ANDROID_APEX__ and __ANDROID_APEX_SDK__ defined // APEX variant has __ANDROID_APEX__ and __ANDROID_APEX__ defined
mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_apex29").Rule("cc").Args["cFlags"] mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_apex29").Rule("cc").Args["cFlags"]
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__") ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__=29")
// When a cc_library sets use_apex_name_macro: true each apex gets a unique variant and // When a cc_library sets use_apex_name_macro: true each apex gets a unique variant and
// each variant defines additional macros to distinguish which apex variant it is built for // each variant defines additional macros to distinguish which apex variant it is built for
@ -3347,19 +3344,17 @@ func TestMacro(t *testing.T) {
mylibCFlags = ctx.ModuleForTests("mylib3", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"] mylibCFlags = ctx.ModuleForTests("mylib3", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__") ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
// recovery variant does not set __ANDROID_APEX_MIN_SDK_VERSION__ // recovery variant does not set __ANDROID_APEX__
mylibCFlags = ctx.ModuleForTests("mylib3", "android_recovery_arm64_armv8-a_static").Rule("cc").Args["cFlags"] mylibCFlags = ctx.ModuleForTests("mylib3", "android_recovery_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__") ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__")
// non-APEX variant does not have __ANDROID_APEX__ defined // non-APEX variant does not have __ANDROID_APEX__ defined
mylibCFlags = ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"] mylibCFlags = ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__") ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
// recovery variant does not set __ANDROID_APEX_MIN_SDK_VERSION__ // recovery variant does not set __ANDROID_APEX__
mylibCFlags = ctx.ModuleForTests("mylib2", "android_recovery_arm64_armv8-a_static").Rule("cc").Args["cFlags"] mylibCFlags = ctx.ModuleForTests("mylib2", "android_recovery_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__") ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__")
} }
func TestHeaderLibsDependency(t *testing.T) { func TestHeaderLibsDependency(t *testing.T) {

View file

@ -416,11 +416,6 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
if ctx.apexVariationName() != "" { if ctx.apexVariationName() != "" {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX__") flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX__")
if ctx.Device() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags,
fmt.Sprintf("-D__ANDROID_APEX_MIN_SDK_VERSION__=%d",
ctx.apexSdkVersion().FinalOrFutureInt()))
}
} }
if ctx.Target().NativeBridge == android.NativeBridgeEnabled { if ctx.Target().NativeBridge == android.NativeBridgeEnabled {

View file

@ -15,7 +15,6 @@
package rust package rust
import ( import (
"fmt"
"strings" "strings"
"github.com/google/blueprint" "github.com/google/blueprint"
@ -178,10 +177,6 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
if mctx, ok := ctx.(*moduleContext); ok && mctx.apexVariationName() != "" { if mctx, ok := ctx.(*moduleContext); ok && mctx.apexVariationName() != "" {
cflags = append(cflags, "-D__ANDROID_APEX__") cflags = append(cflags, "-D__ANDROID_APEX__")
if ctx.Device() {
cflags = append(cflags, fmt.Sprintf("-D__ANDROID_APEX_MIN_SDK_VERSION__=%d",
ctx.RustModule().apexSdkVersion.FinalOrFutureInt()))
}
} }
if ctx.Target().NativeBridge == android.NativeBridgeEnabled { if ctx.Target().NativeBridge == android.NativeBridgeEnabled {