Support tailoring clang --target flag based on min sdk version.

Bug: 215748260
Test: Tested using aquery to verify the --target flag; add added unit

Change-Id: Ifb13509db7d1e110316aa44d55ec9cccaa4b83d1
diff --git a/android/api_levels.go b/android/api_levels.go
index de56625..27a3b7f 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -18,6 +18,8 @@
 	"encoding/json"
 	"fmt"
 	"strconv"
+
+	"android/soong/starlark_fmt"
 )
 
 func init() {
@@ -380,3 +382,21 @@
 	apiLevelsJson := GetApiLevelsJson(ctx)
 	createApiLevelsJson(ctx, apiLevelsJson, apiLevelsMap)
 }
+
+func printApiLevelsStarlarkDict(config Config) string {
+	apiLevelsMap := GetApiLevelsMap(config)
+	valDict := make(map[string]string, len(apiLevelsMap))
+	for k, v := range apiLevelsMap {
+		valDict[k] = strconv.Itoa(v)
+	}
+	return starlark_fmt.PrintDict(valDict, 0)
+}
+
+func StarlarkApiLevelConfigs(config Config) string {
+	return fmt.Sprintf(`# GENERATED FOR BAZEL FROM SOONG. DO NOT EDIT.
+_api_levels = %s
+
+api_levels = _api_levels
+`, printApiLevelsStarlarkDict(config),
+	)
+}
\ No newline at end of file