From 0ea4ffac9a0ed6ee0e73e4112645cfc224b06e82 Mon Sep 17 00:00:00 2001 From: Vinh Tran Date: Fri, 11 Aug 2023 17:29:33 -0400 Subject: [PATCH] Add test mode support for rust_aconfig_library Test: atest aconfig.test_mode.test.rust Change-Id: I3ef774bdc0f8b842106367c91221a2c227585c75 --- aconfig/rust_aconfig_library.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aconfig/rust_aconfig_library.go b/aconfig/rust_aconfig_library.go index 8b1637273..de41776a3 100644 --- a/aconfig/rust_aconfig_library.go +++ b/aconfig/rust_aconfig_library.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/google/blueprint" + "github.com/google/blueprint/proptools" ) type rustDeclarationsTagType struct { @@ -17,6 +18,7 @@ var rustDeclarationsTag = rustDeclarationsTagType{} type RustAconfigLibraryProperties struct { // name of the aconfig_declarations module to generate a library for Aconfig_declarations string + Test *bool } type aconfigDecorator struct { @@ -58,6 +60,11 @@ func (a *aconfigDecorator) GenerateSource(ctx rust.ModuleContext, deps rust.Path } declarations := ctx.OtherModuleProvider(declarationsModules[0], declarationsProviderKey).(declarationsProviderData) + mode := "production" + if proptools.Bool(a.Properties.Test) { + mode = "test" + } + ctx.Build(pctx, android.BuildParams{ Rule: rustRule, Input: declarations.IntermediatePath, @@ -67,8 +74,7 @@ func (a *aconfigDecorator) GenerateSource(ctx rust.ModuleContext, deps rust.Path Description: "rust_aconfig_library", Args: map[string]string{ "gendir": generatedDir.String(), - // TODO: Add test mode - "mode": "production", + "mode": mode, }, }) a.BaseSourceProvider.OutputFiles = android.Paths{generatedSource}