Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 581fd21e authored by Nan Zhang's avatar Nan Zhang
Browse files

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)
parent 50b8682d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -220,6 +220,7 @@ bootstrap_go_package {
        "java/app.go",
        "java/builder.go",
        "java/dex.go",
        "java/droiddoc.go",
        "java/gen.go",
        "java/genrule.go",
        "java/jacoco.go",
+8 −0
Original line number Diff line number Diff line
@@ -425,6 +425,14 @@ func (c *config) EmbeddedInMake() bool {
	return c.inMake
}

func (c *config) BuildId() string {
	return String(c.ProductVariables.BuildId)
}

func (c *config) BuildNumberFromFile() string {
	return String(c.ProductVariables.BuildNumberFromFile)
}

// DeviceName returns the name of the current device target
// TODO: take an AndroidModuleContext to select the device name for multi-device builds
func (c *config) DeviceName() string {
+19 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ type ModuleContext interface {
	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 @@ func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Pat
	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)
}
+4 −0
Original line number Diff line number Diff line
@@ -110,6 +110,10 @@ type productVariables struct {
	// Suffix to add to generated Makefiles
	Make_suffix *string `json:",omitempty"`

	BuildId             *string `json:",omitempty"`
	BuildNumberFromFile *string `json:",omitempty"`
	DateFromFile        *string `json:",omitempty"`

	Platform_sdk_version              *int     `json:",omitempty"`
	Platform_sdk_final                *bool    `json:",omitempty"`
	Platform_version_active_codenames []string `json:",omitempty"`
+36 −0
Original line number Diff line number Diff line
@@ -196,3 +196,39 @@ func (app *AndroidApp) AndroidMk() android.AndroidMkData {
	}

}

func (jd *Javadoc) AndroidMk() android.AndroidMkData {
	return android.AndroidMkData{
		Class:      "JAVA_LIBRARIES",
		OutputFile: android.OptionalPathForPath(jd.stubsJar),
		Include:    "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
		Extra: []android.AndroidMkExtraFunc{
			func(w io.Writer, outputFile android.Path) {
				if jd.properties.Installable == nil || *jd.properties.Installable == true {
					fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
				}
				if jd.stubsJar != nil {
					fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_JAR := ", jd.stubsJar.String())
				}
			},
		},
	}
}

func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
	return android.AndroidMkData{
		Class:      "JAVA_LIBRARIES",
		OutputFile: android.OptionalPathForPath(ddoc.stubsJar),
		Include:    "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
		Extra: []android.AndroidMkExtraFunc{
			func(w io.Writer, outputFile android.Path) {
				if ddoc.Javadoc.properties.Installable == nil || *ddoc.Javadoc.properties.Installable == true {
					fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
				}
				if ddoc.Javadoc.stubsJar != nil {
					fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_JAR := ", ddoc.Javadoc.stubsJar.String())
				}
			},
		},
	}
}
Loading