summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-11-08 06:29:05 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-11-08 06:29:05 +0000
commit99dcad00ba160a17be84c271c7b3b202cc50c03e (patch)
tree3d4c128e95cf53f6315afd950155cd8ffb4d2a97
parente130f47f7fd0061843146ffbbdd4fa78661bbffe (diff)
parent0f1a781e111250d1a55bd20b955703fab0b1b775 (diff)
Merge "cc: use platform sdk version for vendor/product variants" into main
-rw-r--r--cc/cc.go11
-rw-r--r--cc/cc_test.go24
2 files changed, 16 insertions, 19 deletions
diff --git a/cc/cc.go b/cc/cc.go
index c6bc30e54..becff0f01 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1566,12 +1566,11 @@ func (ctx *moduleContextImpl) minSdkVersion() string {
}
if ctx.ctx.Device() {
- config := ctx.ctx.Config()
- if ctx.inVendor() {
- // If building for vendor with final API, then use the latest _stable_ API as "current".
- if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") {
- ver = config.PlatformSdkVersion().String()
- }
+ // When building for vendor/product, use the latest _stable_ API as "current".
+ // This is passed to clang/aidl compilers so that compiled/generated code works
+ // with the system.
+ if (ctx.inVendor() || ctx.inProduct()) && (ver == "" || ver == "current") {
+ ver = ctx.ctx.Config().PlatformSdkVersion().String()
}
}
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 22f7c9f35..df239cbb5 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -3258,7 +3258,7 @@ func TestImageVariants(t *testing.T) {
testDepWithVariant("product")
}
-func TestVendorSdkVersion(t *testing.T) {
+func TestVendorOrProductVariantUsesPlatformSdkVersionAsDefault(t *testing.T) {
t.Parallel()
bp := `
@@ -3266,31 +3266,29 @@ func TestVendorSdkVersion(t *testing.T) {
name: "libfoo",
srcs: ["libfoo.cc"],
vendor_available: true,
+ product_available: true,
}
cc_library {
name: "libbar",
srcs: ["libbar.cc"],
vendor_available: true,
+ product_available: true,
min_sdk_version: "29",
}
`
ctx := prepareForCcTest.RunTestWithBp(t, bp)
- testSdkVersionFlag := func(module, version string) {
- flags := ctx.ModuleForTests(module, "android_vendor_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
- android.AssertStringDoesContain(t, "min sdk version", flags, "-target aarch64-linux-android"+version)
+ testSdkVersionFlag := func(module, variant, version string) {
+ flags := ctx.ModuleForTests(module, "android_"+variant+"_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
+ android.AssertStringDoesContain(t, "target SDK version", flags, "-target aarch64-linux-android"+version)
}
- testSdkVersionFlag("libfoo", "10000")
- testSdkVersionFlag("libbar", "29")
-
- ctx = android.GroupFixturePreparers(
- prepareForCcTest,
- android.PrepareForTestWithBuildFlag("RELEASE_BOARD_API_LEVEL_FROZEN", "true"),
- ).RunTestWithBp(t, bp)
- testSdkVersionFlag("libfoo", "30")
- testSdkVersionFlag("libbar", "29")
+ testSdkVersionFlag("libfoo", "vendor", "30")
+ testSdkVersionFlag("libfoo", "product", "30")
+ // target SDK version can be set explicitly with min_sdk_version
+ testSdkVersionFlag("libbar", "vendor", "29")
+ testSdkVersionFlag("libbar", "product", "29")
}
func TestClangVerify(t *testing.T) {