Use built SDK stubs
Now that the SDK stubs are built in Soong, undo the hack that uses the prebuilt stubs. Fix the linktype checks to treat the various stubs libraries as the correct type, since they can't be annotated with sdk_version. Bug: 70351683 Bug: 77285514 Test: m checkbuild Change-Id: I5e870c34dd0ebc8ae3f888ec627da590c846a76f
This commit is contained in:
74
java/java.go
74
java/java.go
@@ -19,6 +19,7 @@ package java
|
|||||||
// is handled in builder.go
|
// is handled in builder.go
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -420,13 +421,17 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//toModule := func(m string) sdkDep {
|
toModule := func(m string) sdkDep {
|
||||||
// return sdkDep{
|
ret := sdkDep{
|
||||||
// useModule: true,
|
useModule: true,
|
||||||
// module: m,
|
module: m,
|
||||||
// systemModules: m + "_system_modules",
|
systemModules: m + "_system_modules",
|
||||||
// }
|
}
|
||||||
//}
|
if m == "core.current.stubs" {
|
||||||
|
ret.systemModules = "core-system-modules"
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.Config().UnbundledBuild() && v != "" {
|
if ctx.Config().UnbundledBuild() && v != "" {
|
||||||
return toFile(v)
|
return toFile(v)
|
||||||
@@ -437,14 +442,14 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
|
|||||||
return sdkDep{
|
return sdkDep{
|
||||||
useDefaultLibs: true,
|
useDefaultLibs: true,
|
||||||
}
|
}
|
||||||
// TODO(ccross): re-enable these once we generate stubs, until then
|
case "current":
|
||||||
// use the stubs in prebuilts/sdk/*current
|
return toModule("android_stubs_current")
|
||||||
//case "current":
|
case "system_current":
|
||||||
// return toModule("android_stubs_current")
|
return toModule("android_system_stubs_current")
|
||||||
//case "system_current":
|
case "test_current":
|
||||||
// return toModule("android_system_stubs_current")
|
return toModule("android_test_stubs_current")
|
||||||
//case "test_current":
|
case "core_current":
|
||||||
// return toModule("android_test_stubs_current")
|
return toModule("core.current.stubs")
|
||||||
default:
|
default:
|
||||||
return toFile(v)
|
return toFile(v)
|
||||||
}
|
}
|
||||||
@@ -600,23 +605,34 @@ const (
|
|||||||
javaPlatform
|
javaPlatform
|
||||||
)
|
)
|
||||||
|
|
||||||
func getLinkType(m *Module) linkType {
|
func getLinkType(m *Module, name string) linkType {
|
||||||
ver := String(m.deviceProperties.Sdk_version)
|
ver := String(m.deviceProperties.Sdk_version)
|
||||||
if strings.HasPrefix(ver, "core_") {
|
switch {
|
||||||
|
case name == "core.current.stubs" || ver == "core_current":
|
||||||
return javaCore
|
return javaCore
|
||||||
} else if strings.HasPrefix(ver, "system_") {
|
case name == "android_system_stubs_current" || strings.HasPrefix(ver, "system_"):
|
||||||
return javaSystem
|
return javaSystem
|
||||||
} else if _, err := strconv.Atoi(ver); err == nil || ver == "current" {
|
case name == "android_test_stubs_current" || strings.HasPrefix(ver, "test_"):
|
||||||
return javaSdk
|
|
||||||
} else {
|
|
||||||
// test_current falls back here as well
|
|
||||||
return javaPlatform
|
return javaPlatform
|
||||||
|
case name == "android_stubs_current" || ver == "current":
|
||||||
|
return javaSdk
|
||||||
|
case ver == "":
|
||||||
|
return javaPlatform
|
||||||
|
default:
|
||||||
|
if _, err := strconv.Atoi(ver); err != nil {
|
||||||
|
panic(fmt.Errorf("expected sdk_version to be a number, got %q", ver))
|
||||||
|
}
|
||||||
|
return javaSdk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkLinkType(ctx android.ModuleContext, from *Module, to *Library, tag dependencyTag) {
|
func checkLinkType(ctx android.ModuleContext, from *Module, to *Library, tag dependencyTag) {
|
||||||
myLinkType := getLinkType(from)
|
if ctx.Host() {
|
||||||
otherLinkType := getLinkType(&to.Module)
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
myLinkType := getLinkType(from, ctx.ModuleName())
|
||||||
|
otherLinkType := getLinkType(&to.Module, ctx.OtherModuleName(to))
|
||||||
commonMessage := "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source."
|
commonMessage := "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source."
|
||||||
|
|
||||||
switch myLinkType {
|
switch myLinkType {
|
||||||
@@ -909,13 +925,9 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
j.properties.Javac_shard_size)
|
j.properties.Javac_shard_size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If sdk jar is java module, then directly return classesJar as header.jar
|
j.headerJarFile = j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName)
|
||||||
if j.Name() != "android_stubs_current" && j.Name() != "android_system_stubs_current" &&
|
if ctx.Failed() {
|
||||||
j.Name() != "android_test_stubs_current" {
|
return
|
||||||
j.headerJarFile = j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName)
|
|
||||||
if ctx.Failed() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 {
|
if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 {
|
||||||
|
@@ -97,6 +97,7 @@ func testContext(config android.Config, bp string,
|
|||||||
"android_stubs_current",
|
"android_stubs_current",
|
||||||
"android_system_stubs_current",
|
"android_system_stubs_current",
|
||||||
"android_test_stubs_current",
|
"android_test_stubs_current",
|
||||||
|
"core.current.stubs",
|
||||||
"kotlin-stdlib",
|
"kotlin-stdlib",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +107,7 @@ func testContext(config android.Config, bp string,
|
|||||||
name: "%s",
|
name: "%s",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
no_standard_libs: true,
|
no_standard_libs: true,
|
||||||
|
sdk_version: "core_current",
|
||||||
system_modules: "core-system-modules",
|
system_modules: "core-system-modules",
|
||||||
}
|
}
|
||||||
`, extra)
|
`, extra)
|
||||||
@@ -212,9 +214,6 @@ func moduleToPath(name string) string {
|
|||||||
return name
|
return name
|
||||||
case strings.HasSuffix(name, ".jar"):
|
case strings.HasSuffix(name, ".jar"):
|
||||||
return name
|
return name
|
||||||
case name == "android_stubs_current" || name == "android_system_stubs_current" ||
|
|
||||||
name == "android_test_stubs_current":
|
|
||||||
return filepath.Join(buildDir, ".intermediates", name, "android_common", "javac", name+".jar")
|
|
||||||
default:
|
default:
|
||||||
return filepath.Join(buildDir, ".intermediates", name, "android_common", "turbine-combined", name+".jar")
|
return filepath.Join(buildDir, ".intermediates", name, "android_common", "turbine-combined", name+".jar")
|
||||||
}
|
}
|
||||||
@@ -346,17 +345,15 @@ var classpathTestcases = []struct {
|
|||||||
|
|
||||||
name: "current",
|
name: "current",
|
||||||
properties: `sdk_version: "current",`,
|
properties: `sdk_version: "current",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{"android_stubs_current"},
|
||||||
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/current/android.jar"},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "system_current",
|
name: "system_current",
|
||||||
properties: `sdk_version: "system_current",`,
|
properties: `sdk_version: "system_current",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{"android_system_stubs_current"},
|
||||||
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/system_current/android.jar"},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -370,17 +367,15 @@ var classpathTestcases = []struct {
|
|||||||
|
|
||||||
name: "test_current",
|
name: "test_current",
|
||||||
properties: `sdk_version: "test_current",`,
|
properties: `sdk_version: "test_current",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{"android_test_stubs_current"},
|
||||||
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"},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "core_current",
|
name: "core_current",
|
||||||
properties: `sdk_version: "core_current",`,
|
properties: `sdk_version: "core_current",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{"core.current.stubs"},
|
||||||
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/current/core.jar"},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user