diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2018-04-19 07:22:15 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-04-19 07:22:15 +0000 |
| commit | aab3e62e8eeb7822813f9cf8c34714ab0c390d1e (patch) | |
| tree | 4e51181a287d44e15ef9197844598d4099e9f00c | |
| parent | 0a9c748f75c85287e6e802c1f4c3a1362079e3c5 (diff) | |
| parent | 74d547d13c7fd167e78fa059d1eec9a4e5dadea0 (diff) | |
| download | build_soong-aab3e62e8eeb7822813f9cf8c34714ab0c390d1e.tar.gz build_soong-aab3e62e8eeb7822813f9cf8c34714ab0c390d1e.tar.bz2 build_soong-aab3e62e8eeb7822813f9cf8c34714ab0c390d1e.zip | |
Snap for 4731145 from 74d547d13c7fd167e78fa059d1eec9a4e5dadea0 to pi-release
Change-Id: I0ecaf6f232896a9d3eba9e261b0e3c454fb548da
| -rw-r--r-- | android/config.go | 12 | ||||
| -rw-r--r-- | android/paths.go | 12 | ||||
| -rw-r--r-- | android/paths_test.go | 5 | ||||
| -rw-r--r-- | android/variable.go | 1 | ||||
| -rw-r--r-- | cc/cc.go | 3 | ||||
| -rw-r--r-- | java/androidmk.go | 4 | ||||
| -rw-r--r-- | java/app.go | 2 | ||||
| -rw-r--r-- | java/app_test.go | 93 |
8 files changed, 125 insertions, 7 deletions
diff --git a/android/config.go b/android/config.go index b89ae488..549abe91 100644 --- a/android/config.go +++ b/android/config.go @@ -476,6 +476,10 @@ func (c *config) PlatformSdkVersion() string { return strconv.Itoa(c.PlatformSdkVersionInt()) } +func (c *config) PlatformSdkCodename() string { + return String(c.productVariables.Platform_sdk_codename) +} + func (c *config) MinSupportedSdkVersion() int { return 14 } @@ -488,6 +492,14 @@ func (c *config) DefaultAppTargetSdkInt() int { } } +func (c *config) DefaultAppTargetSdk() string { + if Bool(c.productVariables.Platform_sdk_final) { + return c.PlatformSdkVersion() + } else { + return c.PlatformSdkCodename() + } +} + func (c *config) AppsDefaultVersionName() string { return String(c.productVariables.AppsDefaultVersionName) } diff --git a/android/paths.go b/android/paths.go index 87efe534..91dd9a6d 100644 --- a/android/paths.go +++ b/android/paths.go @@ -308,6 +308,18 @@ func LastUniquePaths(list Paths) Paths { return list[totalSkip:] } +// ReversePaths returns a copy of a Paths in reverse order. +func ReversePaths(list Paths) Paths { + if list == nil { + return nil + } + ret := make(Paths, len(list)) + for i := range list { + ret[i] = list[len(list)-1-i] + } + return ret +} + func indexPathList(s Path, list []Path) int { for i, l := range list { if l == s { diff --git a/android/paths_test.go b/android/paths_test.go index 00757985..cd9fbfd5 100644 --- a/android/paths_test.go +++ b/android/paths_test.go @@ -474,10 +474,7 @@ func TestDirectorySortedPaths(t *testing.T) { } paths := makePaths() - reversePaths := make(Paths, len(paths)) - for i, v := range paths { - reversePaths[len(paths)-i-1] = v - } + reversePaths := ReversePaths(paths) sortedPaths := PathsToDirectorySortedPaths(paths) reverseSortedPaths := PathsToDirectorySortedPaths(reversePaths) diff --git a/android/variable.go b/android/variable.go index a386b9df..9d9830ea 100644 --- a/android/variable.go +++ b/android/variable.go @@ -128,6 +128,7 @@ type productVariables struct { DateFromFile *string `json:",omitempty"` Platform_sdk_version *int `json:",omitempty"` + Platform_sdk_codename *string `json:",omitempty"` Platform_sdk_final *bool `json:",omitempty"` Platform_version_active_codenames []string `json:",omitempty"` Platform_version_future_codenames []string `json:",omitempty"` @@ -539,13 +539,14 @@ func (ctx *moduleContextImpl) isVndkExt() bool { // Create source abi dumps if the module belongs to the list of VndkLibraries. func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool { + skipAbiChecks := ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") isUnsanitizedVariant := true sanitize := ctx.mod.sanitize if sanitize != nil { isUnsanitizedVariant = sanitize.isUnsanitizedVariant() } vendorAvailable := Bool(ctx.mod.VendorProperties.Vendor_available) - return isUnsanitizedVariant && ctx.ctx.Device() && ((ctx.useVndk() && ctx.isVndk() && vendorAvailable) || inList(ctx.baseModuleName(), llndkLibraries)) + return !skipAbiChecks && isUnsanitizedVariant && ctx.ctx.Device() && ((ctx.useVndk() && ctx.isVndk() && vendorAvailable) || inList(ctx.baseModuleName(), llndkLibraries)) } func (ctx *moduleContextImpl) selectedStl() string { diff --git a/java/androidmk.go b/java/androidmk.go index 3658636f..13966ed7 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -195,7 +195,9 @@ func (app *AndroidApp) AndroidMk() android.AndroidMkData { } if len(app.rroDirs) > 0 { - fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(app.rroDirs.Strings(), " ")) + // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make + // expects it in LOCAL_RESOURCE_DIRS order (high to low priority). + fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " ")) } if Bool(app.appProperties.Export_package_resources) { diff --git a/java/app.go b/java/app.go index c94d22f0..0db48e76 100644 --- a/java/app.go +++ b/java/app.go @@ -283,7 +283,7 @@ func (a *AndroidApp) aapt2Flags(ctx android.ModuleContext) (flags []string, deps sdkVersion := String(a.deviceProperties.Sdk_version) switch sdkVersion { case "", "current", "system_current", "test_current": - sdkVersion = proptools.NinjaEscape([]string{ctx.Config().AppsDefaultVersionName()})[0] + sdkVersion = proptools.NinjaEscape([]string{ctx.Config().DefaultAppTargetSdk()})[0] } linkFlags = append(linkFlags, "--min-sdk-version "+sdkVersion) diff --git a/java/app_test.go b/java/app_test.go index ba017a18..2e531303 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -16,8 +16,10 @@ package java import ( "android/soong/android" + "fmt" "reflect" "sort" + "strings" "testing" ) @@ -237,3 +239,94 @@ func TestEnforceRRO(t *testing.T) { }) } } + +func TestAppSdkVersion(t *testing.T) { + testCases := []struct { + name string + sdkVersion string + platformSdkInt int + platformSdkCodename string + platformSdkFinal bool + expectedMinSdkVersion string + }{ + { + name: "current final SDK", + sdkVersion: "current", + platformSdkInt: 27, + platformSdkCodename: "REL", + platformSdkFinal: true, + expectedMinSdkVersion: "27", + }, + { + name: "current non-final SDK", + sdkVersion: "current", + platformSdkInt: 27, + platformSdkCodename: "OMR1", + platformSdkFinal: false, + expectedMinSdkVersion: "OMR1", + }, + { + name: "default final SDK", + sdkVersion: "", + platformSdkInt: 27, + platformSdkCodename: "REL", + platformSdkFinal: true, + expectedMinSdkVersion: "27", + }, + { + name: "default non-final SDK", + sdkVersion: "", + platformSdkInt: 27, + platformSdkCodename: "OMR1", + platformSdkFinal: false, + expectedMinSdkVersion: "OMR1", + }, + { + name: "14", + sdkVersion: "14", + expectedMinSdkVersion: "14", + }, + } + + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + bp := fmt.Sprintf(`android_app { + name: "foo", + srcs: ["a.java"], + sdk_version: "%s", + }`, test.sdkVersion) + + config := testConfig(nil) + config.TestProductVariables.Platform_sdk_version = &test.platformSdkInt + config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename + config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal + + ctx := testAppContext(config, bp, nil) + + run(t, ctx, config) + + foo := ctx.ModuleForTests("foo", "android_common") + link := foo.Output("package-res.apk") + linkFlags := strings.Split(link.Args["flags"], " ") + min := android.IndexList("--min-sdk-version", linkFlags) + target := android.IndexList("--target-sdk-version", linkFlags) + + if min == -1 || target == -1 || min == len(linkFlags)-1 || target == len(linkFlags)-1 { + t.Fatalf("missing --min-sdk-version or --target-sdk-version in link flags: %q", linkFlags) + } + + gotMinSdkVersion := linkFlags[min+1] + gotTargetSdkVersion := linkFlags[target+1] + + if gotMinSdkVersion != test.expectedMinSdkVersion { + t.Errorf("incorrect --min-sdk-version, expected %q got %q", + test.expectedMinSdkVersion, gotMinSdkVersion) + } + + if gotTargetSdkVersion != test.expectedMinSdkVersion { + t.Errorf("incorrect --target-sdk-version, expected %q got %q", + test.expectedMinSdkVersion, gotTargetSdkVersion) + } + }) + } +} |
