summaryrefslogtreecommitdiff
path: root/java/hiddenapi_singleton.go
diff options
context:
space:
mode:
authorBill Peckham <bpeckham@google.com>2021-01-08 09:34:44 -0800
committerBill Peckham <bpeckham@google.com>2021-01-19 10:07:45 -0800
commitbae4749de28b89a5702ed8cdeda1a390ad112e50 (patch)
tree35e2ec21b1e9ece53246ca1f1e5c2feab57abc75 /java/hiddenapi_singleton.go
parentad3421aacfac42bd4d2c907473eb943df94054ac (diff)
Enable prebuilt hiddenapi CSV files.
By enabling these hiddenapi CSV files to be prebuilt, it becomes possible to create a split build that supports the hiddenapi encode dex step, but doesn't contain all of the java sources needed to generate the CSV files. Bug: 175048716 Test: m nothing Test: new TestHiddenAPISingletonWithPrebuiltCsvFile Test: local build without prebuilt hiddenapi Test: local build with prebuilt hiddenapi Change-Id: I805ea3ec05860d2df211a3985ec025bf36f0d775
Diffstat (limited to 'java/hiddenapi_singleton.go')
-rw-r--r--java/hiddenapi_singleton.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index d3025247b..4bd255cbf 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -67,6 +67,19 @@ func (h *hiddenAPISingleton) GenerateBuildActions(ctx android.SingletonContext)
stubFlagsRule(ctx)
+ // If there is a prebuilt hiddenapi dir, generate rules to use the
+ // files within. Generally, we build the hiddenapi files from source
+ // during the build, ensuring consistency. It's possible, in a split
+ // build (framework and vendor) scenario, for the vendor build to use
+ // prebuilt hiddenapi files from the framework build. In this scenario,
+ // the framework and vendor builds must use the same source to ensure
+ // consistency.
+
+ if ctx.Config().PrebuiltHiddenApiDir(ctx) != "" {
+ h.flags = prebuiltFlagsRule(ctx)
+ return
+ }
+
// These rules depend on files located in frameworks/base, skip them if running in a tree that doesn't have them.
if ctx.Config().FrameworksBaseDirExists(ctx) {
h.flags = flagsRule(ctx)
@@ -212,6 +225,19 @@ func stubFlagsRule(ctx android.SingletonContext) {
rule.Build("hiddenAPIStubFlagsFile", "hiddenapi stub flags")
}
+func prebuiltFlagsRule(ctx android.SingletonContext) android.Path {
+ outputPath := hiddenAPISingletonPaths(ctx).flags
+ inputPath := android.PathForSource(ctx, ctx.Config().PrebuiltHiddenApiDir(ctx), "hiddenapi-flags.csv")
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cp,
+ Output: outputPath,
+ Input: inputPath,
+ })
+
+ return outputPath
+}
+
// flagsRule creates a rule to build hiddenapi-flags.csv out of flags.csv files generated for boot image modules and
// the unsupported API.
func flagsRule(ctx android.SingletonContext) android.Path {
@@ -391,6 +417,20 @@ func (h *hiddenAPIIndexSingleton) GenerateBuildActions(ctx android.SingletonCont
return
}
+ if ctx.Config().PrebuiltHiddenApiDir(ctx) != "" {
+ outputPath := hiddenAPISingletonPaths(ctx).index
+ inputPath := android.PathForSource(ctx, ctx.Config().PrebuiltHiddenApiDir(ctx), "hiddenapi-index.csv")
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cp,
+ Output: outputPath,
+ Input: inputPath,
+ })
+
+ h.index = outputPath
+ return
+ }
+
indexes := android.Paths{}
ctx.VisitAllModules(func(module android.Module) {
if h, ok := module.(hiddenAPIIntf); ok {