Add support for nullability validation to droidstubs.

This detects whether this is enabled, makes sure the other necessary
flag is set to provide a suitable location, and suppresses the
requirement for a previous_api.

Test: making a new libcore target using this
Bug: 73448108
Change-Id: Ifea3a060011a58e3288050c6c5d98b205abe25fc
This commit is contained in:
Pete Gillin 2018-09-14 14:25:48 +01:00
parent 1e30905f65
commit a262c05904
1 changed files with 16 additions and 8 deletions

View File

@ -1390,15 +1390,23 @@ func (d *Droidstubs) collectAnnotationsFlags(ctx android.ModuleContext,
implicits *android.Paths, implicitOutputs *android.WritablePaths) string {
var flags string
if Bool(d.properties.Annotations_enabled) {
if String(d.properties.Previous_api) == "" {
ctx.PropertyErrorf("metalava_previous_api",
"has to be non-empty if annotations was enabled!")
flags += " --include-annotations"
validatingNullability := strings.Contains(d.Javadoc.args, "--validate-nullability-from-merged-stubs")
migratingNullability := String(d.properties.Previous_api) != ""
if !(migratingNullability || validatingNullability) {
ctx.PropertyErrorf("previous_api",
"has to be non-empty if annotations was enabled (unless validating nullability)")
}
previousApi := ctx.ExpandSource(String(d.properties.Previous_api),
"metalava_previous_api")
if migratingNullability {
previousApi := ctx.ExpandSource(String(d.properties.Previous_api), "previous_api")
*implicits = append(*implicits, previousApi)
flags += " --include-annotations --migrate-nullness " + previousApi.String()
flags += " --migrate-nullness " + previousApi.String()
}
if validatingNullability {
nullabilityWarningsTxt := android.PathForModuleOut(ctx, ctx.ModuleName()+"_nullability_warnings.txt")
*implicitOutputs = append(*implicitOutputs, nullabilityWarningsTxt)
flags += " --nullability-warnings-txt " + nullabilityWarningsTxt.String()
}
d.annotationsZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"_annotations.zip")
*implicitOutputs = append(*implicitOutputs, d.annotationsZip)