Parameterize scopes with additional droidstubs args

Added droidstubsArgs field to the apiscope structure to avoid
switching on api scope type.

Bug: 153443117
Bug: 153306490
Test: m nothing
Merged-In: I96f0eb033d44c6a74787ba7f1523799b05a58092
Change-Id: I96f0eb033d44c6a74787ba7f1523799b05a58092
This commit is contained in:
Paul Duffin
2020-04-07 18:50:10 +01:00
parent cbcfcaa113
commit 3c7c34769d

View File

@@ -86,6 +86,9 @@ type apiScope struct {
// *current. Older stubs library built with a numbered SDK version is created from // *current. Older stubs library built with a numbered SDK version is created from
// the prebuilt jar. // the prebuilt jar.
sdkVersion string sdkVersion string
// Extra arguments to pass to droidstubs for this scope.
droidstubsArgs []string
} }
// Initialize a scope, creating and adding appropriate dependency tags // Initialize a scope, creating and adding appropriate dependency tags
@@ -131,6 +134,7 @@ var (
moduleSuffix: sdkSystemApiSuffix, moduleSuffix: sdkSystemApiSuffix,
apiFileMakeVariableSuffix: "_SYSTEM", apiFileMakeVariableSuffix: "_SYSTEM",
sdkVersion: "system_current", sdkVersion: "system_current",
droidstubsArgs: []string{"-showAnnotation android.annotation.SystemApi"},
}) })
apiScopeTest = initApiScope(&apiScope{ apiScopeTest = initApiScope(&apiScope{
name: "test", name: "test",
@@ -138,6 +142,7 @@ var (
moduleSuffix: sdkTestApiSuffix, moduleSuffix: sdkTestApiSuffix,
apiFileMakeVariableSuffix: "_TEST", apiFileMakeVariableSuffix: "_TEST",
sdkVersion: "test_current", sdkVersion: "test_current",
droidstubsArgs: []string{"-showAnnotation android.annotation.TestApi"},
}) })
allApiScopes = apiScopes{ allApiScopes = apiScopes{
apiScopePublic, apiScopePublic,
@@ -528,12 +533,8 @@ func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiSc
} }
droidstubsArgs = append(droidstubsArgs, android.JoinWithPrefix(disabledWarnings, "--hide ")) droidstubsArgs = append(droidstubsArgs, android.JoinWithPrefix(disabledWarnings, "--hide "))
switch apiScope { // Add in scope specific arguments.
case apiScopeSystem: droidstubsArgs = append(droidstubsArgs, apiScope.droidstubsArgs...)
droidstubsArgs = append(droidstubsArgs, "-showAnnotation android.annotation.SystemApi")
case apiScopeTest:
droidstubsArgs = append(droidstubsArgs, " -showAnnotation android.annotation.TestApi")
}
props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files
props.Args = proptools.StringPtr(strings.Join(droidstubsArgs, " ")) props.Args = proptools.StringPtr(strings.Join(droidstubsArgs, " "))