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
diff --git a/cc/compiler.go b/cc/compiler.go
index fbe10b5..0aee0bd 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -250,8 +250,8 @@
return false
}
-func addToModuleList(ctx ModuleContext, list string, module string) {
- getNamedMapForConfig(ctx.Config(), list).Store(module, true)
+func addToModuleList(ctx ModuleContext, key android.OnceKey, module string) {
+ getNamedMapForConfig(ctx.Config(), key).Store(module, true)
}
// Create a Flags struct that collects the compile flags from global values,
@@ -503,10 +503,10 @@
if len(compiler.Properties.Srcs) > 0 {
module := ctx.ModuleDir() + "/Android.bp:" + ctx.ModuleName()
if inList("-Wno-error", flags.CFlags) || inList("-Wno-error", flags.CppFlags) {
- addToModuleList(ctx, modulesUsingWnoError, module)
+ addToModuleList(ctx, modulesUsingWnoErrorKey, module)
} else if !inList("-Werror", flags.CFlags) && !inList("-Werror", flags.CppFlags) {
if warningsAreAllowed(ctx.ModuleDir()) {
- addToModuleList(ctx, modulesAddedWall, module)
+ addToModuleList(ctx, modulesAddedWallKey, module)
flags.CFlags = append([]string{"-Wall"}, flags.CFlags...)
} else {
flags.CFlags = append([]string{"-Wall", "-Werror"}, flags.CFlags...)