From 76e3e1f55461869fc66403b1c643dccde3e02c9f Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 7 Feb 2019 08:57:26 -0800 Subject: [PATCH] Use a presingleton to create hiddenapi singleton paths early If no module uses hiddenapi (because it is an unbundled build that does not build any boot image modules), then the makevars singleton panics because it will always run before the hiddenapi singleton (due to package init() function ordering), and the hiddenapi singleton paths have not been initialized yet. Add a presingleton to initialize the paths early. Bug: 123645297 Test: tapas Launcher3 && m on unbundled branch Change-Id: I9386ac87848a2181f51140129288df80fff9acfd --- java/hiddenapi_singleton.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go index 96de755ca..d43e276ac 100644 --- a/java/hiddenapi_singleton.go +++ b/java/hiddenapi_singleton.go @@ -19,6 +19,7 @@ import ( ) func init() { + android.RegisterPreSingletonType("pre-hiddenapi", hiddenAPIPreSingletonFactory) android.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory) } @@ -43,6 +44,18 @@ func hiddenAPISingletonPaths(ctx android.PathContext) hiddenAPISingletonPathsStr }).(hiddenAPISingletonPathsStruct) } +func hiddenAPIPreSingletonFactory() android.Singleton { + return hiddenAPIPreSingleton{} +} + +type hiddenAPIPreSingleton struct{} + +// hiddenAPI pre-singleton rules to ensure paths are always generated before +// makevars +func (hiddenAPIPreSingleton) GenerateBuildActions(ctx android.SingletonContext) { + hiddenAPISingletonPaths(ctx) +} + func hiddenAPISingletonFactory() android.Singleton { return hiddenAPISingleton{} }