Add ctx to AndroidMkExtraEntriesFunc
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to
access providers.
Bug: 180540739
Test: m checkbuild
Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index d538ce4..ff548e5 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -98,7 +98,7 @@
Class: "ETC",
OutputFile: android.OptionalPathForPath(l.outputFilePath),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
- func(entries *android.AndroidMkEntries) {
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_PATH", l.installDirPath.ToMakePath().String())
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", l.outputFilePath.Base())
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !installable)
diff --git a/linkerconfig/linkerconfig_test.go b/linkerconfig/linkerconfig_test.go
index 01f4657..8eed4b5 100644
--- a/linkerconfig/linkerconfig_test.go
+++ b/linkerconfig/linkerconfig_test.go
@@ -47,7 +47,7 @@
os.Exit(run())
}
-func testContext(t *testing.T, bp string) (*android.TestContext, android.Config) {
+func testContext(t *testing.T, bp string) *android.TestContext {
t.Helper()
fs := map[string][]byte{
@@ -65,11 +65,11 @@
_, errs = ctx.PrepareBuildActions(config)
android.FailIfErrored(t, errs)
- return ctx, config
+ return ctx
}
func TestBaseLinkerConfig(t *testing.T) {
- ctx, config := testContext(t, `
+ ctx := testContext(t, `
linker_config {
name: "linker-config-base",
src: "linker.config.json",
@@ -88,7 +88,7 @@
t.Errorf("expected linker.config.pb, got %q", p.outputFilePath.Base())
}
- entries := android.AndroidMkEntriesForTest(t, config, "", p)[0]
+ entries := android.AndroidMkEntriesForTest(t, ctx, p)[0]
for k, expectedValue := range expected {
if value, ok := entries.EntryMap[k]; ok {
if !reflect.DeepEqual(value, expectedValue) {
@@ -105,7 +105,7 @@
}
func TestUninstallableLinkerConfig(t *testing.T) {
- ctx, config := testContext(t, `
+ ctx := testContext(t, `
linker_config {
name: "linker-config-base",
src: "linker.config.json",
@@ -116,7 +116,7 @@
expected := []string{"true"}
p := ctx.ModuleForTests("linker-config-base", "android_arm64_armv8-a").Module().(*linkerConfig)
- entries := android.AndroidMkEntriesForTest(t, config, "", p)[0]
+ entries := android.AndroidMkEntriesForTest(t, ctx, p)[0]
if value, ok := entries.EntryMap["LOCAL_UNINSTALLABLE_MODULE"]; ok {
if !reflect.DeepEqual(value, expected) {
t.Errorf("LOCAL_UNINSTALLABLE_MODULE is expected to be true but %s", value)