Add "exported" mode to xx_aconfig_library build rules
Test: added unit tests and CI
Bug: 309990433
Change-Id: Iae1b85265d9780bde7d41ec2ec6e8e441c2b3814
diff --git a/aconfig/rust_aconfig_library.go b/aconfig/rust_aconfig_library.go
index 71918dd..43078b6 100644
--- a/aconfig/rust_aconfig_library.go
+++ b/aconfig/rust_aconfig_library.go
@@ -1,9 +1,10 @@
package aconfig
import (
+ "fmt"
+
"android/soong/android"
"android/soong/rust"
- "fmt"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -18,7 +19,16 @@
type RustAconfigLibraryProperties struct {
// name of the aconfig_declarations module to generate a library for
Aconfig_declarations string
- Test *bool
+
+ // whether to generate test mode version of the library
+ // TODO: remove "Test" property when "Mode" can be used in all the branches
+ Test *bool
+
+ // default mode is "production", the other accepted modes are:
+ // "test": to generate test mode version of the library
+ // "exported": to generate exported mode version of the library
+ // an error will be thrown if the mode is not supported
+ Mode *string
}
type aconfigDecorator struct {
@@ -60,7 +70,15 @@
}
declarations := ctx.OtherModuleProvider(declarationsModules[0], declarationsProviderKey).(declarationsProviderData)
- mode := "production"
+ if a.Properties.Mode != nil && a.Properties.Test != nil {
+ ctx.PropertyErrorf("test", "test prop should not be specified when mode prop is set")
+ }
+ mode := proptools.StringDefault(a.Properties.Mode, "production")
+ if !isModeSupported(mode) {
+ ctx.PropertyErrorf("mode", "%q is not a supported mode", mode)
+ }
+
+ // TODO: remove "Test" property
if proptools.Bool(a.Properties.Test) {
mode = "test"
}