Support sdk_version: "core_current" am: 750e557011
am: 313c1cde06
Change-Id: I0fcd39aac347aff88c043e8a1bcac5825636567a
This commit is contained in:
23
java/java.go
23
java/java.go
@@ -315,7 +315,7 @@ type sdkDep struct {
|
|||||||
|
|
||||||
func sdkStringToNumber(ctx android.BaseContext, v string) int {
|
func sdkStringToNumber(ctx android.BaseContext, v string) int {
|
||||||
switch v {
|
switch v {
|
||||||
case "", "current", "system_current", "test_current":
|
case "", "current", "system_current", "test_current", "core_current":
|
||||||
return android.FutureApiLevel
|
return android.FutureApiLevel
|
||||||
default:
|
default:
|
||||||
if i, err := strconv.Atoi(android.GetNumericSdkVersion(v)); err != nil {
|
if i, err := strconv.Atoi(android.GetNumericSdkVersion(v)); err != nil {
|
||||||
@@ -361,8 +361,15 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toFile := func(v string) sdkDep {
|
toFile := func(v string) sdkDep {
|
||||||
|
isCore := strings.HasPrefix(v, "core_")
|
||||||
|
if isCore {
|
||||||
|
v = strings.TrimPrefix(v, "core_")
|
||||||
|
}
|
||||||
dir := filepath.Join("prebuilts/sdk", v)
|
dir := filepath.Join("prebuilts/sdk", v)
|
||||||
jar := filepath.Join(dir, "android.jar")
|
jar := filepath.Join(dir, "android.jar")
|
||||||
|
if isCore {
|
||||||
|
jar = filepath.Join(dir, "core.jar")
|
||||||
|
}
|
||||||
aidl := filepath.Join(dir, "framework.aidl")
|
aidl := filepath.Join(dir, "framework.aidl")
|
||||||
jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar)
|
jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar)
|
||||||
aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
|
aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
|
||||||
@@ -557,6 +564,15 @@ func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkLinkType(ctx android.ModuleContext, from *Module, to *Library, tag dependencyTag) {
|
||||||
|
if strings.HasPrefix(String(from.deviceProperties.Sdk_version), "core_") {
|
||||||
|
if !strings.HasPrefix(String(to.deviceProperties.Sdk_version), "core_") {
|
||||||
|
ctx.ModuleErrorf("depends on other library %q using non-core Java APIs",
|
||||||
|
ctx.OtherModuleName(to))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
var deps deps
|
var deps deps
|
||||||
|
|
||||||
@@ -573,6 +589,9 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
otherName := ctx.OtherModuleName(module)
|
otherName := ctx.OtherModuleName(module)
|
||||||
tag := ctx.OtherModuleDependencyTag(module)
|
tag := ctx.OtherModuleDependencyTag(module)
|
||||||
|
|
||||||
|
if to, ok := module.(*Library); ok {
|
||||||
|
checkLinkType(ctx, j, to, tag.(dependencyTag))
|
||||||
|
}
|
||||||
switch dep := module.(type) {
|
switch dep := module.(type) {
|
||||||
case Dependency:
|
case Dependency:
|
||||||
switch tag {
|
switch tag {
|
||||||
@@ -989,7 +1008,7 @@ func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags,
|
|||||||
// modules targeting an unreleased SDK (meaning it does not yet have a number) it returns "10000".
|
// modules targeting an unreleased SDK (meaning it does not yet have a number) it returns "10000".
|
||||||
func (j *Module) minSdkVersionNumber(ctx android.ModuleContext) string {
|
func (j *Module) minSdkVersionNumber(ctx android.ModuleContext) string {
|
||||||
switch String(j.deviceProperties.Sdk_version) {
|
switch String(j.deviceProperties.Sdk_version) {
|
||||||
case "", "current", "test_current", "system_current":
|
case "", "current", "test_current", "system_current", "core_current":
|
||||||
return strconv.Itoa(ctx.Config().DefaultAppTargetSdkInt())
|
return strconv.Itoa(ctx.Config().DefaultAppTargetSdkInt())
|
||||||
default:
|
default:
|
||||||
return android.GetNumericSdkVersion(String(j.deviceProperties.Sdk_version))
|
return android.GetNumericSdkVersion(String(j.deviceProperties.Sdk_version))
|
||||||
|
@@ -146,6 +146,7 @@ func testContext(config android.Config, bp string,
|
|||||||
"prebuilts/sdk/14/framework.aidl": nil,
|
"prebuilts/sdk/14/framework.aidl": nil,
|
||||||
"prebuilts/sdk/current/android.jar": nil,
|
"prebuilts/sdk/current/android.jar": nil,
|
||||||
"prebuilts/sdk/current/framework.aidl": nil,
|
"prebuilts/sdk/current/framework.aidl": nil,
|
||||||
|
"prebuilts/sdk/current/core.jar": nil,
|
||||||
"prebuilts/sdk/system_current/android.jar": nil,
|
"prebuilts/sdk/system_current/android.jar": nil,
|
||||||
"prebuilts/sdk/system_current/framework.aidl": nil,
|
"prebuilts/sdk/system_current/framework.aidl": nil,
|
||||||
"prebuilts/sdk/system_14/android.jar": nil,
|
"prebuilts/sdk/system_14/android.jar": nil,
|
||||||
@@ -360,6 +361,14 @@ var classpathTestcases = []struct {
|
|||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
||||||
classpath: []string{"prebuilts/sdk/test_current/android.jar"},
|
classpath: []string{"prebuilts/sdk/test_current/android.jar"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
|
||||||
|
name: "core_current",
|
||||||
|
properties: `sdk_version: "core_current",`,
|
||||||
|
bootclasspath: []string{`""`},
|
||||||
|
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
||||||
|
classpath: []string{"prebuilts/sdk/current/core.jar"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "nostdlib",
|
name: "nostdlib",
|
||||||
|
Reference in New Issue
Block a user