Add core-lambda-stubs to classpath
am: 86a60ae6fa
Change-Id: If6db07e1f33e35015f13b443c9619f34f03552b5
This commit is contained in:
@@ -213,7 +213,7 @@ func aaptLibs(ctx android.ModuleContext, sdkVersion string) (transitiveStaticLib
|
|||||||
|
|
||||||
sdkDep := decodeSdkDep(ctx, sdkVersion)
|
sdkDep := decodeSdkDep(ctx, sdkVersion)
|
||||||
if sdkDep.useFiles {
|
if sdkDep.useFiles {
|
||||||
sharedLibs = append(sharedLibs, sdkDep.jar)
|
sharedLibs = append(sharedLibs, sdkDep.jars...)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.VisitDirectDeps(func(module android.Module) {
|
ctx.VisitDirectDeps(func(module android.Module) {
|
||||||
|
@@ -30,6 +30,8 @@ var (
|
|||||||
DefaultBootclasspathLibraries = []string{"core-oj", "core-libart"}
|
DefaultBootclasspathLibraries = []string{"core-oj", "core-libart"}
|
||||||
DefaultSystemModules = "core-system-modules"
|
DefaultSystemModules = "core-system-modules"
|
||||||
DefaultLibraries = []string{"ext", "framework", "okhttp"}
|
DefaultLibraries = []string{"ext", "framework", "okhttp"}
|
||||||
|
DefaultLambdaStubsLibrary = "core-lambda-stubs"
|
||||||
|
SdkLambdaStubsPath = "prebuilts/sdk/tools/core-lambda-stubs.jar"
|
||||||
|
|
||||||
DefaultJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"}
|
DefaultJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"}
|
||||||
|
|
||||||
|
@@ -293,7 +293,7 @@ func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
|||||||
ctx.AddDependency(ctx.Module(), libTag, []string{"ext", "framework"}...)
|
ctx.AddDependency(ctx.Module(), libTag, []string{"ext", "framework"}...)
|
||||||
}
|
}
|
||||||
} else if sdkDep.useModule {
|
} else if sdkDep.useModule {
|
||||||
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.modules...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,9 +377,9 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
|
|
||||||
sdkDep := decodeSdkDep(ctx, String(j.properties.Sdk_version))
|
sdkDep := decodeSdkDep(ctx, String(j.properties.Sdk_version))
|
||||||
if sdkDep.invalidVersion {
|
if sdkDep.invalidVersion {
|
||||||
ctx.AddMissingDependencies([]string{sdkDep.module})
|
ctx.AddMissingDependencies(sdkDep.modules)
|
||||||
} else if sdkDep.useFiles {
|
} else if sdkDep.useFiles {
|
||||||
deps.bootClasspath = append(deps.bootClasspath, sdkDep.jar)
|
deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.VisitDirectDeps(func(module android.Module) {
|
ctx.VisitDirectDeps(func(module android.Module) {
|
||||||
|
20
java/java.go
20
java/java.go
@@ -338,12 +338,12 @@ var (
|
|||||||
type sdkDep struct {
|
type sdkDep struct {
|
||||||
useModule, useFiles, useDefaultLibs, invalidVersion bool
|
useModule, useFiles, useDefaultLibs, invalidVersion bool
|
||||||
|
|
||||||
module string
|
modules []string
|
||||||
systemModules string
|
systemModules string
|
||||||
|
|
||||||
frameworkResModule string
|
frameworkResModule string
|
||||||
|
|
||||||
jar android.Path
|
jars android.Paths
|
||||||
aidl android.Path
|
aidl android.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,11 +412,12 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
|
|||||||
aidl := filepath.Join(public_dir, "framework.aidl")
|
aidl := filepath.Join(public_dir, "framework.aidl")
|
||||||
jarPath := android.ExistentPathForSource(ctx, jar)
|
jarPath := android.ExistentPathForSource(ctx, jar)
|
||||||
aidlPath := android.ExistentPathForSource(ctx, aidl)
|
aidlPath := android.ExistentPathForSource(ctx, aidl)
|
||||||
|
lambdaStubsPath := android.PathForSource(ctx, config.SdkLambdaStubsPath)
|
||||||
|
|
||||||
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
|
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
|
||||||
return sdkDep{
|
return sdkDep{
|
||||||
invalidVersion: true,
|
invalidVersion: true,
|
||||||
module: fmt.Sprintf("sdk_%s_%s_android", api, v),
|
modules: []string{fmt.Sprintf("sdk_%s_%s_android", api, v)},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +433,7 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
|
|||||||
|
|
||||||
return sdkDep{
|
return sdkDep{
|
||||||
useFiles: true,
|
useFiles: true,
|
||||||
jar: jarPath.Path(),
|
jars: android.Paths{jarPath.Path(), lambdaStubsPath},
|
||||||
aidl: aidlPath.Path(),
|
aidl: aidlPath.Path(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -440,7 +441,7 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
|
|||||||
toModule := func(m, r string) sdkDep {
|
toModule := func(m, r string) sdkDep {
|
||||||
ret := sdkDep{
|
ret := sdkDep{
|
||||||
useModule: true,
|
useModule: true,
|
||||||
module: m,
|
modules: []string{m, config.DefaultLambdaStubsLibrary},
|
||||||
systemModules: m + "_system_modules",
|
systemModules: m + "_system_modules",
|
||||||
frameworkResModule: r,
|
frameworkResModule: r,
|
||||||
}
|
}
|
||||||
@@ -489,7 +490,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
|||||||
if ctx.Config().TargetOpenJDK9() {
|
if ctx.Config().TargetOpenJDK9() {
|
||||||
ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules)
|
ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules)
|
||||||
}
|
}
|
||||||
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.modules...)
|
||||||
if Bool(j.deviceProperties.Optimize.Enabled) {
|
if Bool(j.deviceProperties.Optimize.Enabled) {
|
||||||
ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultBootclasspathLibraries...)
|
ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultBootclasspathLibraries...)
|
||||||
ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultLibraries...)
|
ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultLibraries...)
|
||||||
@@ -625,8 +626,9 @@ const (
|
|||||||
|
|
||||||
func getLinkType(m *Module, name string) linkType {
|
func getLinkType(m *Module, name string) linkType {
|
||||||
ver := String(m.deviceProperties.Sdk_version)
|
ver := String(m.deviceProperties.Sdk_version)
|
||||||
|
noStdLibs := Bool(m.properties.No_standard_libs)
|
||||||
switch {
|
switch {
|
||||||
case name == "core.current.stubs" || ver == "core_current":
|
case name == "core.current.stubs" || ver == "core_current" || noStdLibs:
|
||||||
return javaCore
|
return javaCore
|
||||||
case name == "android_system_stubs_current" || strings.HasPrefix(ver, "system_"):
|
case name == "android_system_stubs_current" || strings.HasPrefix(ver, "system_"):
|
||||||
return javaSystem
|
return javaSystem
|
||||||
@@ -684,10 +686,10 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version))
|
sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version))
|
||||||
if sdkDep.invalidVersion {
|
if sdkDep.invalidVersion {
|
||||||
ctx.AddMissingDependencies([]string{sdkDep.module})
|
ctx.AddMissingDependencies(sdkDep.modules)
|
||||||
} else if sdkDep.useFiles {
|
} else if sdkDep.useFiles {
|
||||||
// sdkDep.jar is actually equivalent to turbine header.jar.
|
// sdkDep.jar is actually equivalent to turbine header.jar.
|
||||||
deps.classpath = append(deps.classpath, sdkDep.jar)
|
deps.classpath = append(deps.classpath, sdkDep.jars...)
|
||||||
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
var buildDir string
|
var buildDir string
|
||||||
@@ -98,6 +100,7 @@ func testContext(config android.Config, bp string,
|
|||||||
extraModules := []string{
|
extraModules := []string{
|
||||||
"core-oj",
|
"core-oj",
|
||||||
"core-libart",
|
"core-libart",
|
||||||
|
"core-lambda-stubs",
|
||||||
"framework",
|
"framework",
|
||||||
"ext",
|
"ext",
|
||||||
"okhttp",
|
"okhttp",
|
||||||
@@ -166,6 +169,7 @@ func testContext(config android.Config, bp string,
|
|||||||
"prebuilts/sdk/14/public/android.jar": nil,
|
"prebuilts/sdk/14/public/android.jar": nil,
|
||||||
"prebuilts/sdk/14/public/framework.aidl": nil,
|
"prebuilts/sdk/14/public/framework.aidl": nil,
|
||||||
"prebuilts/sdk/14/system/android.jar": nil,
|
"prebuilts/sdk/14/system/android.jar": nil,
|
||||||
|
"prebuilts/sdk/current/core/android.jar": nil,
|
||||||
"prebuilts/sdk/current/public/android.jar": nil,
|
"prebuilts/sdk/current/public/android.jar": nil,
|
||||||
"prebuilts/sdk/current/public/framework.aidl": nil,
|
"prebuilts/sdk/current/public/framework.aidl": nil,
|
||||||
"prebuilts/sdk/current/public/core.jar": nil,
|
"prebuilts/sdk/current/public/core.jar": nil,
|
||||||
@@ -183,6 +187,7 @@ func testContext(config android.Config, bp string,
|
|||||||
"prebuilts/sdk/28/public/api/bar-removed.txt": nil,
|
"prebuilts/sdk/28/public/api/bar-removed.txt": nil,
|
||||||
"prebuilts/sdk/28/system/api/bar-removed.txt": nil,
|
"prebuilts/sdk/28/system/api/bar-removed.txt": nil,
|
||||||
"prebuilts/sdk/28/test/api/bar-removed.txt": nil,
|
"prebuilts/sdk/28/test/api/bar-removed.txt": nil,
|
||||||
|
"prebuilts/sdk/tools/core-lambda-stubs.jar": nil,
|
||||||
"prebuilts/sdk/Android.bp": []byte(`prebuilt_apis { name: "prebuilt_apis",}`),
|
"prebuilts/sdk/Android.bp": []byte(`prebuilt_apis { name: "prebuilt_apis",}`),
|
||||||
|
|
||||||
// For framework-res, which is an implicit dependency for framework
|
// For framework-res, which is an implicit dependency for framework
|
||||||
@@ -338,6 +343,7 @@ func TestBinary(t *testing.T) {
|
|||||||
|
|
||||||
var classpathTestcases = []struct {
|
var classpathTestcases = []struct {
|
||||||
name string
|
name string
|
||||||
|
unbundled bool
|
||||||
moduleType string
|
moduleType string
|
||||||
host android.OsClass
|
host android.OsClass
|
||||||
properties string
|
properties string
|
||||||
@@ -364,20 +370,20 @@ var classpathTestcases = []struct {
|
|||||||
properties: `sdk_version: "14",`,
|
properties: `sdk_version: "14",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
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/14/public/android.jar"},
|
classpath: []string{"prebuilts/sdk/14/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "current",
|
name: "current",
|
||||||
properties: `sdk_version: "current",`,
|
properties: `sdk_version: "current",`,
|
||||||
bootclasspath: []string{"android_stubs_current"},
|
bootclasspath: []string{"android_stubs_current", "core-lambda-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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "system_current",
|
name: "system_current",
|
||||||
properties: `sdk_version: "system_current",`,
|
properties: `sdk_version: "system_current",`,
|
||||||
bootclasspath: []string{"android_system_stubs_current"},
|
bootclasspath: []string{"android_system_stubs_current", "core-lambda-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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -386,20 +392,20 @@ var classpathTestcases = []struct {
|
|||||||
properties: `sdk_version: "system_14",`,
|
properties: `sdk_version: "system_14",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
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/14/system/android.jar"},
|
classpath: []string{"prebuilts/sdk/14/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "test_current",
|
name: "test_current",
|
||||||
properties: `sdk_version: "test_current",`,
|
properties: `sdk_version: "test_current",`,
|
||||||
bootclasspath: []string{"android_test_stubs_current"},
|
bootclasspath: []string{"android_test_stubs_current", "core-lambda-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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "core_current",
|
name: "core_current",
|
||||||
properties: `sdk_version: "core_current",`,
|
properties: `sdk_version: "core_current",`,
|
||||||
bootclasspath: []string{"core.current.stubs"},
|
bootclasspath: []string{"core.current.stubs", "core-lambda-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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -448,6 +454,24 @@ var classpathTestcases = []struct {
|
|||||||
properties: `host_supported: true, no_standard_libs: true, system_modules: "none"`,
|
properties: `host_supported: true, no_standard_libs: true, system_modules: "none"`,
|
||||||
classpath: []string{},
|
classpath: []string{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
|
||||||
|
name: "unbundled sdk v14",
|
||||||
|
unbundled: true,
|
||||||
|
properties: `sdk_version: "14",`,
|
||||||
|
bootclasspath: []string{`""`},
|
||||||
|
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
||||||
|
classpath: []string{"prebuilts/sdk/14/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
|
||||||
|
name: "unbundled current",
|
||||||
|
unbundled: true,
|
||||||
|
properties: `sdk_version: "current",`,
|
||||||
|
bootclasspath: []string{`""`},
|
||||||
|
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
||||||
|
classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClasspath(t *testing.T) {
|
func TestClasspath(t *testing.T) {
|
||||||
@@ -498,7 +522,12 @@ func TestClasspath(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("1.8", func(t *testing.T) {
|
t.Run("1.8", func(t *testing.T) {
|
||||||
// Test default javac 1.8
|
// Test default javac 1.8
|
||||||
ctx := testJava(t, bp)
|
config := testConfig(nil)
|
||||||
|
if testcase.unbundled {
|
||||||
|
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
||||||
|
}
|
||||||
|
ctx := testContext(config, bp, nil)
|
||||||
|
run(t, ctx, config)
|
||||||
|
|
||||||
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
|
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
|
||||||
|
|
||||||
@@ -526,6 +555,9 @@ func TestClasspath(t *testing.T) {
|
|||||||
// Test again with javac 1.9
|
// Test again with javac 1.9
|
||||||
t.Run("1.9", func(t *testing.T) {
|
t.Run("1.9", func(t *testing.T) {
|
||||||
config := testConfig(map[string]string{"EXPERIMENTAL_USE_OPENJDK9": "true"})
|
config := testConfig(map[string]string{"EXPERIMENTAL_USE_OPENJDK9": "true"})
|
||||||
|
if testcase.unbundled {
|
||||||
|
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
||||||
|
}
|
||||||
ctx := testContext(config, bp, nil)
|
ctx := testContext(config, bp, nil)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user