Merge changes from topic "android_stubs_current_refactor"
* changes: Cleanup android.JavaApiLibraryName references Redefine core and core platform API surface java_library Introduce product variable Build_from_text_stub Introduce "Exclude_static_libs" property for Java modules
This commit is contained in:
23
java/base.go
23
java/base.go
@@ -79,6 +79,9 @@ type CommonProperties struct {
|
||||
// list of java libraries that will be compiled into the resulting jar
|
||||
Static_libs []string `android:"arch_variant"`
|
||||
|
||||
// list of java libraries that should not be used to build this module
|
||||
Exclude_static_libs []string `android:"arch_variant"`
|
||||
|
||||
// manifest file to be included in resulting jar
|
||||
Manifest *string `android:"path"`
|
||||
|
||||
@@ -724,6 +727,8 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
|
||||
libDeps := ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
|
||||
|
||||
j.properties.Static_libs = android.RemoveListFromList(j.properties.Static_libs, j.properties.Exclude_static_libs)
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...)
|
||||
|
||||
// Add dependency on libraries that provide additional hidden api annotations.
|
||||
@@ -1923,22 +1928,22 @@ type moduleWithSdkDep interface {
|
||||
|
||||
func (m *Module) getSdkLinkType(ctx android.BaseModuleContext, name string) (ret sdkLinkType, stubs bool) {
|
||||
switch name {
|
||||
case android.SdkCore.JavaLibraryName(ctx.Config()),
|
||||
android.JavaApiLibraryName(ctx.Config(), "legacy.core.platform.api.stubs"),
|
||||
android.JavaApiLibraryName(ctx.Config(), "stable.core.platform.api.stubs"),
|
||||
case android.SdkCore.DefaultJavaLibraryName(),
|
||||
"legacy.core.platform.api.stubs",
|
||||
"stable.core.platform.api.stubs",
|
||||
"stub-annotations", "private-stub-annotations-jar",
|
||||
android.JavaApiLibraryName(ctx.Config(), "core-lambda-stubs"),
|
||||
"core-lambda-stubs",
|
||||
"core-generated-annotation-stubs":
|
||||
return javaCore, true
|
||||
case android.SdkPublic.JavaLibraryName(ctx.Config()):
|
||||
case android.SdkPublic.DefaultJavaLibraryName():
|
||||
return javaSdk, true
|
||||
case android.SdkSystem.JavaLibraryName(ctx.Config()):
|
||||
case android.SdkSystem.DefaultJavaLibraryName():
|
||||
return javaSystem, true
|
||||
case android.SdkModule.JavaLibraryName(ctx.Config()):
|
||||
case android.SdkModule.DefaultJavaLibraryName():
|
||||
return javaModule, true
|
||||
case android.SdkSystemServer.JavaLibraryName(ctx.Config()):
|
||||
case android.SdkSystemServer.DefaultJavaLibraryName():
|
||||
return javaSystemServer, true
|
||||
case android.SdkTest.JavaLibraryName(ctx.Config()):
|
||||
case android.SdkTest.DefaultJavaLibraryName():
|
||||
return javaSystem, true
|
||||
}
|
||||
|
||||
|
@@ -33,19 +33,45 @@ dist_targets = [
|
||||
"win_sdk",
|
||||
]
|
||||
|
||||
java_library {
|
||||
name: "core.current.stubs",
|
||||
java_defaults {
|
||||
name: "core.current.stubs.defaults",
|
||||
visibility: ["//visibility:public"],
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
dist: {
|
||||
targets: dist_targets,
|
||||
},
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "core.current.stubs.from-source",
|
||||
defaults: [
|
||||
"core.current.stubs.defaults",
|
||||
],
|
||||
static_libs: [
|
||||
"art.module.public.api.stubs",
|
||||
"conscrypt.module.public.api.stubs",
|
||||
"i18n.module.public.api.stubs",
|
||||
],
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
}
|
||||
|
||||
dist: {
|
||||
targets: dist_targets,
|
||||
java_library {
|
||||
name: "core.current.stubs",
|
||||
defaults: [
|
||||
"core.current.stubs.defaults",
|
||||
],
|
||||
static_libs: [
|
||||
"core.current.stubs.from-source",
|
||||
],
|
||||
product_variables: {
|
||||
build_from_text_stub: {
|
||||
static_libs: [
|
||||
"core.current.stubs.from-text",
|
||||
],
|
||||
exclude_static_libs: [
|
||||
"core.current.stubs.from-source",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -199,18 +225,46 @@ core_platform_visibility = ["//visibility:public"]
|
||||
// API annotations are available to the dex tools that enable enforcement of runtime
|
||||
// accessibility. b/119068555
|
||||
java_library {
|
||||
name: "legacy.core.platform.api.stubs",
|
||||
name: "legacy.core.platform.api.stubs.from-source",
|
||||
visibility: core_platform_visibility,
|
||||
hostdex: true,
|
||||
compile_dex: true,
|
||||
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
defaults: [
|
||||
"core.platform.api.stubs.defaults",
|
||||
],
|
||||
static_libs: [
|
||||
"art.module.public.api.stubs.module_lib",
|
||||
"conscrypt.module.platform.api.stubs",
|
||||
"legacy.i18n.module.platform.api.stubs",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "legacy.core.platform.api.stubs",
|
||||
visibility: core_platform_visibility,
|
||||
defaults: [
|
||||
"core.platform.api.stubs.defaults",
|
||||
],
|
||||
static_libs: [
|
||||
"legacy.core.platform.api.stubs.from-source",
|
||||
],
|
||||
product_variables: {
|
||||
build_from_text_stub: {
|
||||
static_libs: [
|
||||
"stable.core.platform.api.stubs.from-text",
|
||||
],
|
||||
exclude_static_libs: [
|
||||
"stable.core.platform.api.stubs.from-source",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
java_defaults {
|
||||
name: "core.platform.api.stubs.defaults",
|
||||
hostdex: true,
|
||||
compile_dex: true,
|
||||
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
patch_module: "java.base",
|
||||
}
|
||||
|
||||
@@ -233,20 +287,38 @@ java_library {
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "stable.core.platform.api.stubs",
|
||||
name: "stable.core.platform.api.stubs.from-source",
|
||||
visibility: core_platform_visibility,
|
||||
hostdex: true,
|
||||
compile_dex: true,
|
||||
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
defaults: [
|
||||
"core.platform.api.stubs.defaults",
|
||||
],
|
||||
static_libs: [
|
||||
"art.module.public.api.stubs.module_lib",
|
||||
// conscrypt only has a stable version, so it is okay to depend on it here:
|
||||
"conscrypt.module.platform.api.stubs",
|
||||
"stable.i18n.module.platform.api.stubs",
|
||||
],
|
||||
patch_module: "java.base",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "stable.core.platform.api.stubs",
|
||||
visibility: core_platform_visibility,
|
||||
defaults: [
|
||||
"core.platform.api.stubs.defaults",
|
||||
],
|
||||
static_libs: [
|
||||
"stable.core.platform.api.stubs.from-source",
|
||||
],
|
||||
product_variables: {
|
||||
build_from_text_stub: {
|
||||
static_libs: [
|
||||
"stable.core.platform.api.stubs.from-text",
|
||||
],
|
||||
exclude_static_libs: [
|
||||
"stable.core.platform.api.stubs.from-source",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Same as stable.core.platform.api.stubs, but android annotations are
|
||||
|
@@ -236,12 +236,12 @@ func hiddenAPIComputeMonolithicStubLibModules(config android.Config) map[*Hidden
|
||||
testStubModules = append(testStubModules, "sdk_test_current_android")
|
||||
} else {
|
||||
// Use stub modules built from source
|
||||
publicStubModules = append(publicStubModules, android.SdkPublic.JavaLibraryName(config))
|
||||
systemStubModules = append(systemStubModules, android.SdkSystem.JavaLibraryName(config))
|
||||
testStubModules = append(testStubModules, android.SdkTest.JavaLibraryName(config))
|
||||
publicStubModules = append(publicStubModules, android.SdkPublic.DefaultJavaLibraryName())
|
||||
systemStubModules = append(systemStubModules, android.SdkSystem.DefaultJavaLibraryName())
|
||||
testStubModules = append(testStubModules, android.SdkTest.DefaultJavaLibraryName())
|
||||
}
|
||||
// We do not have prebuilts of the core platform api yet
|
||||
corePlatformStubModules = append(corePlatformStubModules, android.JavaApiLibraryName(config, "legacy.core.platform.api.stubs"))
|
||||
corePlatformStubModules = append(corePlatformStubModules, "legacy.core.platform.api.stubs")
|
||||
|
||||
// Allow products to define their own stubs for custom product jars that apps can use.
|
||||
publicStubModules = append(publicStubModules, config.ProductHiddenAPIStubs()...)
|
||||
|
@@ -2322,3 +2322,34 @@ java_test_host {
|
||||
t.Errorf("Expected args[\"extraTestRunnerConfigs\"] to equal %q, was %q", expected, args["extraTestRunnerConfigs"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestJavaExcludeStaticLib(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
java_library {
|
||||
name: "bar",
|
||||
}
|
||||
java_library {
|
||||
name: "foo",
|
||||
}
|
||||
java_library {
|
||||
name: "baz",
|
||||
static_libs: [
|
||||
"foo",
|
||||
"bar",
|
||||
],
|
||||
exclude_static_libs: [
|
||||
"bar",
|
||||
],
|
||||
}
|
||||
`)
|
||||
|
||||
// "bar" not included as dependency of "baz"
|
||||
CheckModuleDependencies(t, ctx, "baz", "android_common", []string{
|
||||
`core-lambda-stubs`,
|
||||
`ext`,
|
||||
`foo`,
|
||||
`framework`,
|
||||
`stable-core-platform-api-stubs-system-modules`,
|
||||
`stable.core.platform.api.stubs`,
|
||||
})
|
||||
}
|
||||
|
18
java/sdk.go
18
java/sdk.go
@@ -151,7 +151,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||
systemModules := android.JavaApiLibraryName(ctx.Config(), fmt.Sprintf("core-%s-stubs-system-modules", systemModulesKind))
|
||||
return sdkDep{
|
||||
useModule: true,
|
||||
bootclasspath: []string{module, android.JavaApiLibraryName(ctx.Config(), config.DefaultLambdaStubsLibrary)},
|
||||
bootclasspath: []string{module, config.DefaultLambdaStubsLibrary},
|
||||
systemModules: systemModules,
|
||||
java9Classpath: []string{module},
|
||||
frameworkResModule: "framework-res",
|
||||
@@ -193,20 +193,20 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||
noFrameworksLibs: true,
|
||||
}
|
||||
case android.SdkPublic, android.SdkSystem, android.SdkTest:
|
||||
return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), sdkFrameworkAidlPath(ctx))
|
||||
return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx))
|
||||
case android.SdkCore:
|
||||
return sdkDep{
|
||||
useModule: true,
|
||||
bootclasspath: []string{android.SdkCore.JavaLibraryName(ctx.Config()), android.JavaApiLibraryName(ctx.Config(), config.DefaultLambdaStubsLibrary)},
|
||||
bootclasspath: []string{android.SdkCore.DefaultJavaLibraryName(), config.DefaultLambdaStubsLibrary},
|
||||
systemModules: android.JavaApiLibraryName(ctx.Config(), "core-public-stubs-system-modules"),
|
||||
noFrameworksLibs: true,
|
||||
}
|
||||
case android.SdkModule:
|
||||
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
|
||||
return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), nonUpdatableFrameworkAidlPath(ctx))
|
||||
return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), nonUpdatableFrameworkAidlPath(ctx))
|
||||
case android.SdkSystemServer:
|
||||
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
|
||||
return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), sdkFrameworkAidlPath(ctx))
|
||||
return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx))
|
||||
default:
|
||||
panic(fmt.Errorf("invalid sdk %q", sdkVersion.Raw))
|
||||
}
|
||||
@@ -269,9 +269,9 @@ func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
// Create framework.aidl by extracting anything that implements android.os.Parcelable from the SDK stubs modules.
|
||||
func createSdkFrameworkAidl(ctx android.SingletonContext) {
|
||||
stubsModules := []string{
|
||||
android.SdkPublic.JavaLibraryName(ctx.Config()),
|
||||
android.SdkTest.JavaLibraryName(ctx.Config()),
|
||||
android.SdkSystem.JavaLibraryName(ctx.Config()),
|
||||
android.SdkPublic.DefaultJavaLibraryName(),
|
||||
android.SdkTest.DefaultJavaLibraryName(),
|
||||
android.SdkSystem.DefaultJavaLibraryName(),
|
||||
}
|
||||
|
||||
combinedAidl := sdkFrameworkAidlPath(ctx)
|
||||
@@ -286,7 +286,7 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) {
|
||||
|
||||
// Creates a version of framework.aidl for the non-updatable part of the platform.
|
||||
func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) {
|
||||
stubsModules := []string{android.SdkModule.JavaLibraryName(ctx.Config())}
|
||||
stubsModules := []string{android.SdkModule.DefaultJavaLibraryName()}
|
||||
|
||||
combinedAidl := nonUpdatableFrameworkAidlPath(ctx)
|
||||
tempPath := tempPathForRestat(ctx, combinedAidl)
|
||||
|
Reference in New Issue
Block a user