Add Platform_sdk_version_or_codename variable
1. Added a new product variable Platform_sdk_version_or_codename;
2. This variable is used to support the logic in the Android.bp file
when either the Platform_sdk_version or the Platform_sdk_codename is
used.
Bug: 195986342
Test: m CtsThemeHostTestCases (the module where the product variable is
used)
Test: TreeHugger
Change-Id: I6b952ce47fd4adc280aa3c7ef4185487558af9bc
diff --git a/android/config.go b/android/config.go
index b3b8f3c..e3d05a6 100644
--- a/android/config.go
+++ b/android/config.go
@@ -209,6 +209,20 @@
Bool(configurable.GcovCoverage) ||
Bool(configurable.ClangCoverage))
+ // when Platform_sdk_final is true (or PLATFORM_VERSION_CODENAME is REL), use Platform_sdk_version;
+ // if false (pre-released version, for example), use Platform_sdk_codename.
+ if Bool(configurable.Platform_sdk_final) {
+ if configurable.Platform_sdk_version != nil {
+ configurable.Platform_sdk_version_or_codename =
+ proptools.StringPtr(strconv.Itoa(*(configurable.Platform_sdk_version)))
+ } else {
+ return fmt.Errorf("Platform_sdk_version cannot be pointed by a NULL pointer")
+ }
+ } else {
+ configurable.Platform_sdk_version_or_codename =
+ proptools.StringPtr(String(configurable.Platform_sdk_codename))
+ }
+
return saveToBazelConfigFile(configurable, filepath.Dir(filename))
}