diff --git a/java/androidmk.go b/java/androidmk.go index bd88a1d16..509ad940a 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -319,15 +319,12 @@ func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData { Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", Extra: []android.AndroidMkExtraFunc{ func(w io.Writer, outputFile android.Path) { - if BoolDefault(ddoc.Javadoc.properties.Installable, true) { + if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil { fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String()) } if ddoc.Javadoc.stubsSrcJar != nil { fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String()) } - if ddoc.annotationsZip != nil { - fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", ddoc.annotationsZip.String()) - } if ddoc.checkCurrentApiTimestamp != nil { fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api") fmt.Fprintln(w, ddoc.Name()+"-check-current-api:", @@ -387,6 +384,75 @@ func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData { } } +func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData { + return android.AndroidMkData{ + Class: "JAVA_LIBRARIES", + OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar), + Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", + Extra: []android.AndroidMkExtraFunc{ + func(w io.Writer, outputFile android.Path) { + if dstubs.Javadoc.stubsSrcJar != nil { + fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String()) + } + if dstubs.annotationsZip != nil { + fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String()) + } + if dstubs.checkCurrentApiTimestamp != nil { + fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api") + fmt.Fprintln(w, dstubs.Name()+"-check-current-api:", + dstubs.checkCurrentApiTimestamp.String()) + + fmt.Fprintln(w, ".PHONY: checkapi") + fmt.Fprintln(w, "checkapi:", + dstubs.checkCurrentApiTimestamp.String()) + + fmt.Fprintln(w, ".PHONY: droidcore") + fmt.Fprintln(w, "droidcore: checkapi") + } + if dstubs.updateCurrentApiTimestamp != nil { + fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api") + fmt.Fprintln(w, dstubs.Name()+"-update-current-api:", + dstubs.updateCurrentApiTimestamp.String()) + + fmt.Fprintln(w, ".PHONY: update-api") + fmt.Fprintln(w, "update-api:", + dstubs.updateCurrentApiTimestamp.String()) + } + if dstubs.checkLastReleasedApiTimestamp != nil { + fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api") + fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:", + dstubs.checkLastReleasedApiTimestamp.String()) + } + apiFilePrefix := "INTERNAL_PLATFORM_" + if String(dstubs.properties.Api_tag_name) != "" { + apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_" + } + if dstubs.apiFile != nil { + fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String()) + } + if dstubs.dexApiFile != nil { + fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String()) + } + if dstubs.privateApiFile != nil { + fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String()) + } + if dstubs.privateDexApiFile != nil { + fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String()) + } + if dstubs.removedApiFile != nil { + fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String()) + } + if dstubs.removedDexApiFile != nil { + fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String()) + } + if dstubs.exactApiFile != nil { + fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String()) + } + }, + }, + } +} + func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) { var testFiles []string for _, d := range data { diff --git a/java/droiddoc.go b/java/droiddoc.go index 68d78610b..3123baf56 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -31,7 +31,7 @@ var ( Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` + `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + `${config.JavadocCmd} -encoding UTF-8 @$out.rsp @$srcJarDir/list ` + - `$opts $bootclasspathArgs $classpathArgs -sourcepath $sourcepath ` + + `$opts $bootclasspathArgs $classpathArgs $sourcepathArgs ` + `-d $outDir -quiet && ` + `${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` + `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir $postDoclavaCmds`, @@ -45,7 +45,7 @@ var ( Restat: true, }, "outDir", "srcJarDir", "stubsDir", "srcJars", "opts", - "bootclasspathArgs", "classpathArgs", "sourcepath", "docZip", "postDoclavaCmds") + "bootclasspathArgs", "classpathArgs", "sourcepathArgs", "docZip", "postDoclavaCmds") apiCheck = pctx.AndroidStaticRule("apiCheck", blueprint.RuleParams{ @@ -60,41 +60,39 @@ var ( updateApi = pctx.AndroidStaticRule("updateApi", blueprint.RuleParams{ - Command: `( ( cp -f $apiFileToCheck $apiFile && cp -f $removedApiFileToCheck $removedApiFile ) ` + + Command: `( ( cp -f $srcApiFile $destApiFile && cp -f $srcRemovedApiFile $destRemovedApiFile ) ` + `&& touch $out ) || (echo failed to update public API ; exit 38)`, }, - "apiFile", "apiFileToCheck", "removedApiFile", "removedApiFileToCheck") + "srcApiFile", "destApiFile", "srcRemovedApiFile", "destRemovedApiFile") metalava = pctx.AndroidStaticRule("metalava", blueprint.RuleParams{ - Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" "$docStubsDir" && ` + - `mkdir -p "$outDir" "$srcJarDir" "$stubsDir" "$docStubsDir" && ` + + Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && ` + + `mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` + `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + `${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` + - `$bootclasspathArgs $classpathArgs -sourcepath $sourcepath --no-banner --color --quiet ` + - `--stubs $stubsDir $opts && ` + - `${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` + + `$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet ` + + `$opts && ` + `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir`, CommandDeps: []string{ "${config.ZipSyncCmd}", "${config.JavaCmd}", "${config.MetalavaJar}", - "${config.JavadocCmd}", "${config.SoongZipCmd}", }, Rspfile: "$out.rsp", RspfileContent: "$in", Restat: true, }, - "outDir", "srcJarDir", "stubsDir", "docStubsDir", "srcJars", "javaVersion", "bootclasspathArgs", - "classpathArgs", "sourcepath", "opts", "docZip") + "outDir", "srcJarDir", "stubsDir", "srcJars", "javaVersion", "bootclasspathArgs", + "classpathArgs", "sourcepathArgs", "opts") metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck", blueprint.RuleParams{ Command: `( rm -rf "$srcJarDir" && mkdir -p "$srcJarDir" && ` + `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + `${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` + - `$bootclasspathArgs $classpathArgs -sourcepath $sourcepath --no-banner --color --quiet ` + + `$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet ` + `$opts && touch $out ) || ` + `( echo -e "$msg" ; exit 38 )`, CommandDeps: []string{ @@ -105,17 +103,40 @@ var ( Rspfile: "$out.rsp", RspfileContent: "$in", }, - "srcJarDir", "srcJars", "javaVersion", "bootclasspathArgs", "classpathArgs", "sourcepath", "opts", "msg") + "srcJarDir", "srcJars", "javaVersion", "bootclasspathArgs", "classpathArgs", "sourcepathArgs", "opts", "msg") + + dokka = pctx.AndroidStaticRule("dokka", + blueprint.RuleParams{ + Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && ` + + `mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` + + `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + + `${config.JavaCmd} -jar ${config.DokkaJar} $srcJarDir ` + + `$classpathArgs -format dac -dacRoot /reference/kotlin -output $outDir $opts && ` + + `${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` + + `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir`, + CommandDeps: []string{ + "${config.ZipSyncCmd}", + "${config.DokkaJar}", + "${config.MetalavaJar}", + "${config.SoongZipCmd}", + }, + Restat: true, + }, + "outDir", "srcJarDir", "stubsDir", "srcJars", "classpathArgs", "opts", "docZip") ) func init() { android.RegisterModuleType("doc_defaults", DocDefaultsFactory) + android.RegisterModuleType("stubs_defaults", StubsDefaultsFactory) android.RegisterModuleType("droiddoc", DroiddocFactory) android.RegisterModuleType("droiddoc_host", DroiddocHostFactory) android.RegisterModuleType("droiddoc_exported_dir", ExportedDroiddocDirFactory) android.RegisterModuleType("javadoc", JavadocFactory) android.RegisterModuleType("javadoc_host", JavadocHostFactory) + + android.RegisterModuleType("droidstubs", DroidstubsFactory) + android.RegisterModuleType("droidstubs_host", DroidstubsHostFactory) } var ( @@ -168,6 +189,18 @@ type JavadocProperties struct { // If not blank, set the java version passed to javadoc as -source Java_version *string + + // local files that are used within user customized droiddoc options. + Arg_files []string + + // user customized droiddoc args. + // Available variables for substitution: + // + // $(location