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
This commit is contained in:
Dennis Shen
2024-01-10 14:07:35 +00:00
parent 2127887e32
commit c6dc551097
2 changed files with 39 additions and 2 deletions

View File

@@ -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

View File

@@ -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)
}