Move kotlin stdlib to normal dependency tag
The kotlin standard library was added with a custom dependency tag, which then required special handling later. We know up front whether it will be treated the same as a static_libs or libs dependency, so just reuse staticLibTag or libTag, and remove all the special handling. Bug: 308016794 Test: TestKotlin Flag: exempt REFACTOR Change-Id: I2c5601faec284d88f28e13378d9cbffc24560efa
This commit is contained in:
31
java/base.go
31
java/base.go
@@ -875,9 +875,12 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||
if j.hasSrcExt(".kt") {
|
||||
// TODO(ccross): move this to a mutator pass that can tell if generated sources contain
|
||||
// Kotlin files
|
||||
ctx.AddVariationDependencies(nil, kotlinStdlibTag,
|
||||
"kotlin-stdlib", "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8")
|
||||
ctx.AddVariationDependencies(nil, kotlinAnnotationsTag, "kotlin-annotations")
|
||||
tag := staticLibTag
|
||||
if !BoolDefault(j.properties.Static_kotlin_stdlib, true) {
|
||||
tag = libTag
|
||||
}
|
||||
ctx.AddVariationDependencies(nil, tag,
|
||||
"kotlin-stdlib", "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8", "kotlin-annotations")
|
||||
}
|
||||
|
||||
// Framework libraries need special handling in static coverage builds: they should not have
|
||||
@@ -1211,7 +1214,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
|
||||
var kotlinJars android.Paths
|
||||
var kotlinHeaderJars android.Paths
|
||||
var kotlinExtraJars android.Paths
|
||||
|
||||
// Prepend extraClasspathJars to classpath so that the resource processor R.jar comes before
|
||||
// any dependencies so that it can override any non-final R classes from dependencies with the
|
||||
@@ -1290,9 +1292,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
// Collect common .kt files for AIDEGen
|
||||
j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, kotlinCommonSrcFiles.Strings()...)
|
||||
|
||||
flags.classpath = append(flags.classpath, deps.kotlinStdlib...)
|
||||
flags.classpath = append(flags.classpath, deps.kotlinAnnotations...)
|
||||
|
||||
flags.kotlincClasspath = append(flags.kotlincClasspath, flags.bootClasspath...)
|
||||
flags.kotlincClasspath = append(flags.kotlincClasspath, flags.classpath...)
|
||||
|
||||
@@ -1322,8 +1321,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
|
||||
kotlinJars = append(kotlinJars, kotlinJarPath)
|
||||
kotlinHeaderJars = append(kotlinHeaderJars, kotlinHeaderJar)
|
||||
kotlinExtraJars = append(kotlinExtraJars, deps.kotlinStdlib...)
|
||||
kotlinExtraJars = append(kotlinExtraJars, deps.kotlinAnnotations...)
|
||||
}
|
||||
|
||||
jars := slices.Clone(kotlinJars)
|
||||
@@ -1342,9 +1339,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
// with sharding enabled. See: b/77284273.
|
||||
}
|
||||
extraJars := slices.Clone(kotlinHeaderJars)
|
||||
if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
|
||||
extraJars = append(extraJars, kotlinExtraJars...)
|
||||
}
|
||||
extraJars = append(extraJars, extraCombinedJars...)
|
||||
var combinedHeaderJarFile android.Path
|
||||
headerJarFileWithoutDepsOrJarjar, combinedHeaderJarFile =
|
||||
@@ -1423,13 +1417,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
}
|
||||
}
|
||||
|
||||
// Jar kotlin classes into the final jar after javac
|
||||
if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
|
||||
jars = append(jars, kotlinExtraJars...)
|
||||
} else {
|
||||
flags.dexClasspath = append(flags.dexClasspath, kotlinExtraJars...)
|
||||
}
|
||||
|
||||
jars = append(jars, extraCombinedJars...)
|
||||
|
||||
j.srcJarArgs, j.srcJarDeps = resourcePathsToJarArgs(srcFiles), srcFiles
|
||||
@@ -2339,10 +2326,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||
} else {
|
||||
ctx.PropertyErrorf("exported_plugins", "%q is not a java_plugin module", otherName)
|
||||
}
|
||||
case kotlinStdlibTag:
|
||||
deps.kotlinStdlib = append(deps.kotlinStdlib, dep.HeaderJars...)
|
||||
case kotlinAnnotationsTag:
|
||||
deps.kotlinAnnotations = dep.HeaderJars
|
||||
case kotlinPluginTag:
|
||||
deps.kotlinPlugins = append(deps.kotlinPlugins, dep.ImplementationAndResourcesJars...)
|
||||
case syspropPublicStubDepTag:
|
||||
@@ -2566,8 +2549,6 @@ func collectDirectDepsProviders(ctx android.ModuleContext) (result *JarJarProvid
|
||||
return RenameUseInclude, "tagswitch"
|
||||
case exportedPluginTag:
|
||||
return RenameUseInclude, "tagswitch"
|
||||
case kotlinStdlibTag, kotlinAnnotationsTag:
|
||||
return RenameUseExclude, "tagswitch"
|
||||
case kotlinPluginTag:
|
||||
return RenameUseInclude, "tagswitch"
|
||||
default:
|
||||
|
Reference in New Issue
Block a user