Merge "Revert "Revert "Make Metalava checkapi a seperate run."""
This commit is contained in:
122
java/droiddoc.go
122
java/droiddoc.go
@@ -88,6 +88,24 @@ var (
|
|||||||
},
|
},
|
||||||
"outDir", "srcJarDir", "stubsDir", "docStubsDir", "srcJars", "javaVersion", "bootclasspathArgs",
|
"outDir", "srcJarDir", "stubsDir", "docStubsDir", "srcJars", "javaVersion", "bootclasspathArgs",
|
||||||
"classpathArgs", "sourcepath", "opts", "docZip")
|
"classpathArgs", "sourcepath", "opts", "docZip")
|
||||||
|
|
||||||
|
metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck",
|
||||||
|
blueprint.RuleParams{
|
||||||
|
Command: `( rm -rf "$srcJarDir" && mkdir -p "$srcJarDir" && ` +
|
||||||
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
||||||
|
`${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` +
|
||||||
|
`$bootclasspathArgs $classpathArgs -sourcepath $sourcepath --no-banner --color --quiet ` +
|
||||||
|
`$opts && touch $out ) || ` +
|
||||||
|
`( echo -e "$msg" ; exit 38 )`,
|
||||||
|
CommandDeps: []string{
|
||||||
|
"${config.ZipSyncCmd}",
|
||||||
|
"${config.JavaCmd}",
|
||||||
|
"${config.MetalavaJar}",
|
||||||
|
},
|
||||||
|
Rspfile: "$out.rsp",
|
||||||
|
RspfileContent: "$in",
|
||||||
|
},
|
||||||
|
"srcJarDir", "srcJars", "javaVersion", "bootclasspathArgs", "classpathArgs", "sourcepath", "opts", "msg")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -288,10 +306,9 @@ type droiddocBuilderFlags struct {
|
|||||||
doclavaDocsFlags string
|
doclavaDocsFlags string
|
||||||
postDoclavaCmds string
|
postDoclavaCmds string
|
||||||
|
|
||||||
metalavaStubsFlags string
|
metalavaStubsFlags string
|
||||||
metalavaAnnotationsFlags string
|
metalavaAnnotationsFlags string
|
||||||
metalavaJavadocFlags string
|
metalavaJavadocFlags string
|
||||||
metalavaCompatibilityCheckFlags string
|
|
||||||
|
|
||||||
metalavaDokkaFlags string
|
metalavaDokkaFlags string
|
||||||
}
|
}
|
||||||
@@ -1014,38 +1031,6 @@ func (d *Droiddoc) collectMetalavaDokkaFlags(ctx android.ModuleContext, implicit
|
|||||||
docStubsDir + " " + classpathArgs + " -format dac -dacRoot /reference/kotlin -output " + outDir
|
docStubsDir + " " + classpathArgs + " -format dac -dacRoot /reference/kotlin -output " + outDir
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Droiddoc) collectMetalavaCompatibilityCheckFlags(ctx android.ModuleContext,
|
|
||||||
implicits *android.Paths) string {
|
|
||||||
var flags string
|
|
||||||
if d.checkCurrentApi() && !ctx.Config().IsPdkBuild() {
|
|
||||||
apiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Api_file),
|
|
||||||
"check_api.current.api_file")
|
|
||||||
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file),
|
|
||||||
"check_api.current_removed_api_file")
|
|
||||||
|
|
||||||
*implicits = append(*implicits, apiFile)
|
|
||||||
*implicits = append(*implicits, removedApiFile)
|
|
||||||
|
|
||||||
flags = " --check-compatibility:api:current " + apiFile.String() +
|
|
||||||
" --check-compatibility:removed:current " + removedApiFile.String() + " "
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.checkLastReleasedApi() && !ctx.Config().IsPdkBuild() {
|
|
||||||
apiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file),
|
|
||||||
"check_api.last_released.api_file")
|
|
||||||
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file),
|
|
||||||
"check_api.last_released.removed_api_file")
|
|
||||||
|
|
||||||
*implicits = append(*implicits, apiFile)
|
|
||||||
*implicits = append(*implicits, removedApiFile)
|
|
||||||
|
|
||||||
flags = flags + " --check-compatibility:api:released " + apiFile.String() +
|
|
||||||
" --check-compatibility:removed:released " + removedApiFile.String() + " "
|
|
||||||
}
|
|
||||||
|
|
||||||
return flags
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *Droiddoc) transformMetalava(ctx android.ModuleContext, implicits android.Paths,
|
func (d *Droiddoc) transformMetalava(ctx android.ModuleContext, implicits android.Paths,
|
||||||
implicitOutputs android.WritablePaths, outDir, docStubsDir, javaVersion,
|
implicitOutputs android.WritablePaths, outDir, docStubsDir, javaVersion,
|
||||||
bootclasspathArgs, classpathArgs, opts string) {
|
bootclasspathArgs, classpathArgs, opts string) {
|
||||||
@@ -1117,6 +1102,29 @@ func (d *Droiddoc) transformCheckApi(ctx android.ModuleContext, apiFile, removed
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Droiddoc) transformMetalavaCheckApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path,
|
||||||
|
implicits android.Paths, javaVersion, bootclasspathArgs, classpathArgs, opts, msg string,
|
||||||
|
output android.WritablePath) {
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: metalavaApiCheck,
|
||||||
|
Description: "Metalava Check API",
|
||||||
|
Output: output,
|
||||||
|
Inputs: d.Javadoc.srcFiles,
|
||||||
|
Implicits: append(android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile},
|
||||||
|
implicits...),
|
||||||
|
Args: map[string]string{
|
||||||
|
"srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
|
||||||
|
"srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
|
||||||
|
"javaVersion": javaVersion,
|
||||||
|
"bootclasspathArgs": bootclasspathArgs,
|
||||||
|
"classpathArgs": classpathArgs,
|
||||||
|
"sourcepath": strings.Join(d.Javadoc.sourcepaths.Strings(), ":"),
|
||||||
|
"opts": opts,
|
||||||
|
"msg": msg,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Droiddoc) transformUpdateApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path,
|
func (d *Droiddoc) transformUpdateApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path,
|
||||||
output android.WritablePath) {
|
output android.WritablePath) {
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
@@ -1152,6 +1160,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flags, err := d.initBuilderFlags(ctx, &implicits, deps)
|
flags, err := d.initBuilderFlags(ctx, &implicits, deps)
|
||||||
|
metalavaCheckApiImplicits := implicits
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1159,7 +1168,6 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
flags.doclavaStubsFlags, flags.metalavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs)
|
flags.doclavaStubsFlags, flags.metalavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs)
|
||||||
if Bool(d.properties.Metalava_enabled) {
|
if Bool(d.properties.Metalava_enabled) {
|
||||||
flags.metalavaAnnotationsFlags = d.collectMetalavaAnnotationsFlags(ctx, &implicits, &implicitOutputs)
|
flags.metalavaAnnotationsFlags = d.collectMetalavaAnnotationsFlags(ctx, &implicits, &implicitOutputs)
|
||||||
flags.metalavaCompatibilityCheckFlags = d.collectMetalavaCompatibilityCheckFlags(ctx, &implicits)
|
|
||||||
outDir := android.PathForModuleOut(ctx, "out").String()
|
outDir := android.PathForModuleOut(ctx, "out").String()
|
||||||
docStubsDir := android.PathForModuleOut(ctx, "docStubsDir").String()
|
docStubsDir := android.PathForModuleOut(ctx, "docStubsDir").String()
|
||||||
// TODO(nanzhang): Add a Soong property to handle documentation args.
|
// TODO(nanzhang): Add a Soong property to handle documentation args.
|
||||||
@@ -1169,7 +1177,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
flags.dokkaClasspathArgs, outDir, docStubsDir)
|
flags.dokkaClasspathArgs, outDir, docStubsDir)
|
||||||
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
||||||
flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+
|
flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+
|
||||||
flags.metalavaAnnotationsFlags+" "+flags.metalavaCompatibilityCheckFlags+" "+
|
flags.metalavaAnnotationsFlags+" "+
|
||||||
strings.Split(flags.args, "--generate-documentation")[0]+
|
strings.Split(flags.args, "--generate-documentation")[0]+
|
||||||
flags.metalavaDokkaFlags+" "+strings.Split(flags.args, "--generate-documentation")[1])
|
flags.metalavaDokkaFlags+" "+strings.Split(flags.args, "--generate-documentation")[1])
|
||||||
} else {
|
} else {
|
||||||
@@ -1178,7 +1186,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
|
flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
|
||||||
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
||||||
flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+
|
flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+
|
||||||
flags.metalavaAnnotationsFlags+" "+flags.metalavaCompatibilityCheckFlags+" "+
|
flags.metalavaAnnotationsFlags+" "+
|
||||||
strings.Split(flags.args, "--generate-documentation")[0]+
|
strings.Split(flags.args, "--generate-documentation")[0]+
|
||||||
flags.metalavaJavadocFlags+flags.doclavaDocsFlags+
|
flags.metalavaJavadocFlags+flags.doclavaDocsFlags+
|
||||||
" "+strings.Split(flags.args, "--generate-documentation")[1])
|
" "+strings.Split(flags.args, "--generate-documentation")[1])
|
||||||
@@ -1186,8 +1194,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
} else {
|
} else {
|
||||||
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
||||||
flags.bootClasspathArgs, flags.classpathArgs,
|
flags.bootClasspathArgs, flags.classpathArgs,
|
||||||
flags.metalavaStubsFlags+flags.metalavaAnnotationsFlags+" "+
|
flags.metalavaStubsFlags+flags.metalavaAnnotationsFlags+" "+flags.args)
|
||||||
flags.metalavaCompatibilityCheckFlags+flags.args)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
|
flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
|
||||||
@@ -1203,8 +1210,8 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file),
|
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file),
|
||||||
"check_api.current_removed_api_file")
|
"check_api.current_removed_api_file")
|
||||||
|
|
||||||
|
d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
|
||||||
if !Bool(d.properties.Metalava_enabled) {
|
if !Bool(d.properties.Metalava_enabled) {
|
||||||
d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
|
|
||||||
d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath,
|
d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath,
|
||||||
fmt.Sprintf(`\n******************************\n`+
|
fmt.Sprintf(`\n******************************\n`+
|
||||||
`You have tried to change the API from what has been previously approved.\n\n`+
|
`You have tried to change the API from what has been previously approved.\n\n`+
|
||||||
@@ -1217,6 +1224,23 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
` you will need approval.\n`+
|
` you will need approval.\n`+
|
||||||
`******************************\n`, ctx.ModuleName()), String(d.properties.Check_api.Current.Args),
|
`******************************\n`, ctx.ModuleName()), String(d.properties.Check_api.Current.Args),
|
||||||
d.checkCurrentApiTimestamp)
|
d.checkCurrentApiTimestamp)
|
||||||
|
} else {
|
||||||
|
opts := flags.args + " --check-compatibility:api:current " + apiFile.String() +
|
||||||
|
" --check-compatibility:removed:current " + removedApiFile.String() + " "
|
||||||
|
|
||||||
|
d.transformMetalavaCheckApi(ctx, apiFile, removedApiFile, metalavaCheckApiImplicits,
|
||||||
|
javaVersion, flags.bootClasspathArgs, flags.classpathArgs, opts,
|
||||||
|
fmt.Sprintf(`\n******************************\n`+
|
||||||
|
`You have tried to change the API from what has been previously approved.\n\n`+
|
||||||
|
`To make these errors go away, you have two choices:\n`+
|
||||||
|
` 1. You can add '@hide' javadoc comments to the methods, etc. listed in the\n`+
|
||||||
|
` errors above.\n\n`+
|
||||||
|
` 2. You can update current.txt by executing the following command:\n`+
|
||||||
|
` make %s-update-current-api\n\n`+
|
||||||
|
` To submit the revised current.txt to the main Android repository,\n`+
|
||||||
|
` you will need approval.\n`+
|
||||||
|
`******************************\n`, ctx.ModuleName()),
|
||||||
|
d.checkCurrentApiTimestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
|
d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
|
||||||
@@ -1229,15 +1253,25 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file),
|
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file),
|
||||||
"check_api.last_released.removed_api_file")
|
"check_api.last_released.removed_api_file")
|
||||||
|
|
||||||
|
d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp")
|
||||||
if !Bool(d.properties.Metalava_enabled) {
|
if !Bool(d.properties.Metalava_enabled) {
|
||||||
d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp")
|
|
||||||
|
|
||||||
d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath,
|
d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath,
|
||||||
`\n******************************\n`+
|
`\n******************************\n`+
|
||||||
`You have tried to change the API from what has been previously released in\n`+
|
`You have tried to change the API from what has been previously released in\n`+
|
||||||
`an SDK. Please fix the errors listed above.\n`+
|
`an SDK. Please fix the errors listed above.\n`+
|
||||||
`******************************\n`, String(d.properties.Check_api.Last_released.Args),
|
`******************************\n`, String(d.properties.Check_api.Last_released.Args),
|
||||||
d.checkLastReleasedApiTimestamp)
|
d.checkLastReleasedApiTimestamp)
|
||||||
|
} else {
|
||||||
|
opts := flags.args + " --check-compatibility:api:released " + apiFile.String() +
|
||||||
|
" --check-compatibility:removed:released " + removedApiFile.String() + " "
|
||||||
|
|
||||||
|
d.transformMetalavaCheckApi(ctx, apiFile, removedApiFile, metalavaCheckApiImplicits,
|
||||||
|
javaVersion, flags.bootClasspathArgs, flags.classpathArgs, opts,
|
||||||
|
`\n******************************\n`+
|
||||||
|
`You have tried to change the API from what has been previously released in\n`+
|
||||||
|
`an SDK. Please fix the errors listed above.\n`+
|
||||||
|
`******************************\n`,
|
||||||
|
d.checkLastReleasedApiTimestamp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user