diff options
author | Artur Satayev <satayev@google.com> | 2020-02-19 16:39:59 +0000 |
---|---|---|
committer | Artur Satayev <satayev@google.com> | 2020-03-21 13:01:17 +0000 |
commit | 8a950790ee7c2aa3d2eb45d7da54978a3cc64169 (patch) | |
tree | 9ea6be5dd83dfc57c0761e8573341cb0de14339f /java/hiddenapi_singleton.go | |
parent | d775f6ae6532e811bff6a62abaae62b66784b929 (diff) |
Merge CSV files generated by UnsupportedAppUsageProcessor.
Flow:
1. Annotation processor generates a CSV file per class as a CLASS_OUTPUT resource.
2. hiddenapi.go extracts individual .csv files and merges them into an index.csv file per module.
3. hiddenapi_singleton.go merges individual index.csv files into a combined .csv file.
In a follow up hiddenapi-index.csv would replace unsupportedappusage_index.csv
Bug: 145132366
Change-Id: I87d92f9c8d4b1cc1df526fc576ee3c2101116b58
Merged-In: I87d92f9c8d4b1cc1df526fc576ee3c2101116b58
Test: diff unsupportedappusage_index.csv hiddenapi-index.csv
Exempt-From-Owner-Approval: cp from r.android.com/1239709
Diffstat (limited to 'java/hiddenapi_singleton.go')
-rw-r--r-- | java/hiddenapi_singleton.go | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go index 785019324..7e7e955f5 100644 --- a/java/hiddenapi_singleton.go +++ b/java/hiddenapi_singleton.go @@ -22,13 +22,15 @@ import ( func init() { android.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory) + android.RegisterSingletonType("hiddenapi_index", hiddenAPIIndexSingletonFactory) android.RegisterModuleType("hiddenapi_flags", hiddenAPIFlagsFactory) } type hiddenAPISingletonPathsStruct struct { - stubFlags android.OutputPath flags android.OutputPath + index android.OutputPath metadata android.OutputPath + stubFlags android.OutputPath } var hiddenAPISingletonPathsKey = android.NewOnceKey("hiddenAPISingletonPathsKey") @@ -39,9 +41,10 @@ var hiddenAPISingletonPathsKey = android.NewOnceKey("hiddenAPISingletonPathsKey" func hiddenAPISingletonPaths(ctx android.PathContext) hiddenAPISingletonPathsStruct { return ctx.Config().Once(hiddenAPISingletonPathsKey, func() interface{} { return hiddenAPISingletonPathsStruct{ - stubFlags: android.PathForOutput(ctx, "hiddenapi", "hiddenapi-stub-flags.txt"), flags: android.PathForOutput(ctx, "hiddenapi", "hiddenapi-flags.csv"), + index: android.PathForOutput(ctx, "hiddenapi", "hiddenapi-index.csv"), metadata: android.PathForOutput(ctx, "hiddenapi", "hiddenapi-greylist.csv"), + stubFlags: android.PathForOutput(ctx, "hiddenapi", "hiddenapi-stub-flags.txt"), } }).(hiddenAPISingletonPathsStruct) } @@ -364,3 +367,45 @@ func hiddenAPIFlagsFactory() android.Module { android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) return module } + +func hiddenAPIIndexSingletonFactory() android.Singleton { + return &hiddenAPIIndexSingleton{} +} + +type hiddenAPIIndexSingleton struct { + index android.Path +} + +func (h *hiddenAPIIndexSingleton) GenerateBuildActions(ctx android.SingletonContext) { + // Don't run any hiddenapi rules if UNSAFE_DISABLE_HIDDENAPI_FLAGS=true + if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") { + return + } + + indexes := android.Paths{} + ctx.VisitAllModules(func(module android.Module) { + if h, ok := module.(hiddenAPIIntf); ok { + if h.indexCSV() != nil { + indexes = append(indexes, h.indexCSV()) + } + } + }) + + rule := android.NewRuleBuilder() + rule.Command(). + BuiltTool(ctx, "merge_csv"). + FlagWithArg("--header=", "signature,file,startline,startcol,endline,endcol,properties"). + FlagWithOutput("--output=", hiddenAPISingletonPaths(ctx).index). + Inputs(indexes) + rule.Build(pctx, ctx, "singleton-merged-hiddenapi-index", "Singleton merged Hidden API index") + + h.index = hiddenAPISingletonPaths(ctx).index +} + +func (h *hiddenAPIIndexSingleton) MakeVars(ctx android.MakeVarsContext) { + if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") { + return + } + + ctx.Strict("INTERNAL_PLATFORM_HIDDENAPI_INDEX", h.index.String()) +} |