Prepare for a type-safe OnceKey
Add an opaque OnceKey type and use it for all calls to Once in build/soong. A future patch will convert the arguments to Once* to OnceKey once users outside build/soong have been updated. Test: onceper_test.go Change-Id: Ifcb338e6e603e804e507203c9508d30ffb2df966
This commit is contained in:
@@ -46,7 +46,7 @@ type overlayGlobResult struct {
|
||||
paths android.DirectorySortedPaths
|
||||
}
|
||||
|
||||
const overlayDataKey = "overlayDataKey"
|
||||
var overlayDataKey = android.NewOnceKey("overlayDataKey")
|
||||
|
||||
type globbedResourceDir struct {
|
||||
dir android.Path
|
||||
|
@@ -81,12 +81,14 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var dexpreoptGlobalConfigKey = android.NewOnceKey("DexpreoptGlobalConfig")
|
||||
|
||||
func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.ModuleOutPath) android.ModuleOutPath {
|
||||
if d.dexpreoptDisabled(ctx) {
|
||||
return dexJarFile
|
||||
}
|
||||
|
||||
globalConfig := ctx.Config().Once("DexpreoptGlobalConfig", func() interface{} {
|
||||
globalConfig := ctx.Config().Once(dexpreoptGlobalConfigKey, func() interface{} {
|
||||
if f := ctx.Config().DexpreoptGlobalConfig(); f != "" {
|
||||
ctx.AddNinjaFileDeps(f)
|
||||
globalConfig, err := dexpreopt.LoadGlobalConfig(f)
|
||||
|
@@ -121,7 +121,7 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath,
|
||||
hiddenAPISaveDexInputs(ctx, dexInput)
|
||||
}
|
||||
|
||||
const hiddenAPIOutputsKey = "hiddenAPIOutputsKey"
|
||||
var hiddenAPIOutputsKey = android.NewOnceKey("hiddenAPIOutputsKey")
|
||||
|
||||
var hiddenAPIOutputsLock sync.Mutex
|
||||
|
||||
|
@@ -28,7 +28,7 @@ func init() {
|
||||
android.RegisterPreSingletonType("sdk", sdkSingletonFactory)
|
||||
}
|
||||
|
||||
const sdkSingletonKey = "sdkSingletonKey"
|
||||
var sdkSingletonKey = android.NewOnceKey("sdkSingletonKey")
|
||||
|
||||
type sdkContext interface {
|
||||
// sdkVersion eturns the sdk_version property of the current module, or an empty string if it is not set.
|
||||
|
@@ -627,8 +627,10 @@ func (module *sdkLibrary) ImplementationJars(ctx android.BaseContext, sdkVersion
|
||||
}
|
||||
}
|
||||
|
||||
var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
|
||||
|
||||
func javaSdkLibraries(config android.Config) *[]string {
|
||||
return config.Once("javaSdkLibraries", func() interface{} {
|
||||
return config.Once(javaSdkLibrariesKey, func() interface{} {
|
||||
return &[]string{}
|
||||
}).(*[]string)
|
||||
}
|
||||
|
Reference in New Issue
Block a user