Merge changes Ib8025019,I7d58d104,I9dd4312c,I995ed389,Iba2a8a5a, ... into rvc-dev

* changes:
  Allow droidstubs to not generate any stubs
  Remove conscrypt.module.intra.core.api.stubs from apex white list
  Ignore PrebuiltDepTag when processing APEX contents
  Stop requiring apex_available on java_library members of sdks
  Add dependency tags to apex available errors
  Extract DepIsInSameApex and RequiredSdks interfaces
This commit is contained in:
TreeHugger Robot
2020-04-23 15:19:41 +00:00
committed by Android (Google) Code Review
11 changed files with 177 additions and 66 deletions

View File

@@ -517,10 +517,21 @@ func (ddoc *Droiddoc) 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{
Class: "JAVA_LIBRARIES",
DistFile: android.OptionalPathForPath(dstubs.apiFile),
OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
DistFile: distFile,
OutputFile: outputFile,
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(entries *android.AndroidMkEntries) {

View File

@@ -257,6 +257,11 @@ type DroidstubsProperties struct {
// if set to true, allow Metalava to generate doc_stubs source files. Defaults to false.
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.
Api_levels_annotations_enabled *bool
@@ -1201,7 +1206,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") ||
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
String(d.properties.Api_filename) != "" {
@@ -1227,11 +1232,13 @@ func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuil
cmd.FlagWithArg("--sdk-values ", d.metadataDir.String())
}
if Bool(d.properties.Create_doc_stubs) {
cmd.FlagWithArg("--doc-stubs ", stubsDir.String())
} else {
cmd.FlagWithArg("--stubs ", stubsDir.String())
cmd.Flag("--exclude-documentation-from-stubs")
if stubsDir.Valid() {
if Bool(d.properties.Create_doc_stubs) {
cmd.FlagWithArg("--doc-stubs ", stubsDir.String())
} else {
cmd.FlagWithArg("--stubs ", stubsDir.String())
cmd.Flag("--exclude-documentation-from-stubs")
}
}
}
@@ -1388,15 +1395,18 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Create rule for metalava
d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
srcJarDir := android.PathForModuleOut(ctx, "srcjars")
stubsDir := android.PathForModuleOut(ctx, "stubsDir")
rule := android.NewRuleBuilder()
rule.Command().Text("rm -rf").Text(stubsDir.String())
rule.Command().Text("mkdir -p").Text(stubsDir.String())
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("mkdir -p").Text(stubsDir.String())
}
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
@@ -1422,13 +1432,15 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
cmd.ImplicitOutput(android.PathForModuleGen(ctx, o))
}
rule.Command().
BuiltTool(ctx, "soong_zip").
Flag("-write_if_changed").
Flag("-jar").
FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
FlagWithArg("-C ", stubsDir.String()).
FlagWithArg("-D ", stubsDir.String())
if generateStubs {
rule.Command().
BuiltTool(ctx, "soong_zip").
Flag("-write_if_changed").
Flag("-jar").
FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
FlagWithArg("-C ", stubsDir.String()).
FlagWithArg("-D ", stubsDir.String())
}
if Bool(d.properties.Write_sdk_values) {
d.metadataZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-metadata.zip")

View File

@@ -1764,11 +1764,6 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
if staticLibTag == ctx.OtherModuleDependencyTag(dep) {
return true
}
// Also, a dependency to an sdk member is also considered as such. This is required because
// sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator.
if sa, ok := dep.(android.SdkAware); ok && sa.IsInAnySdk() {
return true
}
return false
}
@@ -2508,11 +2503,6 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
if staticLibTag == ctx.OtherModuleDependencyTag(dep) {
return true
}
// Also, a dependency to an sdk member is also considered as such. This is required because
// sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator.
if sa, ok := dep.(android.SdkAware); ok && sa.IsInAnySdk() {
return true
}
return false
}