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:
Jerome Gaillard 2019-10-10 19:29:11 +01:00
parent 105e166581
commit 0b09ad7f34
2 changed files with 27 additions and 2 deletions

View file

@ -508,6 +508,9 @@ func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
if dstubs.jdiffDocZip != nil {
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 {
fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",

View file

@ -77,6 +77,8 @@ var (
`$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet --format=v2 ` +
`$opts && ` +
`${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"`,
CommandDeps: []string{
"${config.ZipSyncCmd}",
@ -89,7 +91,7 @@ var (
Restat: true,
},
"outDir", "srcJarDir", "stubsDir", "srcJars", "javaVersion", "bootclasspathArgs",
"classpathArgs", "sourcepathArgs", "opts")
"classpathArgs", "sourcepathArgs", "opts", "writeSdkValues", "metadataZip", "metadataDir")
metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck",
blueprint.RuleParams{
@ -1257,6 +1259,9 @@ type Droidstubs struct {
jdiffDocZip android.WritablePath
jdiffStubsSrcJar android.WritablePath
metadataZip android.WritablePath
metadataDir android.WritablePath
}
func DroidstubsFactory() android.Module {
@ -1391,7 +1396,8 @@ func (d *Droidstubs) collectStubsFlags(ctx android.ModuleContext,
}
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) {
@ -1543,6 +1549,19 @@ func (d *Droidstubs) transformMetalava(ctx android.ModuleContext, implicits andr
implicitOutputs android.WritablePaths, javaVersion,
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{
Rule: metalava,
Description: "Metalava",
@ -1560,6 +1579,9 @@ func (d *Droidstubs) transformMetalava(ctx android.ModuleContext, implicits andr
"classpathArgs": classpathArgs,
"sourcepathArgs": sourcepathArgs,
"opts": opts,
"writeSdkValues": writeSdkValues,
"metadataZip": metadataZip,
"metadataDir": metadataDir,
},
})
}