Droiddoc Support in Soong

Support Droiddoc to Soong based on core/droiddoc.mk. The non-std doclet
based droiddoc compilation output is a "real" stubs.jar instead of a
directory of java files and a timestamp file.

The std doclet based javadoc compilation output is a "empty" stubs.jar
instead of a timestamp file.

The stubs.jar will be exported to
out/target/common/obj/JAVA_LIBRARIES/$(LOCAL_MODULE)_intermediates/classes.jar
and out/target/common/docs/$(LOCAL_MODULE)-stubs.jar

A $(LOCAL_MODULE).zip file will be generated also, and is exported to
out/target/common/docs/$(LOCAL_MODULE)-docs.zip if property: installable is not set
to false.

Bug: b/70351683
Test: unittest + convert libcore docs Android.mk to Soong manually.

Change-Id: I1cffddd138a5d9d445f86a3d4a3fd4de88a2bc0f
(cherry picked from commit 78188ec622cb1ee24171455867fc58ffab91562e)
diff --git a/android/module.go b/android/module.go
index 6f247ab..fe6c0de 100644
--- a/android/module.go
+++ b/android/module.go
@@ -113,6 +113,7 @@
 	ExpandOptionalSource(srcFile *string, prop string) OptionalPath
 	ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths
 	Glob(globPattern string, excludes []string) Paths
+	GlobFiles(globPattern string, excludes []string) Paths
 
 	InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
 	InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
@@ -1245,6 +1246,24 @@
 	return pathsForModuleSrcFromFullPath(ctx, ret)
 }
 
+// glob only "files" under the directory relative to top of the source tree.
+func (ctx *androidModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
+	paths, err := ctx.GlobWithDeps(globPattern, excludes)
+	if err != nil {
+		ctx.ModuleErrorf("glob: %s", err.Error())
+	}
+	var ret []Path
+	for _, p := range paths {
+		if isDir, err := ctx.Fs().IsDir(p); err != nil {
+			ctx.ModuleErrorf("error in IsDir(%s): %s", p, err.Error())
+			return nil
+		} else if !isDir {
+			ret = append(ret, PathForSource(ctx, p))
+		}
+	}
+	return ret
+}
+
 func init() {
 	RegisterSingletonType("buildtarget", BuildTargetSingleton)
 }