Merge "Add property api_levels_jar_filename to droidstubs" am: 9c55b0efa2
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1388544 Change-Id: I4da722343ed53baedf40ad7661fc1f017051a70d
This commit is contained in:
commit
a4278eba24
|
@ -294,6 +294,9 @@ type DroidstubsProperties struct {
|
||||||
// the dirs which Metalava extracts API levels annotations from.
|
// the dirs which Metalava extracts API levels annotations from.
|
||||||
Api_levels_annotations_dirs []string
|
Api_levels_annotations_dirs []string
|
||||||
|
|
||||||
|
// the filename which Metalava extracts API levels annotations from. Defaults to android.jar.
|
||||||
|
Api_levels_jar_filename *string
|
||||||
|
|
||||||
// if set to true, collect the values used by the Dev tools and
|
// if set to true, collect the values used by the Dev tools and
|
||||||
// write them in files packaged with the SDK. Defaults to false.
|
// write them in files packaged with the SDK. Defaults to false.
|
||||||
Write_sdk_values *bool
|
Write_sdk_values *bool
|
||||||
|
@ -1407,7 +1410,10 @@ func (d *Droidstubs) inclusionAnnotationsFlags(ctx android.ModuleContext, cmd *a
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
||||||
if Bool(d.properties.Api_levels_annotations_enabled) {
|
if !Bool(d.properties.Api_levels_annotations_enabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
d.apiVersionsXml = android.PathForModuleOut(ctx, "api-versions.xml")
|
d.apiVersionsXml = android.PathForModuleOut(ctx, "api-versions.xml")
|
||||||
|
|
||||||
if len(d.properties.Api_levels_annotations_dirs) == 0 {
|
if len(d.properties.Api_levels_annotations_dirs) == 0 {
|
||||||
|
@ -1420,21 +1426,21 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
|
||||||
cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion())
|
cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion())
|
||||||
cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename())
|
cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename())
|
||||||
|
|
||||||
|
filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar")
|
||||||
|
|
||||||
ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) {
|
ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) {
|
||||||
if t, ok := m.(*ExportedDroiddocDir); ok {
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
||||||
for _, dep := range t.deps {
|
for _, dep := range t.deps {
|
||||||
if strings.HasSuffix(dep.String(), "android.jar") {
|
if strings.HasSuffix(dep.String(), filename) {
|
||||||
cmd.Implicit(dep)
|
cmd.Implicit(dep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd.FlagWithArg("--android-jar-pattern ", t.dir.String()+"/%/public/android.jar")
|
cmd.FlagWithArg("--android-jar-pattern ", t.dir.String()+"/%/public/"+filename)
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("api_levels_annotations_dirs",
|
ctx.PropertyErrorf("api_levels_annotations_dirs",
|
||||||
"module %q is not a metalava api-levels-annotations dir", ctx.OtherModuleName(m))
|
"module %q is not a metalava api-levels-annotations dir", ctx.OtherModuleName(m))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
||||||
|
|
|
@ -1170,6 +1170,62 @@ func TestDroiddocArgsAndFlagsCausesError(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDroidstubs(t *testing.T) {
|
||||||
|
ctx, _ := testJavaWithFS(t, `
|
||||||
|
droiddoc_exported_dir {
|
||||||
|
name: "droiddoc-templates-sdk",
|
||||||
|
path: ".",
|
||||||
|
}
|
||||||
|
|
||||||
|
droidstubs {
|
||||||
|
name: "bar-stubs",
|
||||||
|
srcs: [
|
||||||
|
"bar-doc/a.java",
|
||||||
|
],
|
||||||
|
api_levels_annotations_dirs: [
|
||||||
|
"droiddoc-templates-sdk",
|
||||||
|
],
|
||||||
|
api_levels_annotations_enabled: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
droidstubs {
|
||||||
|
name: "bar-stubs-other",
|
||||||
|
srcs: [
|
||||||
|
"bar-doc/a.java",
|
||||||
|
],
|
||||||
|
api_levels_annotations_dirs: [
|
||||||
|
"droiddoc-templates-sdk",
|
||||||
|
],
|
||||||
|
api_levels_annotations_enabled: true,
|
||||||
|
api_levels_jar_filename: "android.other.jar",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
map[string][]byte{
|
||||||
|
"bar-doc/a.java": nil,
|
||||||
|
})
|
||||||
|
testcases := []struct {
|
||||||
|
moduleName string
|
||||||
|
expectedJarFilename string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
moduleName: "bar-stubs",
|
||||||
|
expectedJarFilename: "android.jar",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
moduleName: "bar-stubs-other",
|
||||||
|
expectedJarFilename: "android.other.jar",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, c := range testcases {
|
||||||
|
m := ctx.ModuleForTests(c.moduleName, "android_common")
|
||||||
|
metalava := m.Rule("metalava")
|
||||||
|
expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename
|
||||||
|
if actual := metalava.RuleParams.Command; !strings.Contains(actual, expected) {
|
||||||
|
t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDroidstubsWithSystemModules(t *testing.T) {
|
func TestDroidstubsWithSystemModules(t *testing.T) {
|
||||||
ctx, _ := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
droidstubs {
|
droidstubs {
|
||||||
|
|
Loading…
Reference in New Issue