Merge "Allow droidstubs to not generate any stubs" am: e03749b9ad
Change-Id: I709eb7a5eec97b5135ba502964d06b6c18bd6bfe
This commit is contained in:
@@ -545,10 +545,21 @@ func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
|
func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
|
// If the stubsSrcJar is not generated (because generate_stubs is false) then
|
||||||
|
// use the api file as the output file to ensure the relevant phony targets
|
||||||
|
// are created in make if only the api txt file is being generated. This is
|
||||||
|
// needed because an invalid output file would prevent the make entries from
|
||||||
|
// being written.
|
||||||
|
// TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
|
||||||
|
distFile := android.OptionalPathForPath(dstubs.apiFile)
|
||||||
|
outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
|
||||||
|
if !outputFile.Valid() {
|
||||||
|
outputFile = distFile
|
||||||
|
}
|
||||||
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
||||||
Class: "JAVA_LIBRARIES",
|
Class: "JAVA_LIBRARIES",
|
||||||
DistFile: android.OptionalPathForPath(dstubs.apiFile),
|
DistFile: distFile,
|
||||||
OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
|
OutputFile: outputFile,
|
||||||
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
|
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
|
||||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||||
func(entries *android.AndroidMkEntries) {
|
func(entries *android.AndroidMkEntries) {
|
||||||
|
@@ -301,6 +301,11 @@ type DroidstubsProperties struct {
|
|||||||
// if set to true, allow Metalava to generate doc_stubs source files. Defaults to false.
|
// if set to true, allow Metalava to generate doc_stubs source files. Defaults to false.
|
||||||
Create_doc_stubs *bool
|
Create_doc_stubs *bool
|
||||||
|
|
||||||
|
// if set to false then do not write out stubs. Defaults to true.
|
||||||
|
//
|
||||||
|
// TODO(b/146727827): Remove capability when we do not need to generate stubs and API separately.
|
||||||
|
Generate_stubs *bool
|
||||||
|
|
||||||
// is set to true, Metalava will allow framework SDK to contain API levels annotations.
|
// is set to true, Metalava will allow framework SDK to contain API levels annotations.
|
||||||
Api_levels_annotations_enabled *bool
|
Api_levels_annotations_enabled *bool
|
||||||
|
|
||||||
@@ -1285,7 +1290,7 @@ func (d *Droidstubs) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.WritablePath) {
|
func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath) {
|
||||||
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
|
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
|
||||||
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
|
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
|
||||||
String(d.properties.Api_filename) != "" {
|
String(d.properties.Api_filename) != "" {
|
||||||
@@ -1341,12 +1346,14 @@ func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuil
|
|||||||
cmd.FlagWithArg("--sdk-values ", d.metadataDir.String())
|
cmd.FlagWithArg("--sdk-values ", d.metadataDir.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if stubsDir.Valid() {
|
||||||
if Bool(d.properties.Create_doc_stubs) {
|
if Bool(d.properties.Create_doc_stubs) {
|
||||||
cmd.FlagWithArg("--doc-stubs ", stubsDir.String())
|
cmd.FlagWithArg("--doc-stubs ", stubsDir.String())
|
||||||
} else {
|
} else {
|
||||||
cmd.FlagWithArg("--stubs ", stubsDir.String())
|
cmd.FlagWithArg("--stubs ", stubsDir.String())
|
||||||
cmd.Flag("--exclude-documentation-from-stubs")
|
cmd.Flag("--exclude-documentation-from-stubs")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
||||||
@@ -1502,15 +1509,18 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
// Create rule for metalava
|
// Create rule for metalava
|
||||||
|
|
||||||
d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
|
||||||
|
|
||||||
srcJarDir := android.PathForModuleOut(ctx, "srcjars")
|
srcJarDir := android.PathForModuleOut(ctx, "srcjars")
|
||||||
stubsDir := android.PathForModuleOut(ctx, "stubsDir")
|
|
||||||
|
|
||||||
rule := android.NewRuleBuilder()
|
rule := android.NewRuleBuilder()
|
||||||
|
|
||||||
|
generateStubs := BoolDefault(d.properties.Generate_stubs, true)
|
||||||
|
var stubsDir android.OptionalPath
|
||||||
|
if generateStubs {
|
||||||
|
d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
||||||
|
stubsDir = android.OptionalPathForPath(android.PathForModuleOut(ctx, "stubsDir"))
|
||||||
rule.Command().Text("rm -rf").Text(stubsDir.String())
|
rule.Command().Text("rm -rf").Text(stubsDir.String())
|
||||||
rule.Command().Text("mkdir -p").Text(stubsDir.String())
|
rule.Command().Text("mkdir -p").Text(stubsDir.String())
|
||||||
|
}
|
||||||
|
|
||||||
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
||||||
|
|
||||||
@@ -1536,6 +1546,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
cmd.ImplicitOutput(android.PathForModuleGen(ctx, o))
|
cmd.ImplicitOutput(android.PathForModuleGen(ctx, o))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if generateStubs {
|
||||||
rule.Command().
|
rule.Command().
|
||||||
BuiltTool(ctx, "soong_zip").
|
BuiltTool(ctx, "soong_zip").
|
||||||
Flag("-write_if_changed").
|
Flag("-write_if_changed").
|
||||||
@@ -1543,6 +1554,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
|
FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
|
||||||
FlagWithArg("-C ", stubsDir.String()).
|
FlagWithArg("-C ", stubsDir.String()).
|
||||||
FlagWithArg("-D ", stubsDir.String())
|
FlagWithArg("-D ", stubsDir.String())
|
||||||
|
}
|
||||||
|
|
||||||
if Bool(d.properties.Write_sdk_values) {
|
if Bool(d.properties.Write_sdk_values) {
|
||||||
d.metadataZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-metadata.zip")
|
d.metadataZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-metadata.zip")
|
||||||
|
Reference in New Issue
Block a user