Merge changes I25c77994,I7da78ef4,I89197d0a am: 181c2a40d8
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1344320 Change-Id: Id4c51df28d8fb4493d68dbb420eaca67455e258d
This commit is contained in:
14
java/java.go
14
java/java.go
@@ -253,6 +253,9 @@ type CompilerProperties struct {
|
|||||||
|
|
||||||
// List of files to include in the META-INF/services folder of the resulting jar.
|
// List of files to include in the META-INF/services folder of the resulting jar.
|
||||||
Services []string `android:"path,arch_variant"`
|
Services []string `android:"path,arch_variant"`
|
||||||
|
|
||||||
|
// If true, package the kotlin stdlib into the jar. Defaults to true.
|
||||||
|
Static_kotlin_stdlib *bool `android:"arch_variant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CompilerDeviceProperties struct {
|
type CompilerDeviceProperties struct {
|
||||||
@@ -576,6 +579,7 @@ var (
|
|||||||
certificateTag = dependencyTag{name: "certificate"}
|
certificateTag = dependencyTag{name: "certificate"}
|
||||||
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
|
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
|
||||||
usesLibTag = dependencyTag{name: "uses-library"}
|
usesLibTag = dependencyTag{name: "uses-library"}
|
||||||
|
extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
|
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
|
||||||
@@ -687,6 +691,8 @@ func (j *Module) AvailableFor(what string) bool {
|
|||||||
|
|
||||||
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
|
j.linter.deps(ctx)
|
||||||
|
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||||
if sdkDep.useDefaultLibs {
|
if sdkDep.useDefaultLibs {
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||||
@@ -1350,8 +1356,10 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
if len(flags.processorPath) > 0 {
|
if len(flags.processorPath) > 0 {
|
||||||
// Use kapt for annotation processing
|
// Use kapt for annotation processing
|
||||||
kaptSrcJar := android.PathForModuleOut(ctx, "kapt", "kapt-sources.jar")
|
kaptSrcJar := android.PathForModuleOut(ctx, "kapt", "kapt-sources.jar")
|
||||||
kotlinKapt(ctx, kaptSrcJar, kotlinSrcFiles, srcJars, flags)
|
kaptResJar := android.PathForModuleOut(ctx, "kapt", "kapt-res.jar")
|
||||||
|
kotlinKapt(ctx, kaptSrcJar, kaptResJar, kotlinSrcFiles, srcJars, flags)
|
||||||
srcJars = append(srcJars, kaptSrcJar)
|
srcJars = append(srcJars, kaptSrcJar)
|
||||||
|
kotlinJars = append(kotlinJars, kaptResJar)
|
||||||
// Disable annotation processing in javac, it's already been handled by kapt
|
// Disable annotation processing in javac, it's already been handled by kapt
|
||||||
flags.processorPath = nil
|
flags.processorPath = nil
|
||||||
flags.processors = nil
|
flags.processors = nil
|
||||||
@@ -1366,10 +1374,12 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
// Make javac rule depend on the kotlinc rule
|
// Make javac rule depend on the kotlinc rule
|
||||||
flags.classpath = append(flags.classpath, kotlinJar)
|
flags.classpath = append(flags.classpath, kotlinJar)
|
||||||
|
|
||||||
// Jar kotlin classes into the final jar after javac
|
|
||||||
kotlinJars = append(kotlinJars, kotlinJar)
|
kotlinJars = append(kotlinJars, kotlinJar)
|
||||||
|
// Jar kotlin classes into the final jar after javac
|
||||||
|
if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
|
||||||
kotlinJars = append(kotlinJars, deps.kotlinStdlib...)
|
kotlinJars = append(kotlinJars, deps.kotlinStdlib...)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jars := append(android.Paths(nil), kotlinJars...)
|
jars := append(android.Paths(nil), kotlinJars...)
|
||||||
|
|
||||||
|
@@ -90,7 +90,8 @@ func kotlinCompile(ctx android.ModuleContext, outputFile android.WritablePath,
|
|||||||
|
|
||||||
var kapt = pctx.AndroidRemoteStaticRule("kapt", android.RemoteRuleSupports{Goma: true},
|
var kapt = pctx.AndroidRemoteStaticRule("kapt", android.RemoteRuleSupports{Goma: true},
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `rm -rf "$srcJarDir" "$kotlinBuildFile" "$kaptDir" && mkdir -p "$srcJarDir" "$kaptDir" && ` +
|
Command: `rm -rf "$srcJarDir" "$kotlinBuildFile" "$kaptDir" && ` +
|
||||||
|
`mkdir -p "$srcJarDir" "$kaptDir/sources" "$kaptDir/classes" && ` +
|
||||||
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
||||||
`${config.GenKotlinBuildFileCmd} $classpath "$name" "" $out.rsp $srcJarDir/list > $kotlinBuildFile &&` +
|
`${config.GenKotlinBuildFileCmd} $classpath "$name" "" $out.rsp $srcJarDir/list > $kotlinBuildFile &&` +
|
||||||
`${config.KotlincCmd} ${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} $kotlincFlags ` +
|
`${config.KotlincCmd} ${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} $kotlincFlags ` +
|
||||||
@@ -105,6 +106,7 @@ var kapt = pctx.AndroidRemoteStaticRule("kapt", android.RemoteRuleSupports{Goma:
|
|||||||
`$kaptProcessor ` +
|
`$kaptProcessor ` +
|
||||||
`-Xbuild-file=$kotlinBuildFile && ` +
|
`-Xbuild-file=$kotlinBuildFile && ` +
|
||||||
`${config.SoongZipCmd} -jar -o $out -C $kaptDir/sources -D $kaptDir/sources && ` +
|
`${config.SoongZipCmd} -jar -o $out -C $kaptDir/sources -D $kaptDir/sources && ` +
|
||||||
|
`${config.SoongZipCmd} -jar -o $classesJarOut -C $kaptDir/classes -D $kaptDir/classes && ` +
|
||||||
`rm -rf "$srcJarDir"`,
|
`rm -rf "$srcJarDir"`,
|
||||||
CommandDeps: []string{
|
CommandDeps: []string{
|
||||||
"${config.KotlincCmd}",
|
"${config.KotlincCmd}",
|
||||||
@@ -118,13 +120,14 @@ var kapt = pctx.AndroidRemoteStaticRule("kapt", android.RemoteRuleSupports{Goma:
|
|||||||
RspfileContent: `$in`,
|
RspfileContent: `$in`,
|
||||||
},
|
},
|
||||||
"kotlincFlags", "encodedJavacFlags", "kaptProcessorPath", "kaptProcessor",
|
"kotlincFlags", "encodedJavacFlags", "kaptProcessorPath", "kaptProcessor",
|
||||||
"classpath", "srcJars", "srcJarDir", "kaptDir", "kotlinJvmTarget", "kotlinBuildFile", "name")
|
"classpath", "srcJars", "srcJarDir", "kaptDir", "kotlinJvmTarget", "kotlinBuildFile", "name",
|
||||||
|
"classesJarOut")
|
||||||
|
|
||||||
// kotlinKapt performs Kotlin-compatible annotation processing. It takes .kt and .java sources and srcjars, and runs
|
// kotlinKapt performs Kotlin-compatible annotation processing. It takes .kt and .java sources and srcjars, and runs
|
||||||
// annotation processors over all of them, producing a srcjar of generated code in outputFile. The srcjar should be
|
// annotation processors over all of them, producing a srcjar of generated code in outputFile. The srcjar should be
|
||||||
// added as an additional input to kotlinc and javac rules, and the javac rule should have annotation processing
|
// added as an additional input to kotlinc and javac rules, and the javac rule should have annotation processing
|
||||||
// disabled.
|
// disabled.
|
||||||
func kotlinKapt(ctx android.ModuleContext, outputFile android.WritablePath,
|
func kotlinKapt(ctx android.ModuleContext, srcJarOutputFile, resJarOutputFile android.WritablePath,
|
||||||
srcFiles, srcJars android.Paths,
|
srcFiles, srcJars android.Paths,
|
||||||
flags javaBuilderFlags) {
|
flags javaBuilderFlags) {
|
||||||
|
|
||||||
@@ -154,7 +157,8 @@ func kotlinKapt(ctx android.ModuleContext, outputFile android.WritablePath,
|
|||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: kapt,
|
Rule: kapt,
|
||||||
Description: "kapt",
|
Description: "kapt",
|
||||||
Output: outputFile,
|
Output: srcJarOutputFile,
|
||||||
|
ImplicitOutput: resJarOutputFile,
|
||||||
Inputs: srcFiles,
|
Inputs: srcFiles,
|
||||||
Implicits: deps,
|
Implicits: deps,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
@@ -168,6 +172,7 @@ func kotlinKapt(ctx android.ModuleContext, outputFile android.WritablePath,
|
|||||||
"kaptDir": android.PathForModuleOut(ctx, "kapt/gen").String(),
|
"kaptDir": android.PathForModuleOut(ctx, "kapt/gen").String(),
|
||||||
"encodedJavacFlags": encodedJavacFlags,
|
"encodedJavacFlags": encodedJavacFlags,
|
||||||
"name": kotlinName,
|
"name": kotlinName,
|
||||||
|
"classesJarOut": resJarOutputFile.String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
21
java/lint.go
21
java/lint.go
@@ -42,6 +42,9 @@ type LintProperties struct {
|
|||||||
|
|
||||||
// Checks that should be skipped.
|
// Checks that should be skipped.
|
||||||
Disabled_checks []string
|
Disabled_checks []string
|
||||||
|
|
||||||
|
// Modules that provide extra lint checks
|
||||||
|
Extra_check_modules []string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +79,14 @@ func (l *linter) enabled() bool {
|
|||||||
return BoolDefault(l.properties.Lint.Enabled, true)
|
return BoolDefault(l.properties.Lint.Enabled, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *linter) deps(ctx android.BottomUpMutatorContext) {
|
||||||
|
if !l.enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), extraLintCheckTag, l.properties.Lint.Extra_check_modules...)
|
||||||
|
}
|
||||||
|
|
||||||
func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
|
func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
|
||||||
rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir android.WritablePath, deps android.Paths) {
|
rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir android.WritablePath, deps android.Paths) {
|
||||||
|
|
||||||
@@ -179,6 +190,16 @@ func (l *linter) lint(ctx android.ModuleContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag)
|
||||||
|
for _, extraLintCheckModule := range extraLintCheckModules {
|
||||||
|
if dep, ok := extraLintCheckModule.(Dependency); ok {
|
||||||
|
l.extraLintCheckJars = append(l.extraLintCheckJars, dep.ImplementationAndResourcesJars()...)
|
||||||
|
} else {
|
||||||
|
ctx.PropertyErrorf("lint.extra_check_modules",
|
||||||
|
"%s is not a java module", ctx.OtherModuleName(extraLintCheckModule))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rule := android.NewRuleBuilder()
|
rule := android.NewRuleBuilder()
|
||||||
|
|
||||||
if l.manifest == nil {
|
if l.manifest == nil {
|
||||||
|
Reference in New Issue
Block a user