From c6dc551097865daf6a8daf6cc2a8a6fc1e670ba6 Mon Sep 17 00:00:00 2001 From: Dennis Shen Date: Wed, 10 Jan 2024 14:07:35 +0000 Subject: [PATCH] do not include sever_configurable_flags dependency when in force-read-only-mode Bug: b/316932568 Test: m --no-skip-soong-tests nothing Change-Id: I02a7925dd6b5b33107dae1507447f8e7a1991795 --- aconfig/codegen/cc_aconfig_library.go | 8 ++++-- aconfig/codegen/cc_aconfig_library_test.go | 33 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go index 8df353d4d..50cd4de20 100644 --- a/aconfig/codegen/cc_aconfig_library.go +++ b/aconfig/codegen/cc_aconfig_library.go @@ -77,8 +77,12 @@ func (this *CcAconfigLibraryCallbacks) GeneratorDeps(ctx cc.DepsContext, deps cc ctx.AddDependency(ctx.Module(), ccDeclarationsTag, declarations) } - // Add a dependency for the aconfig flags base library - deps.SharedLibs = append(deps.SharedLibs, baseLibDep) + mode := proptools.StringDefault(this.properties.Mode, "production") + + // Add a dependency for the aconfig flags base library if it is not forced read only + if mode != "force-read-only" { + deps.SharedLibs = append(deps.SharedLibs, baseLibDep) + } // TODO: It'd be really nice if we could reexport this library and not make everyone do it. return deps diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go index d762e9bfe..ef92cc871 100644 --- a/aconfig/codegen/cc_aconfig_library_test.go +++ b/aconfig/codegen/cc_aconfig_library_test.go @@ -20,6 +20,8 @@ import ( "android/soong/android" "android/soong/cc" + + "github.com/google/blueprint" ) var ccCodegenModeTestData = []struct { @@ -164,3 +166,34 @@ func TestAndroidMkCcLibrary(t *testing.T) { android.AssertIntEquals(t, "len(LOCAL_ACONFIG_FILES)", 1, len(makeVar)) android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_foo/intermediate.pb") } + +func TestForceReadOnly(t *testing.T) { + t.Helper() + result := android.GroupFixturePreparers( + PrepareForTestWithAconfigBuildComponents, + cc.PrepareForTestWithCcDefaultModules). + ExtendWithErrorHandler(android.FixtureExpectsNoErrors). + RunTestWithBp(t, fmt.Sprintf(` + aconfig_declarations { + name: "my_aconfig_declarations", + package: "com.example.package", + srcs: ["foo.aconfig"], + } + + cc_aconfig_library { + name: "my_cc_aconfig_library", + aconfig_declarations: "my_aconfig_declarations", + mode: "force-read-only", + } + `)) + + module := result.ModuleForTests("my_cc_aconfig_library", "android_arm64_armv8-a_shared").Module() + dependOnBaseLib := false + result.VisitDirectDeps(module, func(dep blueprint.Module) { + if dep.Name() == baseLibDep { + dependOnBaseLib = true + } + }) + android.AssertBoolEquals(t, "should not have dependency on server_configuriable_flags", + dependOnBaseLib, false) +}