Merge "Move checking of minApiForArch for apex into cc"
This commit is contained in:
commit
21c71a35bd
4 changed files with 44 additions and 7 deletions
|
@ -2740,11 +2740,6 @@ func (a *apexBundle) minSdkVersionValue(ctx android.EarlyModuleContext) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
archMinApiLevel := cc.MinApiForArch(ctx, a.MultiTargets()[0].Arch.ArchType)
|
|
||||||
if !archMinApiLevel.IsNone() && archMinApiLevel.CompareTo(minApiLevel) > 0 {
|
|
||||||
minApiLevel = archMinApiLevel
|
|
||||||
}
|
|
||||||
|
|
||||||
overrideMinSdkValue := ctx.DeviceConfig().ApexGlobalMinSdkVersionOverride()
|
overrideMinSdkValue := ctx.DeviceConfig().ApexGlobalMinSdkVersionOverride()
|
||||||
overrideApiLevel := minSdkVersionFromValue(ctx, overrideMinSdkValue)
|
overrideApiLevel := minSdkVersionFromValue(ctx, overrideMinSdkValue)
|
||||||
if !overrideApiLevel.IsNone() && overrideApiLevel.CompareTo(minApiLevel) > 0 {
|
if !overrideApiLevel.IsNone() && overrideApiLevel.CompareTo(minApiLevel) > 0 {
|
||||||
|
|
|
@ -2191,6 +2191,38 @@ func TestApexMinSdkVersion_Okay(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApexMinSdkVersion_MinApiForArch(t *testing.T) {
|
||||||
|
// Tests that an apex dependency with min_sdk_version higher than the
|
||||||
|
// min_sdk_version of the apex is allowed as long as the dependency's
|
||||||
|
// min_sdk_version is less than or equal to the api level that the
|
||||||
|
// architecture was introduced in. In this case, arm64 didn't exist
|
||||||
|
// until api level 21, so the arm64 code will never need to run on
|
||||||
|
// an api level 20 device, even if other architectures of the apex
|
||||||
|
// will.
|
||||||
|
testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: ["libfoo"],
|
||||||
|
min_sdk_version: "20",
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libfoo",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
apex_available: ["myapex"],
|
||||||
|
min_sdk_version: "21",
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
func TestJavaStableSdkVersion(t *testing.T) {
|
func TestJavaStableSdkVersion(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MinApiForArch(ctx android.EarlyModuleContext,
|
func minApiForArch(ctx android.EarlyModuleContext,
|
||||||
arch android.ArchType) android.ApiLevel {
|
arch android.ArchType) android.ApiLevel {
|
||||||
|
|
||||||
switch arch {
|
switch arch {
|
||||||
|
@ -38,7 +38,7 @@ func MinApiForArch(ctx android.EarlyModuleContext,
|
||||||
func nativeApiLevelFromUser(ctx android.BaseModuleContext,
|
func nativeApiLevelFromUser(ctx android.BaseModuleContext,
|
||||||
raw string) (android.ApiLevel, error) {
|
raw string) (android.ApiLevel, error) {
|
||||||
|
|
||||||
min := MinApiForArch(ctx, ctx.Arch().ArchType)
|
min := minApiForArch(ctx, ctx.Arch().ArchType)
|
||||||
if raw == "minimum" {
|
if raw == "minimum" {
|
||||||
return min, nil
|
return min, nil
|
||||||
}
|
}
|
||||||
|
|
10
cc/cc.go
10
cc/cc.go
|
@ -3626,6 +3626,16 @@ func (c *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A dependency only needs to support a min_sdk_version at least
|
||||||
|
// as high as the api level that the architecture was introduced in.
|
||||||
|
// This allows introducing new architectures in the platform that
|
||||||
|
// need to be included in apexes that normally require an older
|
||||||
|
// min_sdk_version.
|
||||||
|
minApiForArch := minApiForArch(ctx, c.Target().Arch.ArchType)
|
||||||
|
if sdkVersion.LessThan(minApiForArch) {
|
||||||
|
sdkVersion = minApiForArch
|
||||||
|
}
|
||||||
|
|
||||||
if ver.GreaterThan(sdkVersion) {
|
if ver.GreaterThan(sdkVersion) {
|
||||||
return fmt.Errorf("newer SDK(%v)", ver)
|
return fmt.Errorf("newer SDK(%v)", ver)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue