summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mårten Kongstad <amhk@google.com> 2025-01-16 10:11:06 +0100
committer Mårten Kongstad <amhk@google.com> 2025-01-17 09:21:51 +0100
commit81050fa3eb70a3be150a61d8dd48aa3c0527891b (patch)
tree40c235aed8b5e0bc948cacfd404aea812b3550bf
parenta2c4c09e6f8b0a63347f2fa0a9028535e3dc88e4 (diff)
all_aconfig_declarations: convert to SingletonModule
This will be needed for an upcoming change. Also remove the TestTwoAconfigDeclarationsPerPackage test -- now that all_aconfig_declarations is a module, it is (technically) no longer an error to find more than one all_aconfig_declarations module. Bug: 377676163 Test: m all_aconfig_declarations Change-Id: I0388f52dc7b6a1b0338238a2163f43807e08f747
-rw-r--r--aconfig/Android.bp5
-rw-r--r--aconfig/all_aconfig_declarations.go13
-rw-r--r--aconfig/all_aconfig_declarations_test.go48
-rw-r--r--aconfig/init.go2
4 files changed, 15 insertions, 53 deletions
diff --git a/aconfig/Android.bp b/aconfig/Android.bp
index 402cf1649..1fe417e7a 100644
--- a/aconfig/Android.bp
+++ b/aconfig/Android.bp
@@ -25,7 +25,10 @@ bootstrap_go_package {
"aconfig_declarations_test.go",
"aconfig_values_test.go",
"aconfig_value_set_test.go",
- "all_aconfig_declarations_test.go",
],
pluginFor: ["soong_build"],
}
+
+all_aconfig_declarations {
+ name: "all_aconfig_declarations",
+}
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go
index 3262493c3..05cb065cc 100644
--- a/aconfig/all_aconfig_declarations.go
+++ b/aconfig/all_aconfig_declarations.go
@@ -28,8 +28,10 @@ import (
// Note that this is ALL aconfig_declarations modules present in the tree, not just
// ones that are relevant to the product currently being built, so that that infra
// doesn't need to pull from multiple builds and merge them.
-func AllAconfigDeclarationsFactory() android.Singleton {
- return &allAconfigDeclarationsSingleton{releaseMap: make(map[string]allAconfigReleaseDeclarationsSingleton)}
+func AllAconfigDeclarationsFactory() android.SingletonModule {
+ module := &allAconfigDeclarationsSingleton{releaseMap: make(map[string]allAconfigReleaseDeclarationsSingleton)}
+ android.InitAndroidModule(module)
+ return module
}
type allAconfigReleaseDeclarationsSingleton struct {
@@ -38,6 +40,8 @@ type allAconfigReleaseDeclarationsSingleton struct {
}
type allAconfigDeclarationsSingleton struct {
+ android.SingletonModuleBase
+
releaseMap map[string]allAconfigReleaseDeclarationsSingleton
}
@@ -50,7 +54,10 @@ func (this *allAconfigDeclarationsSingleton) sortedConfigNames() []string {
return names
}
-func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+func (this *allAconfigDeclarationsSingleton) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+}
+
+func (this *allAconfigDeclarationsSingleton) GenerateSingletonBuildActions(ctx android.SingletonContext) {
for _, rcName := range append([]string{""}, ctx.Config().ReleaseAconfigExtraReleaseConfigs()...) {
// Find all of the aconfig_declarations modules
var packages = make(map[string]int)
diff --git a/aconfig/all_aconfig_declarations_test.go b/aconfig/all_aconfig_declarations_test.go
deleted file mode 100644
index 0b2021e7b..000000000
--- a/aconfig/all_aconfig_declarations_test.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2024 Google Inc. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package aconfig
-
-import (
- "testing"
-
- "android/soong/android"
-)
-
-func TestTwoAconfigDeclarationsPerPackage(t *testing.T) {
- bp := `
- aconfig_declarations {
- name: "module_name.foo",
- package: "com.example.package",
- container: "com.android.foo",
- srcs: [
- "foo.aconfig",
- ],
- }
-
- aconfig_declarations {
- name: "module_name.bar",
- package: "com.example.package",
- container: "com.android.foo",
- srcs: [
- "bar.aconfig",
- ],
- }
- `
- errMsg := "Only one aconfig_declarations allowed for each package."
- android.GroupFixturePreparers(
- PrepareForTestWithAconfigBuildComponents).
- ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(errMsg)).
- RunTestWithBp(t, bp)
-}
diff --git a/aconfig/init.go b/aconfig/init.go
index ab6ee46d0..519d50264 100644
--- a/aconfig/init.go
+++ b/aconfig/init.go
@@ -118,6 +118,6 @@ func RegisterBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("aconfig_declarations", DeclarationsFactory)
ctx.RegisterModuleType("aconfig_values", ValuesFactory)
ctx.RegisterModuleType("aconfig_value_set", ValueSetFactory)
- ctx.RegisterParallelSingletonType("all_aconfig_declarations", AllAconfigDeclarationsFactory)
+ ctx.RegisterSingletonModuleType("all_aconfig_declarations", AllAconfigDeclarationsFactory)
ctx.RegisterParallelSingletonType("exported_java_aconfig_library", ExportedJavaDeclarationsLibraryFactory)
}