Merge "Changed droiddoc.go to compile Metalava based android.jar"

This commit is contained in:
Treehugger Robot
2018-06-18 16:55:28 +00:00
committed by Gerrit Code Review
2 changed files with 22 additions and 16 deletions

View File

@@ -70,8 +70,8 @@ var (
Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` + Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` +
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
`${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source 1.8 @$out.rsp @$srcJarDir/list ` + `${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source 1.8 @$out.rsp @$srcJarDir/list ` +
`$bootclasspathArgs $classpathArgs -sourcepath $sourcepath --no-banner --color ` + `$bootclasspathArgs $classpathArgs -sourcepath $sourcepath --no-banner --color --quiet ` +
`--stubs $stubsDir --quiet --write-stubs-source-list $outDir/stubs_src_list $opts && ` + `--stubs $stubsDir $opts && ` +
`${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` + `${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` +
`${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir`, `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir`,
CommandDeps: []string{ CommandDeps: []string{
@@ -240,7 +240,7 @@ type DroiddocProperties struct {
// is set to true, Metalava will allow framework SDK to contain annotations. // is set to true, Metalava will allow framework SDK to contain annotations.
Metalava_annotations_enabled *bool Metalava_annotations_enabled *bool
// a XML files set to merge annotations. // a top level directory contains XML files set to merge annotations.
Metalava_merge_annotations_dir *string Metalava_merge_annotations_dir *string
} }
@@ -854,7 +854,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if String(d.properties.Metalava_previous_api) != "" { if String(d.properties.Metalava_previous_api) != "" {
previousApi = ctx.ExpandSource(String(d.properties.Metalava_previous_api), previousApi = ctx.ExpandSource(String(d.properties.Metalava_previous_api),
"metalava_previous_api") "metalava_previous_api")
opts += " --check-compatibility --previous-api " + previousApi.String() opts += " --previous-api " + previousApi.String()
implicits = append(implicits, previousApi) implicits = append(implicits, previousApi)
} }
@@ -873,19 +873,19 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
"has to be non-empty if annotations was enabled!") "has to be non-empty if annotations was enabled!")
} }
mergeAnnotationsDir := android.PathForModuleSrc(ctx, mergeAnnotationsDir := android.PathForSource(ctx, String(d.properties.Metalava_merge_annotations_dir))
String(d.properties.Metalava_merge_annotations_dir))
implicits = append(implicits, ctx.Glob(mergeAnnotationsDir.Join(ctx, "**/*").String(), nil)...)
opts += " --extract-annotations " + annotationsZip.String() + " --merge-annotations " + mergeAnnotationsDir.String() opts += " --extract-annotations " + annotationsZip.String() + " --merge-annotations " + mergeAnnotationsDir.String()
// TODO(tnorbye): find owners to fix these warnings when annotation was enabled. // TODO(tnorbye): find owners to fix these warnings when annotation was enabled.
opts += "--hide HiddenTypedefConstant --hide SuperfluousPrefix --hide AnnotationExtraction" opts += " --hide HiddenTypedefConstant --hide SuperfluousPrefix --hide AnnotationExtraction"
} }
if genDocsForMetalava { if genDocsForMetalava {
opts += " --generate-documentation ${config.JavadocCmd} -encoding UTF-8 STUBS_SOURCE_LIST " + opts += " --doc-stubs " + android.PathForModuleOut(ctx, "docs", "docStubsDir").String() +
" --write-doc-stubs-source-list $outDir/doc_stubs_src_list " +
" --generate-documentation ${config.JavadocCmd} -encoding UTF-8 DOC_STUBS_SOURCE_LIST " +
doclavaOpts + docArgsForMetalava + bootClasspathArgs + " " + classpathArgs + " " + " -sourcepath " + doclavaOpts + docArgsForMetalava + bootClasspathArgs + " " + classpathArgs + " " + " -sourcepath " +
strings.Join(d.Javadoc.sourcepaths.Strings(), ":") + " -quiet -d $outDir " android.PathForModuleOut(ctx, "docs", "docStubsDir").String() + " -quiet -d $outDir "
implicits = append(implicits, jsilver) implicits = append(implicits, jsilver)
implicits = append(implicits, doclava) implicits = append(implicits, doclava)
} }

View File

@@ -507,7 +507,10 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} }
if ctx.ModuleName() == "android_stubs_current" || if ctx.ModuleName() == "android_stubs_current" ||
ctx.ModuleName() == "android_system_stubs_current" || ctx.ModuleName() == "android_system_stubs_current" ||
ctx.ModuleName() == "android_test_stubs_current" { ctx.ModuleName() == "android_test_stubs_current" ||
ctx.ModuleName() == "metalava_android_stubs_current" ||
ctx.ModuleName() == "metalava_android_system_stubs_current" ||
ctx.ModuleName() == "metalava_android_test_stubs_current" {
ctx.AddDependency(ctx.Module(), frameworkApkTag, "framework-res") ctx.AddDependency(ctx.Module(), frameworkApkTag, "framework-res")
} }
} }
@@ -628,13 +631,13 @@ func getLinkType(m *Module, name string) linkType {
ver := String(m.deviceProperties.Sdk_version) ver := String(m.deviceProperties.Sdk_version)
noStdLibs := Bool(m.properties.No_standard_libs) noStdLibs := Bool(m.properties.No_standard_libs)
switch { switch {
case name == "core.current.stubs" || ver == "core_current" || noStdLibs: case name == "core.current.stubs" || ver == "core_current" || noStdLibs || name == "stub-annotations":
return javaCore return javaCore
case name == "android_system_stubs_current" || strings.HasPrefix(ver, "system_"): case name == "android_system_stubs_current" || strings.HasPrefix(ver, "system_") || name == "metalava_android_system_stubs_current":
return javaSystem return javaSystem
case name == "android_test_stubs_current" || strings.HasPrefix(ver, "test_"): case name == "android_test_stubs_current" || strings.HasPrefix(ver, "test_") || name == "metalava_android_test_stubs_current":
return javaPlatform return javaPlatform
case name == "android_stubs_current" || ver == "current": case name == "android_stubs_current" || ver == "current" || name == "metalava_android_stubs_current":
return javaSdk return javaSdk
case ver == "": case ver == "":
return javaPlatform return javaPlatform
@@ -724,7 +727,10 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
case frameworkApkTag: case frameworkApkTag:
if ctx.ModuleName() == "android_stubs_current" || if ctx.ModuleName() == "android_stubs_current" ||
ctx.ModuleName() == "android_system_stubs_current" || ctx.ModuleName() == "android_system_stubs_current" ||
ctx.ModuleName() == "android_test_stubs_current" { ctx.ModuleName() == "android_test_stubs_current" ||
ctx.ModuleName() == "metalava_android_stubs_current" ||
ctx.ModuleName() == "metalava_android_system_stubs_current" ||
ctx.ModuleName() == "metalava_android_test_stubs_current" {
// framework stubs.jar need to depend on framework-res.apk, in order to pull the // framework stubs.jar need to depend on framework-res.apk, in order to pull the
// resource files out of there for aapt. // resource files out of there for aapt.
// //