Merge "Soong: support Errorprone javacflags"
This commit is contained in:
commit
fdc2b3bebe
4 changed files with 38 additions and 0 deletions
|
@ -128,6 +128,7 @@ func init() {
|
||||||
|
|
||||||
"LOCAL_JAVA_RESOURCE_DIRS": "java_resource_dirs",
|
"LOCAL_JAVA_RESOURCE_DIRS": "java_resource_dirs",
|
||||||
"LOCAL_JAVACFLAGS": "javacflags",
|
"LOCAL_JAVACFLAGS": "javacflags",
|
||||||
|
"LOCAL_ERROR_PRONE_FLAGS": "errorprone.javacflags",
|
||||||
"LOCAL_DX_FLAGS": "dxflags",
|
"LOCAL_DX_FLAGS": "dxflags",
|
||||||
"LOCAL_JAVA_LIBRARIES": "libs",
|
"LOCAL_JAVA_LIBRARIES": "libs",
|
||||||
"LOCAL_STATIC_JAVA_LIBRARIES": "static_libs",
|
"LOCAL_STATIC_JAVA_LIBRARIES": "static_libs",
|
||||||
|
|
|
@ -474,6 +474,24 @@ include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "errorprone options for java library",
|
||||||
|
in: `
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_ERROR_PRONE_FLAGS := -Xep:AsyncCallableReturnsNull:ERROR -Xep:AsyncFunctionReturnsNull:ERROR
|
||||||
|
include $(BUILD_JAVA_LIBRARY)
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
java_library {
|
||||||
|
errorprone: {
|
||||||
|
javacflags: [
|
||||||
|
"-Xep:AsyncCallableReturnsNull:ERROR",
|
||||||
|
"-Xep:AsyncFunctionReturnsNull:ERROR",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func reformatBlueprint(input string) string {
|
func reformatBlueprint(input string) string {
|
||||||
|
|
|
@ -155,6 +155,8 @@ type javaBuilderFlags struct {
|
||||||
aidlFlags string
|
aidlFlags string
|
||||||
javaVersion string
|
javaVersion string
|
||||||
|
|
||||||
|
errorProneExtraJavacFlags string
|
||||||
|
|
||||||
kotlincFlags string
|
kotlincFlags string
|
||||||
kotlincClasspath classpath
|
kotlincClasspath classpath
|
||||||
|
|
||||||
|
@ -210,6 +212,14 @@ func RunErrorProne(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
ctx.ModuleErrorf("cannot build with Error Prone, missing external/error_prone?")
|
ctx.ModuleErrorf("cannot build with Error Prone, missing external/error_prone?")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(flags.errorProneExtraJavacFlags) > 0 {
|
||||||
|
if len(flags.javacFlags) > 0 {
|
||||||
|
flags.javacFlags = flags.errorProneExtraJavacFlags + " " + flags.javacFlags
|
||||||
|
} else {
|
||||||
|
flags.javacFlags = flags.errorProneExtraJavacFlags
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
transformJavaToClasses(ctx, outputFile, -1, srcFiles, srcJars, flags, nil,
|
transformJavaToClasses(ctx, outputFile, -1, srcFiles, srcJars, flags, nil,
|
||||||
"errorprone", "errorprone", errorprone)
|
"errorprone", "errorprone", errorprone)
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,11 @@ type CompilerProperties struct {
|
||||||
Exclude_filter []string
|
Exclude_filter []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Errorprone struct {
|
||||||
|
// List of javac flags that should only be used when running errorprone.
|
||||||
|
Javacflags []string
|
||||||
|
}
|
||||||
|
|
||||||
Proto struct {
|
Proto struct {
|
||||||
// List of extra options that will be passed to the proto generator.
|
// List of extra options that will be passed to the proto generator.
|
||||||
Output_params []string
|
Output_params []string
|
||||||
|
@ -646,6 +651,10 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
||||||
flags.javacFlags = "$javacFlags"
|
flags.javacFlags = "$javacFlags"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(j.properties.Errorprone.Javacflags) > 0 {
|
||||||
|
flags.errorProneExtraJavacFlags = strings.Join(j.properties.Errorprone.Javacflags, " ")
|
||||||
|
}
|
||||||
|
|
||||||
// javaVersion flag.
|
// javaVersion flag.
|
||||||
sdk := sdkStringToNumber(ctx, String(j.deviceProperties.Sdk_version))
|
sdk := sdkStringToNumber(ctx, String(j.deviceProperties.Sdk_version))
|
||||||
if j.properties.Java_version != nil {
|
if j.properties.Java_version != nil {
|
||||||
|
|
Loading…
Reference in a new issue