From 30f7c79949e1635e606f18ff3520ce4b19066bca Mon Sep 17 00:00:00 2001 From: Prashanth Swaminathan Date: Fri, 28 Jul 2023 13:09:37 -0700 Subject: [PATCH] Convert preview sdkVersion to int for target-api If the target SDK of the module is a preview, the current logic passes it through to llvm-rs-cc, which expects an int. Convert codenames to their API level first, then extract the final or preview int. Also simplify the logic to look for 'current' more generically via the common ApiLevel library functions. Test: Verified local build of riscv64, confirmed RS attempts to build with API level 9000+ instead of 'VanillaIceCream'. Change-Id: I1fa7577181bfd16de0ea4e77f7ab8fbd8fdb55e5 --- cc/rs.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cc/rs.go b/cc/rs.go index 65072591f..93acdc7db 100644 --- a/cc/rs.go +++ b/cc/rs.go @@ -101,11 +101,12 @@ func rsGenerateCpp(ctx android.ModuleContext, rsFiles android.Paths, rsFlags str func rsFlags(ctx ModuleContext, flags Flags, properties *BaseCompilerProperties) Flags { targetApi := String(properties.Renderscript.Target_api) if targetApi == "" && ctx.useSdk() { - switch ctx.sdkVersion() { - case "current", "system_current", "test_current": - // Nothing - default: - targetApi = android.GetNumericSdkVersion(ctx.sdkVersion()) + targetApiLevel := android.ApiLevelOrPanic(ctx, ctx.sdkVersion()) + if targetApiLevel.IsCurrent() || targetApiLevel.IsPreview() { + // If the target level is current or preview, leave the 'target-api' unset. + // This signals to llvm-rs-cc that the development API should be used. + } else { + targetApi = targetApiLevel.String() } }