Revert "Revert "Enable from-text stub generation in non-sdk java..."
Revert submission 3207397-revert-2982300-java_api_library_non_sdk-FIKZOSARQI Reason for revert: Post submit build breakage culprit fixed Reverted changes: /q/submissionid:3207397-revert-2982300-java_api_library_non_sdk-FIKZOSARQI Change-Id: Ic79b7fd074f02febba94183cb1479874efe044b5
This commit is contained in:
committed by
Gerrit Code Review
parent
a574cd28a8
commit
b0f4c0239d
@@ -1975,17 +1975,6 @@ func (c *config) SetBuildFromTextStub(b bool) {
|
|||||||
c.productVariables.Build_from_text_stub = boolPtr(b)
|
c.productVariables.Build_from_text_stub = boolPtr(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) SetApiLibraries(libs []string) {
|
|
||||||
c.apiLibraries = make(map[string]struct{})
|
|
||||||
for _, lib := range libs {
|
|
||||||
c.apiLibraries[lib] = struct{}{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *config) GetApiLibraries() map[string]struct{} {
|
|
||||||
return c.apiLibraries
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *deviceConfig) CheckVendorSeappViolations() bool {
|
func (c *deviceConfig) CheckVendorSeappViolations() bool {
|
||||||
return Bool(c.config.productVariables.CheckVendorSeappViolations)
|
return Bool(c.config.productVariables.CheckVendorSeappViolations)
|
||||||
}
|
}
|
||||||
|
@@ -9992,9 +9992,6 @@ func TestApexLintBcpFragmentSdkLibDeps(t *testing.T) {
|
|||||||
java.PrepareForTestWithJavaSdkLibraryFiles,
|
java.PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
java.PrepareForTestWithJacocoInstrumentation,
|
java.PrepareForTestWithJacocoInstrumentation,
|
||||||
java.FixtureWithLastReleaseApis("foo"),
|
java.FixtureWithLastReleaseApis("foo"),
|
||||||
android.FixtureModifyConfig(func(config android.Config) {
|
|
||||||
config.SetApiLibraries([]string{"foo"})
|
|
||||||
}),
|
|
||||||
android.FixtureMergeMockFs(fs),
|
android.FixtureMergeMockFs(fs),
|
||||||
).RunTestWithBp(t, bp)
|
).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
@@ -11478,9 +11475,6 @@ func TestAconfifDeclarationsValidation(t *testing.T) {
|
|||||||
prepareForApexTest,
|
prepareForApexTest,
|
||||||
java.PrepareForTestWithJavaSdkLibraryFiles,
|
java.PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
java.FixtureWithLastReleaseApis("foo"),
|
java.FixtureWithLastReleaseApis("foo"),
|
||||||
android.FixtureModifyConfig(func(config android.Config) {
|
|
||||||
config.SetApiLibraries([]string{"foo"})
|
|
||||||
}),
|
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "baz-java-lib",
|
name: "baz-java-lib",
|
||||||
|
@@ -41,7 +41,7 @@ java_defaults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "core.current.stubs.from-source",
|
name: "core.current.stubs",
|
||||||
defaults: [
|
defaults: [
|
||||||
"core.current.stubs.defaults",
|
"core.current.stubs.defaults",
|
||||||
],
|
],
|
||||||
@@ -52,8 +52,12 @@ java_library {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used for bootstrapping ART system modules
|
||||||
java_api_library {
|
java_api_library {
|
||||||
name: "core.current.stubs.from-text",
|
name: "core.current.stubs.from-text",
|
||||||
|
defaults: [
|
||||||
|
"core.current.stubs.defaults",
|
||||||
|
],
|
||||||
api_surface: "core",
|
api_surface: "core",
|
||||||
api_contributions: [
|
api_contributions: [
|
||||||
"art.module.public.api.stubs.source.api.contribution",
|
"art.module.public.api.stubs.source.api.contribution",
|
||||||
@@ -68,27 +72,7 @@ java_api_library {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "core.current.stubs",
|
name: "core.current.stubs.exportable",
|
||||||
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",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
java_library {
|
|
||||||
name: "core.current.stubs.exportable.from-source",
|
|
||||||
defaults: [
|
defaults: [
|
||||||
"core.current.stubs.defaults",
|
"core.current.stubs.defaults",
|
||||||
],
|
],
|
||||||
@@ -103,16 +87,6 @@ java_library {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
|
||||||
name: "core.current.stubs.exportable",
|
|
||||||
defaults: [
|
|
||||||
"core.current.stubs.defaults",
|
|
||||||
],
|
|
||||||
static_libs: [
|
|
||||||
"core.current.stubs.exportable.from-source",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
// Distributed with the SDK for turning into system modules to compile apps
|
// Distributed with the SDK for turning into system modules to compile apps
|
||||||
// against.
|
// against.
|
||||||
//
|
//
|
||||||
@@ -200,26 +174,6 @@ java_library {
|
|||||||
defaults: [
|
defaults: [
|
||||||
"core.module_lib.stubs.defaults",
|
"core.module_lib.stubs.defaults",
|
||||||
],
|
],
|
||||||
static_libs: [
|
|
||||||
"core.module_lib.stubs.from-source",
|
|
||||||
],
|
|
||||||
product_variables: {
|
|
||||||
build_from_text_stub: {
|
|
||||||
static_libs: [
|
|
||||||
"core.module_lib.stubs.from-text",
|
|
||||||
],
|
|
||||||
exclude_static_libs: [
|
|
||||||
"core.module_lib.stubs.from-source",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
java_library {
|
|
||||||
name: "core.module_lib.stubs.from-source",
|
|
||||||
defaults: [
|
|
||||||
"core.module_lib.stubs.defaults",
|
|
||||||
],
|
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"art.module.public.api.stubs.module_lib",
|
"art.module.public.api.stubs.module_lib",
|
||||||
|
|
||||||
@@ -231,27 +185,6 @@ java_library {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_api_library {
|
|
||||||
name: "core.module_lib.stubs.from-text",
|
|
||||||
api_surface: "module-lib",
|
|
||||||
api_contributions: [
|
|
||||||
"art.module.public.api.stubs.source.api.contribution",
|
|
||||||
"art.module.public.api.stubs.source.system.api.contribution",
|
|
||||||
"art.module.public.api.stubs.source.module_lib.api.contribution",
|
|
||||||
|
|
||||||
// Add the module-lib correspondence when Conscrypt or i18N module
|
|
||||||
// provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
|
|
||||||
// @SystemApi(MODULE_LIBRARIES).
|
|
||||||
"conscrypt.module.public.api.stubs.source.api.contribution",
|
|
||||||
"i18n.module.public.api.stubs.source.api.contribution",
|
|
||||||
],
|
|
||||||
libs: [
|
|
||||||
"stub-annotations",
|
|
||||||
],
|
|
||||||
visibility: ["//visibility:private"],
|
|
||||||
stubs_type: "everything",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Produces a dist file that is used by the
|
// Produces a dist file that is used by the
|
||||||
// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
|
// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
|
||||||
// directory.
|
// directory.
|
||||||
@@ -311,7 +244,7 @@ core_platform_visibility = ["//visibility:public"]
|
|||||||
// API annotations are available to the dex tools that enable enforcement of runtime
|
// API annotations are available to the dex tools that enable enforcement of runtime
|
||||||
// accessibility. b/119068555
|
// accessibility. b/119068555
|
||||||
java_library {
|
java_library {
|
||||||
name: "legacy.core.platform.api.stubs.from-source",
|
name: "legacy.core.platform.api.stubs",
|
||||||
visibility: core_platform_visibility,
|
visibility: core_platform_visibility,
|
||||||
defaults: [
|
defaults: [
|
||||||
"core.platform.api.stubs.defaults",
|
"core.platform.api.stubs.defaults",
|
||||||
@@ -324,7 +257,7 @@ java_library {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "legacy.core.platform.api.stubs.exportable.from-source",
|
name: "legacy.core.platform.api.stubs.exportable",
|
||||||
visibility: core_platform_visibility,
|
visibility: core_platform_visibility,
|
||||||
defaults: [
|
defaults: [
|
||||||
"core.platform.api.stubs.defaults",
|
"core.platform.api.stubs.defaults",
|
||||||
@@ -348,53 +281,6 @@ java_defaults {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_api_library {
|
|
||||||
name: "legacy.core.platform.api.stubs.from-text",
|
|
||||||
api_surface: "core_platform",
|
|
||||||
defaults: [
|
|
||||||
"android_core_platform_stubs_current_contributions",
|
|
||||||
],
|
|
||||||
api_contributions: [
|
|
||||||
"legacy.i18n.module.platform.api.stubs.source.api.contribution",
|
|
||||||
],
|
|
||||||
libs: [
|
|
||||||
"stub-annotations",
|
|
||||||
],
|
|
||||||
stubs_type: "everything",
|
|
||||||
}
|
|
||||||
|
|
||||||
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: [
|
|
||||||
"legacy.core.platform.api.stubs.from-text",
|
|
||||||
],
|
|
||||||
exclude_static_libs: [
|
|
||||||
"legacy.core.platform.api.stubs.from-source",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
java_library {
|
|
||||||
name: "legacy.core.platform.api.stubs.exportable",
|
|
||||||
visibility: core_platform_visibility,
|
|
||||||
defaults: [
|
|
||||||
"core.platform.api.stubs.defaults",
|
|
||||||
],
|
|
||||||
static_libs: [
|
|
||||||
"legacy.core.platform.api.stubs.exportable.from-source",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
java_defaults {
|
java_defaults {
|
||||||
name: "core.platform.api.stubs.defaults",
|
name: "core.platform.api.stubs.defaults",
|
||||||
hostdex: true,
|
hostdex: true,
|
||||||
@@ -424,7 +310,7 @@ java_library {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "stable.core.platform.api.stubs.from-source",
|
name: "stable.core.platform.api.stubs",
|
||||||
visibility: core_platform_visibility,
|
visibility: core_platform_visibility,
|
||||||
defaults: [
|
defaults: [
|
||||||
"core.platform.api.stubs.defaults",
|
"core.platform.api.stubs.defaults",
|
||||||
@@ -437,42 +323,6 @@ java_library {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_api_library {
|
|
||||||
name: "stable.core.platform.api.stubs.from-text",
|
|
||||||
api_surface: "core_platform",
|
|
||||||
defaults: [
|
|
||||||
"android_core_platform_stubs_current_contributions",
|
|
||||||
],
|
|
||||||
api_contributions: [
|
|
||||||
"stable.i18n.module.platform.api.stubs.source.api.contribution",
|
|
||||||
],
|
|
||||||
libs: [
|
|
||||||
"stub-annotations",
|
|
||||||
],
|
|
||||||
stubs_type: "everything",
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
// Same as stable.core.platform.api.stubs, but android annotations are
|
||||||
// stripped. This is used by the Java toolchain, while the annotated stub is to
|
// stripped. This is used by the Java toolchain, while the annotated stub is to
|
||||||
// be used by Kotlin one.
|
// be used by Kotlin one.
|
||||||
|
129
java/java.go
129
java/java.go
@@ -432,7 +432,6 @@ var (
|
|||||||
r8LibraryJarTag = dependencyTag{name: "r8-libraryjar", runtimeLinked: true}
|
r8LibraryJarTag = dependencyTag{name: "r8-libraryjar", runtimeLinked: true}
|
||||||
syspropPublicStubDepTag = dependencyTag{name: "sysprop public stub"}
|
syspropPublicStubDepTag = dependencyTag{name: "sysprop public stub"}
|
||||||
javaApiContributionTag = dependencyTag{name: "java-api-contribution"}
|
javaApiContributionTag = dependencyTag{name: "java-api-contribution"}
|
||||||
depApiSrcsTag = dependencyTag{name: "dep-api-srcs"}
|
|
||||||
aconfigDeclarationTag = dependencyTag{name: "aconfig-declaration"}
|
aconfigDeclarationTag = dependencyTag{name: "aconfig-declaration"}
|
||||||
jniInstallTag = dependencyTag{name: "jni install", runtimeLinked: true, installable: true}
|
jniInstallTag = dependencyTag{name: "jni install", runtimeLinked: true, installable: true}
|
||||||
binaryInstallTag = dependencyTag{name: "binary install", runtimeLinked: true, installable: true}
|
binaryInstallTag = dependencyTag{name: "binary install", runtimeLinked: true, installable: true}
|
||||||
@@ -2005,12 +2004,6 @@ type JavaApiLibraryProperties struct {
|
|||||||
// merge zipped after metalava invocation
|
// merge zipped after metalava invocation
|
||||||
Static_libs []string
|
Static_libs []string
|
||||||
|
|
||||||
// Java Api library to provide the full API surface stub jar file.
|
|
||||||
// If this property is set, the stub jar of this module is created by
|
|
||||||
// extracting the compiled class files provided by the
|
|
||||||
// full_api_surface_stub module.
|
|
||||||
Full_api_surface_stub *string
|
|
||||||
|
|
||||||
// Version of previously released API file for compatibility check.
|
// Version of previously released API file for compatibility check.
|
||||||
Previous_api *string `android:"path"`
|
Previous_api *string `android:"path"`
|
||||||
|
|
||||||
@@ -2043,6 +2036,15 @@ type JavaApiLibraryProperties struct {
|
|||||||
// List of hard coded filegroups containing Metalava config files that are passed to every
|
// List of hard coded filegroups containing Metalava config files that are passed to every
|
||||||
// Metalava invocation that this module performs. See addMetalavaConfigFilesToCmd.
|
// Metalava invocation that this module performs. See addMetalavaConfigFilesToCmd.
|
||||||
ConfigFiles []string `android:"path" blueprint:"mutated"`
|
ConfigFiles []string `android:"path" blueprint:"mutated"`
|
||||||
|
|
||||||
|
// If not blank, set to the version of the sdk to compile against.
|
||||||
|
// Defaults to an empty string, which compiles the module against the private platform APIs.
|
||||||
|
// Values are of one of the following forms:
|
||||||
|
// 1) numerical API level, "current", "none", or "core_platform"
|
||||||
|
// 2) An SDK kind with an API level: "<sdk kind>_<API level>"
|
||||||
|
// See build/soong/android/sdk_version.go for the complete and up to date list of SDK kinds.
|
||||||
|
// If the SDK kind is empty, it will be set to public.
|
||||||
|
Sdk_version *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func ApiLibraryFactory() android.Module {
|
func ApiLibraryFactory() android.Module {
|
||||||
@@ -2141,40 +2143,6 @@ func (al *ApiLibrary) addValidation(ctx android.ModuleContext, cmd *android.Rule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method extracts the stub class files from the stub jar file provided
|
|
||||||
// from full_api_surface_stub module instead of compiling the srcjar generated from invoking metalava.
|
|
||||||
// This method is used because metalava can generate compilable from-text stubs only when
|
|
||||||
// the codebase encompasses all classes listed in the input API text file, and a class can extend
|
|
||||||
// a class that is not within the same API domain.
|
|
||||||
func (al *ApiLibrary) extractApiSrcs(ctx android.ModuleContext, rule *android.RuleBuilder, stubsDir android.OptionalPath, fullApiSurfaceStubJar android.Path) {
|
|
||||||
classFilesList := android.PathForModuleOut(ctx, "metalava", "classes.txt")
|
|
||||||
unzippedSrcJarDir := android.PathForModuleOut(ctx, "metalava", "unzipDir")
|
|
||||||
|
|
||||||
rule.Command().
|
|
||||||
BuiltTool("list_files").
|
|
||||||
Text(stubsDir.String()).
|
|
||||||
FlagWithOutput("--out ", classFilesList).
|
|
||||||
FlagWithArg("--extensions ", ".java").
|
|
||||||
FlagWithArg("--root ", unzippedSrcJarDir.String()).
|
|
||||||
Flag("--classes")
|
|
||||||
|
|
||||||
rule.Command().
|
|
||||||
Text("unzip").
|
|
||||||
Flag("-q").
|
|
||||||
Input(fullApiSurfaceStubJar).
|
|
||||||
FlagWithArg("-d ", unzippedSrcJarDir.String())
|
|
||||||
|
|
||||||
rule.Command().
|
|
||||||
BuiltTool("soong_zip").
|
|
||||||
Flag("-jar").
|
|
||||||
Flag("-write_if_changed").
|
|
||||||
Flag("-ignore_missing_files").
|
|
||||||
Flag("-quiet").
|
|
||||||
FlagWithArg("-C ", unzippedSrcJarDir.String()).
|
|
||||||
FlagWithInput("-l ", classFilesList).
|
|
||||||
FlagWithOutput("-o ", al.stubsJarWithoutStaticLibs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
apiContributions := al.properties.Api_contributions
|
apiContributions := al.properties.Api_contributions
|
||||||
addValidations := !ctx.Config().IsEnvTrue("DISABLE_STUB_VALIDATION") &&
|
addValidations := !ctx.Config().IsEnvTrue("DISABLE_STUB_VALIDATION") &&
|
||||||
@@ -2201,14 +2169,18 @@ func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ctx.Device() {
|
||||||
|
sdkDep := decodeSdkDep(ctx, android.SdkContext(al))
|
||||||
|
if sdkDep.useModule {
|
||||||
|
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
||||||
|
ctx.AddVariationDependencies(nil, libTag, sdkDep.classpath...)
|
||||||
|
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
ctx.AddVariationDependencies(nil, libTag, al.properties.Libs...)
|
ctx.AddVariationDependencies(nil, libTag, al.properties.Libs...)
|
||||||
ctx.AddVariationDependencies(nil, staticLibTag, al.properties.Static_libs...)
|
ctx.AddVariationDependencies(nil, staticLibTag, al.properties.Static_libs...)
|
||||||
if al.properties.Full_api_surface_stub != nil {
|
|
||||||
ctx.AddVariationDependencies(nil, depApiSrcsTag, String(al.properties.Full_api_surface_stub))
|
|
||||||
}
|
|
||||||
if al.properties.System_modules != nil {
|
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, String(al.properties.System_modules))
|
|
||||||
}
|
|
||||||
for _, aconfigDeclarationsName := range al.properties.Aconfig_declarations {
|
for _, aconfigDeclarationsName := range al.properties.Aconfig_declarations {
|
||||||
ctx.AddDependency(ctx.Module(), aconfigDeclarationTag, aconfigDeclarationsName)
|
ctx.AddDependency(ctx.Module(), aconfigDeclarationTag, aconfigDeclarationsName)
|
||||||
}
|
}
|
||||||
@@ -2264,8 +2236,8 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
var srcFilesInfo []JavaApiImportInfo
|
var srcFilesInfo []JavaApiImportInfo
|
||||||
var classPaths android.Paths
|
var classPaths android.Paths
|
||||||
|
var bootclassPaths android.Paths
|
||||||
var staticLibs android.Paths
|
var staticLibs android.Paths
|
||||||
var depApiSrcsStubsJar android.Path
|
|
||||||
var systemModulesPaths android.Paths
|
var systemModulesPaths android.Paths
|
||||||
ctx.VisitDirectDeps(func(dep android.Module) {
|
ctx.VisitDirectDeps(func(dep android.Module) {
|
||||||
tag := ctx.OtherModuleDependencyTag(dep)
|
tag := ctx.OtherModuleDependencyTag(dep)
|
||||||
@@ -2279,12 +2251,12 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
case libTag:
|
case libTag:
|
||||||
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
||||||
classPaths = append(classPaths, provider.HeaderJars...)
|
classPaths = append(classPaths, provider.HeaderJars...)
|
||||||
|
case bootClasspathTag:
|
||||||
|
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
||||||
|
bootclassPaths = append(bootclassPaths, provider.HeaderJars...)
|
||||||
case staticLibTag:
|
case staticLibTag:
|
||||||
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
||||||
staticLibs = append(staticLibs, provider.HeaderJars...)
|
staticLibs = append(staticLibs, provider.HeaderJars...)
|
||||||
case depApiSrcsTag:
|
|
||||||
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
|
||||||
depApiSrcsStubsJar = provider.HeaderJars[0]
|
|
||||||
case systemModulesTag:
|
case systemModulesTag:
|
||||||
module := dep.(SystemModulesProvider)
|
module := dep.(SystemModulesProvider)
|
||||||
systemModulesPaths = append(systemModulesPaths, module.HeaderJars()...)
|
systemModulesPaths = append(systemModulesPaths, module.HeaderJars()...)
|
||||||
@@ -2319,7 +2291,10 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
configFiles := android.PathsForModuleSrc(ctx, al.properties.ConfigFiles)
|
configFiles := android.PathsForModuleSrc(ctx, al.properties.ConfigFiles)
|
||||||
|
|
||||||
cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir, systemModulesPaths, configFiles)
|
combinedPaths := append(([]android.Path)(nil), systemModulesPaths...)
|
||||||
|
combinedPaths = append(combinedPaths, classPaths...)
|
||||||
|
combinedPaths = append(combinedPaths, bootclassPaths...)
|
||||||
|
cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir, combinedPaths, configFiles)
|
||||||
|
|
||||||
al.stubsFlags(ctx, cmd, stubsDir)
|
al.stubsFlags(ctx, cmd, stubsDir)
|
||||||
|
|
||||||
@@ -2337,9 +2312,6 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
al.stubsJarWithoutStaticLibs = android.PathForModuleOut(ctx, "metalava", "stubs.jar")
|
al.stubsJarWithoutStaticLibs = android.PathForModuleOut(ctx, "metalava", "stubs.jar")
|
||||||
al.stubsJar = android.PathForModuleOut(ctx, ctx.ModuleName(), fmt.Sprintf("%s.jar", ctx.ModuleName()))
|
al.stubsJar = android.PathForModuleOut(ctx, ctx.ModuleName(), fmt.Sprintf("%s.jar", ctx.ModuleName()))
|
||||||
|
|
||||||
if depApiSrcsStubsJar != nil {
|
|
||||||
al.extractApiSrcs(ctx, rule, stubsDir, depApiSrcsStubsJar)
|
|
||||||
}
|
|
||||||
rule.Command().
|
rule.Command().
|
||||||
BuiltTool("soong_zip").
|
BuiltTool("soong_zip").
|
||||||
Flag("-write_if_changed").
|
Flag("-write_if_changed").
|
||||||
@@ -2350,19 +2322,18 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
rule.Build("metalava", "metalava merged text")
|
rule.Build("metalava", "metalava merged text")
|
||||||
|
|
||||||
if depApiSrcsStubsJar == nil {
|
javacFlags := javaBuilderFlags{
|
||||||
var flags javaBuilderFlags
|
javaVersion: getStubsJavaVersion(),
|
||||||
flags.javaVersion = getStubsJavaVersion()
|
javacFlags: strings.Join(al.properties.Javacflags, " "),
|
||||||
flags.javacFlags = strings.Join(al.properties.Javacflags, " ")
|
classpath: classpath(classPaths),
|
||||||
flags.classpath = classpath(classPaths)
|
bootClasspath: classpath(append(systemModulesPaths, bootclassPaths...)),
|
||||||
flags.bootClasspath = classpath(systemModulesPaths)
|
|
||||||
|
|
||||||
annoSrcJar := android.PathForModuleOut(ctx, ctx.ModuleName(), "anno.srcjar")
|
|
||||||
|
|
||||||
TransformJavaToClasses(ctx, al.stubsJarWithoutStaticLibs, 0, android.Paths{},
|
|
||||||
android.Paths{al.stubsSrcJar}, annoSrcJar, flags, android.Paths{})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
annoSrcJar := android.PathForModuleOut(ctx, ctx.ModuleName(), "anno.srcjar")
|
||||||
|
|
||||||
|
TransformJavaToClasses(ctx, al.stubsJarWithoutStaticLibs, 0, android.Paths{},
|
||||||
|
android.Paths{al.stubsSrcJar}, annoSrcJar, javacFlags, android.Paths{})
|
||||||
|
|
||||||
builder := android.NewRuleBuilder(pctx, ctx)
|
builder := android.NewRuleBuilder(pctx, ctx)
|
||||||
builder.Command().
|
builder.Command().
|
||||||
BuiltTool("merge_zips").
|
BuiltTool("merge_zips").
|
||||||
@@ -2373,7 +2344,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
// compile stubs to .dex for hiddenapi processing
|
// compile stubs to .dex for hiddenapi processing
|
||||||
dexParams := &compileDexParams{
|
dexParams := &compileDexParams{
|
||||||
flags: javaBuilderFlags{},
|
flags: javacFlags,
|
||||||
sdkVersion: al.SdkVersion(ctx),
|
sdkVersion: al.SdkVersion(ctx),
|
||||||
minSdkVersion: al.MinSdkVersion(ctx),
|
minSdkVersion: al.MinSdkVersion(ctx),
|
||||||
classesJar: al.stubsJar,
|
classesJar: al.stubsJar,
|
||||||
@@ -2409,14 +2380,28 @@ func (al *ApiLibrary) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// java_api_library constitutes the sdk, and does not build against one
|
// Most java_api_library constitues the sdk, but there are some java_api_library that
|
||||||
|
// does not contribute to the api surface. Such modules are allowed to set sdk_version
|
||||||
|
// other than "none"
|
||||||
func (al *ApiLibrary) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
func (al *ApiLibrary) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||||
return android.SdkSpecNone
|
return android.SdkSpecFrom(ctx, proptools.String(al.properties.Sdk_version))
|
||||||
}
|
}
|
||||||
|
|
||||||
// java_api_library is always at "current". Return FutureApiLevel
|
// java_api_library is always at "current". Return FutureApiLevel
|
||||||
func (al *ApiLibrary) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
func (al *ApiLibrary) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||||
return android.FutureApiLevel
|
return al.SdkVersion(ctx).ApiLevel
|
||||||
|
}
|
||||||
|
|
||||||
|
func (al *ApiLibrary) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||||
|
return al.SdkVersion(ctx).ApiLevel
|
||||||
|
}
|
||||||
|
|
||||||
|
func (al *ApiLibrary) SystemModules() string {
|
||||||
|
return proptools.String(al.properties.System_modules)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (al *ApiLibrary) TargetSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||||
|
return al.SdkVersion(ctx).ApiLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (al *ApiLibrary) IDEInfo(i *android.IdeInfo) {
|
func (al *ApiLibrary) IDEInfo(i *android.IdeInfo) {
|
||||||
@@ -2434,9 +2419,6 @@ func (al *ApiLibrary) ideDeps() []string {
|
|||||||
if al.properties.System_modules != nil {
|
if al.properties.System_modules != nil {
|
||||||
ret = append(ret, proptools.String(al.properties.System_modules))
|
ret = append(ret, proptools.String(al.properties.System_modules))
|
||||||
}
|
}
|
||||||
if al.properties.Full_api_surface_stub != nil {
|
|
||||||
ret = append(ret, proptools.String(al.properties.Full_api_surface_stub))
|
|
||||||
}
|
|
||||||
// Other non java_library dependencies like java_api_contribution are ignored for now.
|
// Other non java_library dependencies like java_api_contribution are ignored for now.
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@@ -2444,6 +2426,7 @@ func (al *ApiLibrary) ideDeps() []string {
|
|||||||
// implement the following interfaces for hiddenapi processing
|
// implement the following interfaces for hiddenapi processing
|
||||||
var _ hiddenAPIModule = (*ApiLibrary)(nil)
|
var _ hiddenAPIModule = (*ApiLibrary)(nil)
|
||||||
var _ UsesLibraryDependency = (*ApiLibrary)(nil)
|
var _ UsesLibraryDependency = (*ApiLibrary)(nil)
|
||||||
|
var _ android.SdkContext = (*ApiLibrary)(nil)
|
||||||
|
|
||||||
// implement the following interface for IDE completion.
|
// implement the following interface for IDE completion.
|
||||||
var _ android.IDEInfo = (*ApiLibrary)(nil)
|
var _ android.IDEInfo = (*ApiLibrary)(nil)
|
||||||
|
@@ -1342,12 +1342,12 @@ func TestJavaLibraryWithSystemModules(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
checkBootClasspathForSystemModule(t, ctx, "lib-with-source-system-modules", "/source-jar.jar")
|
checkBootClasspathForLibWithSystemModule(t, ctx, "lib-with-source-system-modules", "/source-jar.jar")
|
||||||
|
|
||||||
checkBootClasspathForSystemModule(t, ctx, "lib-with-prebuilt-system-modules", "/prebuilt-jar.jar")
|
checkBootClasspathForLibWithSystemModule(t, ctx, "lib-with-prebuilt-system-modules", "/prebuilt-jar.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkBootClasspathForSystemModule(t *testing.T, ctx *android.TestContext, moduleName string, expectedSuffix string) {
|
func checkBootClasspathForLibWithSystemModule(t *testing.T, ctx *android.TestContext, moduleName string, expectedSuffix string) {
|
||||||
javacRule := ctx.ModuleForTests(moduleName, "android_common").Rule("javac")
|
javacRule := ctx.ModuleForTests(moduleName, "android_common").Rule("javac")
|
||||||
bootClasspath := javacRule.Args["bootClasspath"]
|
bootClasspath := javacRule.Args["bootClasspath"]
|
||||||
if strings.HasPrefix(bootClasspath, "--system ") && strings.HasSuffix(bootClasspath, expectedSuffix) {
|
if strings.HasPrefix(bootClasspath, "--system ") && strings.HasSuffix(bootClasspath, expectedSuffix) {
|
||||||
@@ -2256,61 +2256,6 @@ func TestJavaApiLibraryStaticLibsLink(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) {
|
|
||||||
provider_bp_a := `
|
|
||||||
java_api_contribution {
|
|
||||||
name: "foo1",
|
|
||||||
api_file: "current.txt",
|
|
||||||
api_surface: "public",
|
|
||||||
}
|
|
||||||
`
|
|
||||||
provider_bp_b := `
|
|
||||||
java_api_contribution {
|
|
||||||
name: "foo2",
|
|
||||||
api_file: "current.txt",
|
|
||||||
api_surface: "public",
|
|
||||||
}
|
|
||||||
`
|
|
||||||
lib_bp_a := `
|
|
||||||
java_api_library {
|
|
||||||
name: "lib1",
|
|
||||||
api_surface: "public",
|
|
||||||
api_contributions: ["foo1", "foo2"],
|
|
||||||
stubs_type: "everything",
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
ctx := android.GroupFixturePreparers(
|
|
||||||
prepareForJavaTest,
|
|
||||||
android.FixtureMergeMockFs(
|
|
||||||
map[string][]byte{
|
|
||||||
"a/Android.bp": []byte(provider_bp_a),
|
|
||||||
"b/Android.bp": []byte(provider_bp_b),
|
|
||||||
"c/Android.bp": []byte(lib_bp_a),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
android.FixtureMergeEnv(
|
|
||||||
map[string]string{
|
|
||||||
"DISABLE_STUB_VALIDATION": "true",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
).RunTestWithBp(t, `
|
|
||||||
java_api_library {
|
|
||||||
name: "bar1",
|
|
||||||
api_surface: "public",
|
|
||||||
api_contributions: ["foo1"],
|
|
||||||
full_api_surface_stub: "lib1",
|
|
||||||
stubs_type: "everything",
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
|
|
||||||
m := ctx.ModuleForTests("bar1", "android_common")
|
|
||||||
manifest := m.Output("metalava.sbox.textproto")
|
|
||||||
sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest)
|
|
||||||
manifestCommand := sboxProto.Commands[0].GetCommand()
|
|
||||||
android.AssertStringDoesContain(t, "Command expected to contain full_api_surface_stub output jar", manifestCommand, "lib1.jar")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTransitiveSrcFiles(t *testing.T) {
|
func TestTransitiveSrcFiles(t *testing.T) {
|
||||||
ctx, _ := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
@@ -2511,9 +2456,6 @@ func TestSdkLibraryProvidesSystemModulesToApiLibrary(t *testing.T) {
|
|||||||
prepareForJavaTest,
|
prepareForJavaTest,
|
||||||
PrepareForTestWithJavaSdkLibraryFiles,
|
PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
FixtureWithLastReleaseApis("foo"),
|
FixtureWithLastReleaseApis("foo"),
|
||||||
android.FixtureModifyConfig(func(config android.Config) {
|
|
||||||
config.SetApiLibraries([]string{"foo"})
|
|
||||||
}),
|
|
||||||
android.FixtureMergeMockFs(
|
android.FixtureMergeMockFs(
|
||||||
map[string][]byte{
|
map[string][]byte{
|
||||||
"A.java": nil,
|
"A.java": nil,
|
||||||
@@ -2534,12 +2476,8 @@ func TestSdkLibraryProvidesSystemModulesToApiLibrary(t *testing.T) {
|
|||||||
system_modules: "baz",
|
system_modules: "baz",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
m := result.ModuleForTests(apiScopePublic.apiLibraryModuleName("foo"), "android_common")
|
|
||||||
manifest := m.Output("metalava.sbox.textproto")
|
checkBootClasspathForLibWithSystemModule(t, result.TestContext, apiScopePublic.apiLibraryModuleName("foo"), "/bar.jar")
|
||||||
sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest)
|
|
||||||
manifestCommand := sboxProto.Commands[0].GetCommand()
|
|
||||||
classPathFlag := "--classpath __SBOX_SANDBOX_DIR__/out/soong/.intermediates/bar/android_common/turbine-combined/bar.jar"
|
|
||||||
android.AssertStringDoesContain(t, "command expected to contain classpath flag", manifestCommand, classPathFlag)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApiLibraryDroidstubsDependency(t *testing.T) {
|
func TestApiLibraryDroidstubsDependency(t *testing.T) {
|
||||||
@@ -2547,9 +2485,6 @@ func TestApiLibraryDroidstubsDependency(t *testing.T) {
|
|||||||
prepareForJavaTest,
|
prepareForJavaTest,
|
||||||
PrepareForTestWithJavaSdkLibraryFiles,
|
PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
FixtureWithLastReleaseApis("foo"),
|
FixtureWithLastReleaseApis("foo"),
|
||||||
android.FixtureModifyConfig(func(config android.Config) {
|
|
||||||
config.SetApiLibraries([]string{"foo"})
|
|
||||||
}),
|
|
||||||
android.FixtureMergeMockFs(
|
android.FixtureMergeMockFs(
|
||||||
map[string][]byte{
|
map[string][]byte{
|
||||||
"A.java": nil,
|
"A.java": nil,
|
||||||
@@ -2598,7 +2533,6 @@ func TestDisableFromTextStubForCoverageBuild(t *testing.T) {
|
|||||||
PrepareForTestWithJacocoInstrumentation,
|
PrepareForTestWithJacocoInstrumentation,
|
||||||
FixtureWithLastReleaseApis("foo"),
|
FixtureWithLastReleaseApis("foo"),
|
||||||
android.FixtureModifyConfig(func(config android.Config) {
|
android.FixtureModifyConfig(func(config android.Config) {
|
||||||
config.SetApiLibraries([]string{"foo"})
|
|
||||||
config.SetBuildFromTextStub(true)
|
config.SetBuildFromTextStub(true)
|
||||||
}),
|
}),
|
||||||
android.FixtureModifyEnv(func(env map[string]string) {
|
android.FixtureModifyEnv(func(env map[string]string) {
|
||||||
|
@@ -427,22 +427,10 @@ var (
|
|||||||
apiScopeModuleLib,
|
apiScopeModuleLib,
|
||||||
apiScopeSystemServer,
|
apiScopeSystemServer,
|
||||||
}
|
}
|
||||||
apiLibraryAdditionalProperties = map[string]struct {
|
apiLibraryAdditionalProperties = map[string]string{
|
||||||
FullApiSurfaceStubLib string
|
"legacy.i18n.module.platform.api": "i18n.module.public.api.stubs.source.api.contribution",
|
||||||
AdditionalApiContribution string
|
"stable.i18n.module.platform.api": "i18n.module.public.api.stubs.source.api.contribution",
|
||||||
}{
|
"conscrypt.module.platform.api": "conscrypt.module.public.api.stubs.source.api.contribution",
|
||||||
"legacy.i18n.module.platform.api": {
|
|
||||||
FullApiSurfaceStubLib: "legacy.core.platform.api.stubs",
|
|
||||||
AdditionalApiContribution: "i18n.module.public.api.stubs.source.api.contribution",
|
|
||||||
},
|
|
||||||
"stable.i18n.module.platform.api": {
|
|
||||||
FullApiSurfaceStubLib: "stable.core.platform.api.stubs",
|
|
||||||
AdditionalApiContribution: "i18n.module.public.api.stubs.source.api.contribution",
|
|
||||||
},
|
|
||||||
"conscrypt.module.platform.api": {
|
|
||||||
FullApiSurfaceStubLib: "stable.core.platform.api.stubs",
|
|
||||||
AdditionalApiContribution: "conscrypt.module.public.api.stubs.source.api.contribution",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -650,13 +638,6 @@ type sdkLibraryProperties struct {
|
|||||||
Legacy_errors_allowed *bool
|
Legacy_errors_allowed *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determines if the module contributes to any api surfaces.
|
|
||||||
// This property should be set to true only if the module is listed under
|
|
||||||
// frameworks-base-api.bootclasspath in frameworks/base/api/Android.bp.
|
|
||||||
// Otherwise, this property should be set to false.
|
|
||||||
// Defaults to false.
|
|
||||||
Contribute_to_android_api *bool
|
|
||||||
|
|
||||||
// a list of aconfig_declarations module names that the stubs generated in this module
|
// a list of aconfig_declarations module names that the stubs generated in this module
|
||||||
// depend on.
|
// depend on.
|
||||||
Aconfig_declarations []string
|
Aconfig_declarations []string
|
||||||
@@ -1751,30 +1732,13 @@ func (module *SdkLibrary) latestIncompatibilitiesModuleName(apiScope *apiScope)
|
|||||||
return latestPrebuiltApiModuleName(module.distStem()+"-incompatibilities", apiScope)
|
return latestPrebuiltApiModuleName(module.distStem()+"-incompatibilities", apiScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) contributesToApiSurface(c android.Config) bool {
|
|
||||||
_, exists := c.GetApiLibraries()[module.Name()]
|
|
||||||
return exists
|
|
||||||
}
|
|
||||||
|
|
||||||
// The listed modules are the special java_sdk_libraries where apiScope.kind do not match the
|
|
||||||
// api surface that the module contribute to. For example, the public droidstubs and java_library
|
|
||||||
// do not contribute to the public api surface, but contributes to the core platform api surface.
|
|
||||||
// This method returns the full api surface stub lib that
|
|
||||||
// the generated java_api_library should depend on.
|
|
||||||
func (module *SdkLibrary) alternativeFullApiSurfaceStubLib() string {
|
|
||||||
if val, ok := apiLibraryAdditionalProperties[module.Name()]; ok {
|
|
||||||
return val.FullApiSurfaceStubLib
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// The listed modules' stubs contents do not match the corresponding txt files,
|
// The listed modules' stubs contents do not match the corresponding txt files,
|
||||||
// but require additional api contributions to generate the full stubs.
|
// but require additional api contributions to generate the full stubs.
|
||||||
// This method returns the name of the additional api contribution module
|
// This method returns the name of the additional api contribution module
|
||||||
// for corresponding sdk_library modules.
|
// for corresponding sdk_library modules.
|
||||||
func (module *SdkLibrary) apiLibraryAdditionalApiContribution() string {
|
func (module *SdkLibrary) apiLibraryAdditionalApiContribution() string {
|
||||||
if val, ok := apiLibraryAdditionalProperties[module.Name()]; ok {
|
if val, ok := apiLibraryAdditionalProperties[module.Name()]; ok {
|
||||||
return val.AdditionalApiContribution
|
return val
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -2069,17 +2033,18 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
|
|||||||
mctx.CreateModule(DroidstubsFactory, &props, module.sdkComponentPropertiesForChildLibrary()).(*Droidstubs).CallHookIfAvailable(mctx)
|
mctx.CreateModule(DroidstubsFactory, &props, module.sdkComponentPropertiesForChildLibrary()).(*Droidstubs).CallHookIfAvailable(mctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope, alternativeFullApiSurfaceStub string) {
|
func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
Visibility []string
|
Visibility []string
|
||||||
Api_contributions []string
|
Api_contributions []string
|
||||||
Libs []string
|
Libs []string
|
||||||
Static_libs []string
|
Static_libs []string
|
||||||
Full_api_surface_stub *string
|
System_modules *string
|
||||||
System_modules *string
|
Enable_validation *bool
|
||||||
Enable_validation *bool
|
Stubs_type *string
|
||||||
Stubs_type *string
|
Sdk_version *string
|
||||||
|
Previous_api *string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
|
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
|
||||||
@@ -2103,34 +2068,29 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
props.Api_contributions = apiContributions
|
props.Api_contributions = apiContributions
|
||||||
props.Libs = module.properties.Libs
|
|
||||||
|
// Ensure that stub-annotations is added to the classpath before any other libs
|
||||||
|
props.Libs = []string{"stub-annotations"}
|
||||||
|
props.Libs = append(props.Libs, module.properties.Libs...)
|
||||||
|
props.Libs = append(props.Libs, module.properties.Static_libs...)
|
||||||
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
|
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
|
||||||
props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
|
props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
|
||||||
props.Libs = append(props.Libs, "stub-annotations")
|
|
||||||
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
|
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
|
||||||
props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName())
|
|
||||||
if alternativeFullApiSurfaceStub != "" {
|
|
||||||
props.Full_api_surface_stub = proptools.StringPtr(alternativeFullApiSurfaceStub)
|
|
||||||
}
|
|
||||||
|
|
||||||
// android_module_lib_stubs_current.from-text only comprises api contributions from art, conscrypt and i18n.
|
|
||||||
// Thus, replace with android_module_lib_stubs_current_full.from-text, which comprises every api domains.
|
|
||||||
if apiScope.kind == android.SdkModule {
|
|
||||||
props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + "_full.from-text")
|
|
||||||
}
|
|
||||||
|
|
||||||
// java_sdk_library modules that set sdk_version as none does not depend on other api
|
|
||||||
// domains. Therefore, java_api_library created from such modules should not depend on
|
|
||||||
// full_api_surface_stubs but create and compile stubs by the java_api_library module
|
|
||||||
// itself.
|
|
||||||
if module.SdkVersion(mctx).Kind == android.SdkNone {
|
|
||||||
props.Full_api_surface_stub = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
props.System_modules = module.deviceProperties.System_modules
|
props.System_modules = module.deviceProperties.System_modules
|
||||||
props.Enable_validation = proptools.BoolPtr(true)
|
props.Enable_validation = proptools.BoolPtr(true)
|
||||||
props.Stubs_type = proptools.StringPtr("everything")
|
props.Stubs_type = proptools.StringPtr("everything")
|
||||||
|
|
||||||
|
if module.deviceProperties.Sdk_version != nil {
|
||||||
|
props.Sdk_version = module.deviceProperties.Sdk_version
|
||||||
|
}
|
||||||
|
|
||||||
|
if module.compareAgainstLatestApi(apiScope) {
|
||||||
|
// check against the latest released API
|
||||||
|
latestApiFilegroupName := proptools.StringPtr(module.latestApiFilegroupName(apiScope))
|
||||||
|
props.Previous_api = latestApiFilegroupName
|
||||||
|
}
|
||||||
|
|
||||||
mctx.CreateModule(ApiLibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
|
mctx.CreateModule(ApiLibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2161,7 +2121,7 @@ func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHook
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) createTopLevelStubsLibrary(
|
func (module *SdkLibrary) createTopLevelStubsLibrary(
|
||||||
mctx android.DefaultableHookContext, apiScope *apiScope, contributesToApiSurface bool) {
|
mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||||
|
|
||||||
// Dist the "everything" stubs when the RELEASE_HIDDEN_API_EXPORTABLE_STUBS build flag is false
|
// Dist the "everything" stubs when the RELEASE_HIDDEN_API_EXPORTABLE_STUBS build flag is false
|
||||||
doDist := !mctx.Config().ReleaseHiddenApiExportableStubs()
|
doDist := !mctx.Config().ReleaseHiddenApiExportableStubs()
|
||||||
@@ -2170,7 +2130,7 @@ func (module *SdkLibrary) createTopLevelStubsLibrary(
|
|||||||
|
|
||||||
// Add the stub compiling java_library/java_api_library as static lib based on build config
|
// Add the stub compiling java_library/java_api_library as static lib based on build config
|
||||||
staticLib := module.sourceStubsLibraryModuleName(apiScope)
|
staticLib := module.sourceStubsLibraryModuleName(apiScope)
|
||||||
if mctx.Config().BuildFromTextStub() && contributesToApiSurface {
|
if mctx.Config().BuildFromTextStub() && module.ModuleBuildFromTextStubs() {
|
||||||
staticLib = module.apiLibraryModuleName(apiScope)
|
staticLib = module.apiLibraryModuleName(apiScope)
|
||||||
}
|
}
|
||||||
props.Static_libs = append(props.Static_libs, staticLib)
|
props.Static_libs = append(props.Static_libs, staticLib)
|
||||||
@@ -2213,8 +2173,8 @@ func (module *SdkLibrary) UniqueApexVariations() bool {
|
|||||||
return module.uniqueApexVariations()
|
return module.uniqueApexVariations()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) ContributeToApi() bool {
|
func (module *SdkLibrary) ModuleBuildFromTextStubs() bool {
|
||||||
return proptools.BoolDefault(module.sdkLibraryProperties.Contribute_to_android_api, false)
|
return proptools.BoolDefault(module.sdkLibraryProperties.Build_from_text_stub, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the xml file that publicizes the runtime library
|
// Creates the xml file that publicizes the runtime library
|
||||||
@@ -2390,16 +2350,10 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont
|
|||||||
module.createStubsLibrary(mctx, scope)
|
module.createStubsLibrary(mctx, scope)
|
||||||
module.createExportableStubsLibrary(mctx, scope)
|
module.createExportableStubsLibrary(mctx, scope)
|
||||||
|
|
||||||
alternativeFullApiSurfaceStubLib := ""
|
if mctx.Config().BuildFromTextStub() && module.ModuleBuildFromTextStubs() {
|
||||||
if scope == apiScopePublic {
|
module.createApiLibrary(mctx, scope)
|
||||||
alternativeFullApiSurfaceStubLib = module.alternativeFullApiSurfaceStubLib()
|
|
||||||
}
|
}
|
||||||
contributesToApiSurface := module.contributesToApiSurface(mctx.Config()) || alternativeFullApiSurfaceStubLib != ""
|
module.createTopLevelStubsLibrary(mctx, scope)
|
||||||
if contributesToApiSurface {
|
|
||||||
module.createApiLibrary(mctx, scope, alternativeFullApiSurfaceStubLib)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.createTopLevelStubsLibrary(mctx, scope, contributesToApiSurface)
|
|
||||||
module.createTopLevelExportableStubsLibrary(mctx, scope)
|
module.createTopLevelExportableStubsLibrary(mctx, scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,9 +35,6 @@ func TestJavaSdkLibrary(t *testing.T) {
|
|||||||
"29": {"foo"},
|
"29": {"foo"},
|
||||||
"30": {"bar", "barney", "baz", "betty", "foo", "fred", "quuz", "wilma"},
|
"30": {"bar", "barney", "baz", "betty", "foo", "fred", "quuz", "wilma"},
|
||||||
}),
|
}),
|
||||||
android.FixtureModifyConfig(func(config android.Config) {
|
|
||||||
config.SetApiLibraries([]string{"foo"})
|
|
||||||
}),
|
|
||||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
variables.BuildFlags = map[string]string{
|
variables.BuildFlags = map[string]string{
|
||||||
"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
|
"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
|
||||||
@@ -1588,9 +1585,6 @@ func TestJavaSdkLibrary_ApiLibrary(t *testing.T) {
|
|||||||
prepareForJavaTest,
|
prepareForJavaTest,
|
||||||
PrepareForTestWithJavaSdkLibraryFiles,
|
PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
FixtureWithLastReleaseApis("foo"),
|
FixtureWithLastReleaseApis("foo"),
|
||||||
android.FixtureModifyConfig(func(config android.Config) {
|
|
||||||
config.SetApiLibraries([]string{"foo"})
|
|
||||||
}),
|
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
java_sdk_library {
|
java_sdk_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -1609,36 +1603,30 @@ func TestJavaSdkLibrary_ApiLibrary(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
scope *apiScope
|
scope *apiScope
|
||||||
apiContributions []string
|
apiContributions []string
|
||||||
fullApiSurfaceStub string
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
scope: apiScopePublic,
|
scope: apiScopePublic,
|
||||||
apiContributions: []string{"foo.stubs.source.api.contribution"},
|
apiContributions: []string{"foo.stubs.source.api.contribution"},
|
||||||
fullApiSurfaceStub: "android_stubs_current",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scope: apiScopeSystem,
|
scope: apiScopeSystem,
|
||||||
apiContributions: []string{"foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
|
apiContributions: []string{"foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
|
||||||
fullApiSurfaceStub: "android_system_stubs_current",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scope: apiScopeTest,
|
scope: apiScopeTest,
|
||||||
apiContributions: []string{"foo.stubs.source.test.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
|
apiContributions: []string{"foo.stubs.source.test.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
|
||||||
fullApiSurfaceStub: "android_test_stubs_current",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scope: apiScopeModuleLib,
|
scope: apiScopeModuleLib,
|
||||||
apiContributions: []string{"foo.stubs.source.module_lib.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
|
apiContributions: []string{"foo.stubs.source.module_lib.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
|
||||||
fullApiSurfaceStub: "android_module_lib_stubs_current_full.from-text",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range testCases {
|
for _, c := range testCases {
|
||||||
m := result.ModuleForTests(c.scope.apiLibraryModuleName("foo"), "android_common").Module().(*ApiLibrary)
|
m := result.ModuleForTests(c.scope.apiLibraryModuleName("foo"), "android_common").Module().(*ApiLibrary)
|
||||||
android.AssertArrayString(t, "Module expected to contain api contributions", c.apiContributions, m.properties.Api_contributions)
|
android.AssertArrayString(t, "Module expected to contain api contributions", c.apiContributions, m.properties.Api_contributions)
|
||||||
android.AssertStringEquals(t, "Module expected to contain full api surface api library", c.fullApiSurfaceStub, *m.properties.Full_api_surface_stub)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1708,9 +1696,6 @@ func TestSdkLibraryExportableStubsLibrary(t *testing.T) {
|
|||||||
prepareForJavaTest,
|
prepareForJavaTest,
|
||||||
PrepareForTestWithJavaSdkLibraryFiles,
|
PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
FixtureWithLastReleaseApis("foo"),
|
FixtureWithLastReleaseApis("foo"),
|
||||||
android.FixtureModifyConfig(func(config android.Config) {
|
|
||||||
config.SetApiLibraries([]string{"foo"})
|
|
||||||
}),
|
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
aconfig_declarations {
|
aconfig_declarations {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
|
@@ -486,21 +486,17 @@ func gatherRequiredDepsForTest() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extraApiLibraryModules := map[string]droidstubsStruct{
|
extraApiLibraryModules := map[string]droidstubsStruct{
|
||||||
"android_stubs_current.from-text": publicDroidstubs,
|
"android_stubs_current.from-text": publicDroidstubs,
|
||||||
"android_system_stubs_current.from-text": systemDroidstubs,
|
"android_system_stubs_current.from-text": systemDroidstubs,
|
||||||
"android_test_stubs_current.from-text": testDroidstubs,
|
"android_test_stubs_current.from-text": testDroidstubs,
|
||||||
"android_module_lib_stubs_current.from-text": moduleLibDroidstubs,
|
"android_module_lib_stubs_current.from-text": moduleLibDroidstubs,
|
||||||
"android_module_lib_stubs_current_full.from-text": moduleLibDroidstubs,
|
"android_module_lib_stubs_current_full.from-text": moduleLibDroidstubs,
|
||||||
"android_system_server_stubs_current.from-text": systemServerDroidstubs,
|
"android_system_server_stubs_current.from-text": systemServerDroidstubs,
|
||||||
"core.current.stubs.from-text": publicDroidstubs,
|
"core.current.stubs.from-text": publicDroidstubs,
|
||||||
"legacy.core.platform.api.stubs.from-text": publicDroidstubs,
|
"legacy.core.platform.api.stubs.from-text": publicDroidstubs,
|
||||||
"stable.core.platform.api.stubs.from-text": publicDroidstubs,
|
"stable.core.platform.api.stubs.from-text": publicDroidstubs,
|
||||||
"core-lambda-stubs.from-text": publicDroidstubs,
|
"core-lambda-stubs.from-text": publicDroidstubs,
|
||||||
"android-non-updatable.stubs.from-text": publicDroidstubs,
|
"android-non-updatable.stubs.test_module_lib": moduleLibDroidstubs,
|
||||||
"android-non-updatable.stubs.system.from-text": systemDroidstubs,
|
|
||||||
"android-non-updatable.stubs.test.from-text": testDroidstubs,
|
|
||||||
"android-non-updatable.stubs.module_lib.from-text": moduleLibDroidstubs,
|
|
||||||
"android-non-updatable.stubs.test_module_lib": moduleLibDroidstubs,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, droidstubs := range droidstubsStructs {
|
for _, droidstubs := range droidstubsStructs {
|
||||||
@@ -529,6 +525,8 @@ func gatherRequiredDepsForTest() string {
|
|||||||
name: "%s",
|
name: "%s",
|
||||||
api_contributions: ["%s"],
|
api_contributions: ["%s"],
|
||||||
stubs_type: "everything",
|
stubs_type: "everything",
|
||||||
|
sdk_version: "none",
|
||||||
|
system_modules: "none",
|
||||||
}
|
}
|
||||||
`, libName, droidstubs.name+".api.contribution")
|
`, libName, droidstubs.name+".api.contribution")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user