summaryrefslogtreecommitdiff
path: root/java/base.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/base.go')
-rw-r--r--java/base.go76
1 files changed, 21 insertions, 55 deletions
diff --git a/java/base.go b/java/base.go
index ef299b279..32bfc17f9 100644
--- a/java/base.go
+++ b/java/base.go
@@ -83,9 +83,6 @@ type CommonProperties struct {
// list of java libraries that will be compiled into the resulting jar
Static_libs proptools.Configurable[[]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"`
@@ -535,7 +532,8 @@ type Module struct {
linter
// list of the xref extraction files
- kytheFiles android.Paths
+ kytheFiles android.Paths
+ kytheKotlinFiles android.Paths
hideApexVariantFromMake bool
@@ -707,9 +705,6 @@ func setOutputFiles(ctx android.ModuleContext, m Module) {
ctx.SetOutputFiles(android.Paths{m.dexer.proguardDictionary.Path()}, ".proguard_map")
}
ctx.SetOutputFiles(m.properties.Generated_srcjars, ".generated_srcjars")
- if m.linter.outputs.xml != nil {
- ctx.SetOutputFiles(android.Paths{m.linter.outputs.xml}, ".lint")
- }
}
func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
@@ -829,7 +824,7 @@ func (j *Module) AvailableFor(what string) bool {
}
func (j *Module) staticLibs(ctx android.BaseModuleContext) []string {
- return android.RemoveListFromList(j.properties.Static_libs.GetOrDefault(ctx, nil), j.properties.Exclude_static_libs)
+ return j.properties.Static_libs.GetOrDefault(ctx, nil)
}
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
@@ -853,33 +848,6 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
// Add dependency on libraries that provide additional hidden api annotations.
ctx.AddVariationDependencies(nil, hiddenApiAnnotationsTag, j.properties.Hiddenapi_additional_annotations...)
- if ctx.Config().EnforceInterPartitionJavaSdkLibrary() {
- // Require java_sdk_library at inter-partition java dependency to ensure stable
- // interface between partitions. If inter-partition java_library dependency is detected,
- // raise build error because java_library doesn't have a stable interface.
- //
- // Inputs:
- // PRODUCT_ENFORCE_INTER_PARTITION_JAVA_SDK_LIBRARY
- // if true, enable enforcement
- // PRODUCT_INTER_PARTITION_JAVA_LIBRARY_ALLOWLIST
- // exception list of java_library names to allow inter-partition dependency
- for idx := range j.properties.Libs {
- if libDeps[idx] == nil {
- continue
- }
-
- if javaDep, ok := libDeps[idx].(javaSdkLibraryEnforceContext); ok {
- // java_sdk_library is always allowed at inter-partition dependency.
- // So, skip check.
- if _, ok := javaDep.(*SdkLibrary); ok {
- continue
- }
-
- j.checkPartitionsForJavaDependency(ctx, "libs", javaDep)
- }
- }
- }
-
// For library dependencies that are component libraries (like stubs), add the implementation
// as a dependency (dexpreopt needs to be against the implementation library, not stubs).
for _, dep := range libDeps {
@@ -1370,7 +1338,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
kotlinJar := android.PathForModuleOut(ctx, "kotlin", jarName)
kotlinHeaderJar := android.PathForModuleOut(ctx, "kotlin_headers", jarName)
- kotlinCompile(ctx, kotlinJar, kotlinHeaderJar, uniqueSrcFiles, kotlinCommonSrcFiles, srcJars, flags)
+ j.kotlinCompile(ctx, kotlinJar, kotlinHeaderJar, uniqueSrcFiles, kotlinCommonSrcFiles, srcJars, flags)
if ctx.Failed() {
return
}
@@ -1735,8 +1703,12 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
return
}
+ completeStaticLibsImplementationJarsToCombine := completeStaticLibsImplementationJars
+
if j.shouldInstrument(ctx) {
- outputFile = j.instrument(ctx, flags, outputFile, jarName, specs)
+ instrumentedOutputFile := j.instrument(ctx, flags, outputFile, jarName, specs)
+ completeStaticLibsImplementationJarsToCombine = android.NewDepSet(android.PREORDER, android.Paths{instrumentedOutputFile}, nil)
+ outputFile = instrumentedOutputFile
}
// merge implementation jar with resources if necessary
@@ -1744,7 +1716,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
if ctx.Config().UseTransitiveJarsInClasspath() {
resourceJars := completeStaticLibsResourceJars.ToList()
if len(resourceJars) > 0 {
- implementationAndResourcesJarsToCombine = append(resourceJars, completeStaticLibsImplementationJars.ToList()...)
+ implementationAndResourcesJarsToCombine = append(resourceJars, completeStaticLibsImplementationJarsToCombine.ToList()...)
implementationAndResourcesJarsToCombine = append(implementationAndResourcesJarsToCombine, extraDepCombinedJars...)
}
} else {
@@ -1789,14 +1761,14 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
classesJar: outputFile,
jarName: jarName,
}
- if j.GetProfileGuided() && j.optimizeOrObfuscateEnabled() && !j.EnableProfileRewriting() {
+ if j.GetProfileGuided(ctx) && j.optimizeOrObfuscateEnabled() && !j.EnableProfileRewriting(ctx) {
ctx.PropertyErrorf("enable_profile_rewriting",
"Enable_profile_rewriting must be true when profile_guided dexpreopt and R8 optimization/obfuscation is turned on. The attached profile should be sourced from an unoptimized/unobfuscated APK.",
)
}
- if j.EnableProfileRewriting() {
- profile := j.GetProfile()
- if profile == "" || !j.GetProfileGuided() {
+ if j.EnableProfileRewriting(ctx) {
+ profile := j.GetProfile(ctx)
+ if profile == "" || !j.GetProfileGuided(ctx) {
ctx.PropertyErrorf("enable_profile_rewriting", "Profile and Profile_guided must be set when enable_profile_rewriting is true")
}
params.artProfileInput = &profile
@@ -2413,18 +2385,12 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
return
}
- if dep, ok := module.(SdkLibraryDependency); ok {
+ if sdkInfo, ok := android.OtherModuleProvider(ctx, module, SdkLibraryInfoProvider); ok {
switch tag {
- case sdkLibTag, libTag:
- depHeaderJars := dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))
- deps.classpath = append(deps.classpath, depHeaderJars...)
- deps.dexClasspath = append(deps.dexClasspath, depHeaderJars...)
-
- // TODO: SDK libraries should export a provider with TransitiveClasspathHeaderJars
- depHeaderJarsSet := android.NewDepSet(android.PREORDER, depHeaderJars, nil)
- transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, depHeaderJarsSet)
- case staticLibTag:
- ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
+ case sdkLibTag, libTag, staticLibTag:
+ generatingLibsString := android.PrettyConcat(
+ getGeneratingLibs(ctx, j.SdkVersion(ctx), module.Name(), sdkInfo), true, "or")
+ ctx.ModuleErrorf("cannot depend directly on java_sdk_library %q; try depending on %s instead", module.Name(), generatingLibsString)
}
} else if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
if sdkLinkType != javaPlatform {
@@ -2730,7 +2696,7 @@ func collectDirectDepsProviders(ctx android.ModuleContext) (result *JarJarProvid
module := ctx.Module()
moduleName := module.Name()
- ctx.VisitDirectDepsIgnoreBlueprint(func(m android.Module) {
+ ctx.VisitDirectDeps(func(m android.Module) {
tag := ctx.OtherModuleDependencyTag(m)
// This logic mirrors that in (*Module).collectDeps above. There are several places
// where we explicitly return RenameUseExclude, even though it is the default, to
@@ -2753,7 +2719,7 @@ func collectDirectDepsProviders(ctx android.ModuleContext) (result *JarJarProvid
if IsJniDepTag(tag) || tag == certificateTag || tag == proguardRaiseTag {
return RenameUseExclude, "tags"
}
- if _, ok := m.(SdkLibraryDependency); ok {
+ if _, ok := android.OtherModuleProvider(ctx, m, SdkLibraryInfoProvider); ok {
switch tag {
case sdkLibTag, libTag:
return RenameUseExclude, "sdklibdep" // matches collectDeps()