Update droidstubs build target
This allows to use Metalava to generate metadata files useful for Android Studio as part of a droidstubs target. Once those files have been created in a new metadata folder, they are zipped to make it easier to transfer them into the out/target/common/obj/PACKAGING folder where they can then be picked up by the SDK build to be included there. Bug: 142480924 Test: m sdk Change-Id: I4be1c9e78369c65ee9cd94706c6d20ab0df6b797 Merged-In: I4be1c9e78369c65ee9cd94706c6d20ab0df6b797
This commit is contained in:
@@ -508,6 +508,9 @@ func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
|
|||||||
if dstubs.jdiffDocZip != nil {
|
if dstubs.jdiffDocZip != nil {
|
||||||
fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
|
fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
|
||||||
}
|
}
|
||||||
|
if dstubs.metadataZip != nil {
|
||||||
|
fmt.Fprintln(w, "LOCAL_DROIDDOC_METADATA_ZIP := ", dstubs.metadataZip.String())
|
||||||
|
}
|
||||||
if dstubs.checkCurrentApiTimestamp != nil {
|
if dstubs.checkCurrentApiTimestamp != nil {
|
||||||
fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
|
fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
|
||||||
fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
|
fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
|
||||||
|
@@ -77,6 +77,8 @@ var (
|
|||||||
`$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet --format=v2 ` +
|
`$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet --format=v2 ` +
|
||||||
`$opts && ` +
|
`$opts && ` +
|
||||||
`${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir && ` +
|
`${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir && ` +
|
||||||
|
`(if $writeSdkValues; then ${config.SoongZipCmd} -write_if_changed -d -o $metadataZip ` +
|
||||||
|
`-C $metadataDir -D $metadataDir; fi) && ` +
|
||||||
`rm -rf "$srcJarDir"`,
|
`rm -rf "$srcJarDir"`,
|
||||||
CommandDeps: []string{
|
CommandDeps: []string{
|
||||||
"${config.ZipSyncCmd}",
|
"${config.ZipSyncCmd}",
|
||||||
@@ -89,7 +91,7 @@ var (
|
|||||||
Restat: true,
|
Restat: true,
|
||||||
},
|
},
|
||||||
"outDir", "srcJarDir", "stubsDir", "srcJars", "javaVersion", "bootclasspathArgs",
|
"outDir", "srcJarDir", "stubsDir", "srcJars", "javaVersion", "bootclasspathArgs",
|
||||||
"classpathArgs", "sourcepathArgs", "opts")
|
"classpathArgs", "sourcepathArgs", "opts", "writeSdkValues", "metadataZip", "metadataDir")
|
||||||
|
|
||||||
metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck",
|
metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
@@ -1257,6 +1259,9 @@ type Droidstubs struct {
|
|||||||
|
|
||||||
jdiffDocZip android.WritablePath
|
jdiffDocZip android.WritablePath
|
||||||
jdiffStubsSrcJar android.WritablePath
|
jdiffStubsSrcJar android.WritablePath
|
||||||
|
|
||||||
|
metadataZip android.WritablePath
|
||||||
|
metadataDir android.WritablePath
|
||||||
}
|
}
|
||||||
|
|
||||||
func DroidstubsFactory() android.Module {
|
func DroidstubsFactory() android.Module {
|
||||||
@@ -1391,7 +1396,8 @@ func (d *Droidstubs) collectStubsFlags(ctx android.ModuleContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if Bool(d.properties.Write_sdk_values) {
|
if Bool(d.properties.Write_sdk_values) {
|
||||||
metalavaFlags = metalavaFlags + " --sdk-values " + android.PathForModuleOut(ctx, "out").String()
|
d.metadataDir = android.PathForModuleOut(ctx, "metadata")
|
||||||
|
metalavaFlags = metalavaFlags + " --sdk-values " + d.metadataDir.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
if Bool(d.properties.Create_doc_stubs) {
|
if Bool(d.properties.Create_doc_stubs) {
|
||||||
@@ -1543,6 +1549,19 @@ func (d *Droidstubs) transformMetalava(ctx android.ModuleContext, implicits andr
|
|||||||
implicitOutputs android.WritablePaths, javaVersion,
|
implicitOutputs android.WritablePaths, javaVersion,
|
||||||
bootclasspathArgs, classpathArgs, sourcepathArgs, opts string) {
|
bootclasspathArgs, classpathArgs, sourcepathArgs, opts string) {
|
||||||
|
|
||||||
|
var writeSdkValues, metadataZip, metadataDir string
|
||||||
|
if Bool(d.properties.Write_sdk_values) {
|
||||||
|
writeSdkValues = "true"
|
||||||
|
d.metadataZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-metadata.zip")
|
||||||
|
metadataZip = d.metadataZip.String()
|
||||||
|
metadataDir = d.metadataDir.String()
|
||||||
|
implicitOutputs = append(implicitOutputs, d.metadataZip)
|
||||||
|
} else {
|
||||||
|
writeSdkValues = "false"
|
||||||
|
metadataZip = ""
|
||||||
|
metadataDir = ""
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: metalava,
|
Rule: metalava,
|
||||||
Description: "Metalava",
|
Description: "Metalava",
|
||||||
@@ -1560,6 +1579,9 @@ func (d *Droidstubs) transformMetalava(ctx android.ModuleContext, implicits andr
|
|||||||
"classpathArgs": classpathArgs,
|
"classpathArgs": classpathArgs,
|
||||||
"sourcepathArgs": sourcepathArgs,
|
"sourcepathArgs": sourcepathArgs,
|
||||||
"opts": opts,
|
"opts": opts,
|
||||||
|
"writeSdkValues": writeSdkValues,
|
||||||
|
"metadataZip": metadataZip,
|
||||||
|
"metadataDir": metadataDir,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user