summaryrefslogtreecommitdiff
path: root/java/droiddoc.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/droiddoc.go')
-rw-r--r--java/droiddoc.go90
1 files changed, 61 insertions, 29 deletions
diff --git a/java/droiddoc.go b/java/droiddoc.go
index dbe021d00..730f23696 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -135,6 +135,9 @@ type DroiddocProperties struct {
// At some point, this might be improved to show more warnings.
Todo_file *string `android:"path"`
+ // A file containing a baseline for allowed lint errors.
+ Lint_baseline *string `android:"path"`
+
// directory under current module source that provide additional resources (images).
Resourcesdir *string
@@ -179,6 +182,17 @@ func InitDroiddocModule(module android.DefaultableModule, hod android.HostOrDevi
func apiCheckEnabled(ctx android.ModuleContext, apiToCheck ApiToCheck, apiVersionTag string) bool {
if ctx.Config().IsEnvTrue("WITHOUT_CHECK_API") {
+ if ctx.Config().BuildFromTextStub() {
+ ctx.ModuleErrorf("Generating stubs from api signature files is not available " +
+ "with WITHOUT_CHECK_API=true, as sync between the source Java files and the " +
+ "api signature files is not guaranteed.\n" +
+ "In order to utilize WITHOUT_CHECK_API, generate stubs from the source Java " +
+ "files with BUILD_FROM_SOURCE_STUB=true.\n" +
+ "However, the usage of WITHOUT_CHECK_API is not preferred as the incremental " +
+ "build is slower when generating stubs from the source Java files.\n" +
+ "Consider updating the api signature files and generating the stubs from " +
+ "them instead.")
+ }
return false
} else if String(apiToCheck.Api_file) != "" && String(apiToCheck.Removed_api_file) != "" {
return true
@@ -205,17 +219,8 @@ type Javadoc struct {
docZip android.WritablePath
stubsSrcJar android.WritablePath
-}
-func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- return android.Paths{j.stubsSrcJar}, nil
- case ".docs.zip":
- return android.Paths{j.docZip}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
+ exportableStubsSrcJar android.WritablePath
}
// javadoc converts .java source files to documentation using javadoc.
@@ -238,8 +243,6 @@ func JavadocHostFactory() android.Module {
return module
}
-var _ android.OutputFileProducer = (*Javadoc)(nil)
-
func (j *Javadoc) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
return android.SdkSpecFrom(ctx, String(j.properties.Sdk_version))
}
@@ -299,7 +302,7 @@ func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Op
}
flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
- flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
+ flags = append(flags, "-I"+ctx.ModuleDir())
if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() {
flags = append(flags, "-I"+src.String())
}
@@ -360,8 +363,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
switch tag {
case bootClasspathTag:
- if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars...)
} else if sm, ok := module.(SystemModulesProvider); ok {
// A system modules dependency has been added to the bootclasspath
@@ -373,19 +375,19 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
case libTag, sdkLibTag:
if dep, ok := module.(SdkLibraryDependency); ok {
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))...)
- } else if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ } else if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.classpath = append(deps.classpath, dep.HeaderJars...)
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...)
+ deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.AconfigIntermediateCacheOutputPaths...)
} else if dep, ok := module.(android.SourceFileProducer); ok {
checkProducesJars(ctx, dep)
deps.classpath = append(deps.classpath, dep.Srcs()...)
} else {
ctx.ModuleErrorf("depends on non-java module %q", otherName)
}
+
case java9LibTag:
- if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars...)
} else {
ctx.ModuleErrorf("depends on non-java module %q", otherName)
@@ -397,6 +399,18 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
sm := module.(SystemModulesProvider)
outputDir, outputDeps := sm.OutputDirAndDeps()
deps.systemModules = &systemModules{outputDir, outputDeps}
+ case aconfigDeclarationTag:
+ if dep, ok := android.OtherModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey); ok {
+ deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.IntermediateCacheOutputPath)
+ } else if dep, ok := android.OtherModuleProvider(ctx, module, android.CodegenInfoProvider); ok {
+ deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.IntermediateCacheOutputPaths...)
+ } else {
+ ctx.ModuleErrorf("Only aconfig_declarations and aconfig_declarations_group "+
+ "module type is allowed for flags_packages property, but %s is neither "+
+ "of these supported module types",
+ module.Name(),
+ )
+ }
}
})
// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
@@ -404,6 +418,19 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
j.implicits = append(j.implicits, srcFiles...)
+ // Module can depend on a java_aconfig_library module using the ":module_name{.tag}" syntax.
+ // Find the corresponding aconfig_declarations module name for such case.
+ for _, src := range j.properties.Srcs {
+ if moduleName, tag := android.SrcIsModuleWithTag(src); moduleName != "" {
+ otherModule := android.GetModuleFromPathDep(ctx, moduleName, tag)
+ if otherModule != nil {
+ if dep, ok := android.OtherModuleProvider(ctx, otherModule, android.CodegenInfoProvider); ok {
+ deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.IntermediateCacheOutputPaths...)
+ }
+ }
+ }
+ }
+
filterByPackage := func(srcs []android.Path, filterPackages []string) []android.Path {
if filterPackages == nil {
return srcs
@@ -545,6 +572,9 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
zipSyncCleanupCmd(rule, srcJarDir)
rule.Build("javadoc", "javadoc")
+
+ ctx.SetOutputFiles(android.Paths{j.stubsSrcJar}, "")
+ ctx.SetOutputFiles(android.Paths{j.docZip}, ".docs.zip")
}
// Droiddoc
@@ -576,15 +606,6 @@ func DroiddocHostFactory() android.Module {
return module
}
-func (d *Droiddoc) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "", ".docs.zip":
- return android.Paths{d.Javadoc.docZip}, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (d *Droiddoc) DepsMutator(ctx android.BottomUpMutatorContext) {
d.Javadoc.addDeps(ctx)
@@ -608,6 +629,11 @@ func (d *Droiddoc) doclavaDocsFlags(ctx android.ModuleContext, cmd *android.Rule
FlagWithArg("-Xmaxerrs ", "10").
FlagWithArg("-Xmaxwarns ", "10").
Flag("-J--add-exports=jdk.javadoc/jdk.javadoc.internal.doclets.formats.html=ALL-UNNAMED").
+ Flag("-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED").
+ Flag("-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED").
+ Flag("-J--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED").
+ Flag("-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED").
+ Flag("-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED").
Flag("-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED").
FlagWithArg("-hdf page.build ", ctx.Config().BuildId()+"-$(cat "+buildNumberFile.String()+")").OrderOnly(buildNumberFile).
FlagWithArg("-hdf page.now ", `"$(date -d @$(cat `+ctx.Config().Getenv("BUILD_DATETIME_FILE")+`) "+%d %b %Y %k:%M")" `)
@@ -659,6 +685,10 @@ func (d *Droiddoc) doclavaDocsFlags(ctx android.ModuleContext, cmd *android.Rule
ImplicitOutput(android.PathForModuleOut(ctx, String(d.properties.Todo_file)))
}
+ if String(d.properties.Lint_baseline) != "" {
+ cmd.FlagWithInput("-lintbaseline ", android.PathForModuleSrc(ctx, String(d.properties.Lint_baseline)))
+ }
+
if String(d.properties.Resourcesdir) != "" {
// TODO: should we add files under resourcesDir to the implicits? It seems that
// resourcesDir is one sub dir of htmlDir
@@ -694,7 +724,6 @@ func javadocCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs andro
cmd := rule.Command().
BuiltTool("soong_javac_wrapper").Tool(config.JavadocCmd(ctx)).
Flag(config.JavacVmFlags).
- FlagWithArg("-encoding ", "UTF-8").
FlagWithRspFileInputList("@", android.PathForModuleOut(ctx, "javadoc.rsp"), srcs).
FlagWithInput("@", srcJarList)
@@ -828,6 +857,9 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
zipSyncCleanupCmd(rule, srcJarDir)
rule.Build("javadoc", desc)
+
+ ctx.SetOutputFiles(android.Paths{d.Javadoc.docZip}, "")
+ ctx.SetOutputFiles(android.Paths{d.Javadoc.docZip}, ".docs.zip")
}
// Exported Droiddoc Directory