Add ctx to AndroidMkExtraEntriesFunc
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to access providers. Test: m checkbuild Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc Merged-In: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
This commit is contained in:
@@ -354,7 +354,7 @@ func ensureListNotEmpty(t *testing.T, result []string) {
|
||||
|
||||
// Minimal test
|
||||
func TestBasicApex(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex_defaults {
|
||||
name: "myapex-defaults",
|
||||
manifest: ":myapex.manifest",
|
||||
@@ -562,7 +562,7 @@ func TestBasicApex(t *testing.T) {
|
||||
|
||||
// Make sure that Android.mk is created
|
||||
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", ab)
|
||||
data := android.AndroidMkDataForTest(t, ctx, ab)
|
||||
var builder strings.Builder
|
||||
data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data)
|
||||
|
||||
@@ -2508,7 +2508,7 @@ func TestUseVendorFailsIfNotVendorAvailable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVendorApex(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -2539,7 +2539,7 @@ func TestVendorApex(t *testing.T) {
|
||||
})
|
||||
|
||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||
name := apexBundle.BaseModuleName()
|
||||
prefix := "TARGET_"
|
||||
var builder strings.Builder
|
||||
@@ -2643,7 +2643,7 @@ func TestApex_withPrebuiltFirmware(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAndroidMk_UseVendorRequired(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -2667,7 +2667,7 @@ func TestAndroidMk_UseVendorRequired(t *testing.T) {
|
||||
})
|
||||
|
||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||
name := apexBundle.BaseModuleName()
|
||||
prefix := "TARGET_"
|
||||
var builder strings.Builder
|
||||
@@ -2677,7 +2677,7 @@ func TestAndroidMk_UseVendorRequired(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAndroidMk_VendorApexRequired(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -2698,7 +2698,7 @@ func TestAndroidMk_VendorApexRequired(t *testing.T) {
|
||||
`)
|
||||
|
||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||
name := apexBundle.BaseModuleName()
|
||||
prefix := "TARGET_"
|
||||
var builder strings.Builder
|
||||
@@ -2708,7 +2708,7 @@ func TestAndroidMk_VendorApexRequired(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAndroidMkWritesCommonProperties(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -2726,7 +2726,7 @@ func TestAndroidMkWritesCommonProperties(t *testing.T) {
|
||||
`)
|
||||
|
||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||
name := apexBundle.BaseModuleName()
|
||||
prefix := "TARGET_"
|
||||
var builder strings.Builder
|
||||
@@ -3799,7 +3799,7 @@ func TestDependenciesInApexManifest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApexName(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -3832,7 +3832,7 @@ func TestApexName(t *testing.T) {
|
||||
ensureContains(t, apexRule.Args["opt_flags"], "--do_not_check_keyname")
|
||||
|
||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||
name := apexBundle.BaseModuleName()
|
||||
prefix := "TARGET_"
|
||||
var builder strings.Builder
|
||||
@@ -4336,7 +4336,7 @@ func TestPrebuiltFilenameOverride(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrebuiltOverrides(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
prebuilt_apex {
|
||||
name: "myapex.prebuilt",
|
||||
src: "myapex-arm.apex",
|
||||
@@ -4349,7 +4349,7 @@ func TestPrebuiltOverrides(t *testing.T) {
|
||||
p := ctx.ModuleForTests("myapex.prebuilt", "android_common").Module().(*Prebuilt)
|
||||
|
||||
expected := []string{"myapex"}
|
||||
actual := android.AndroidMkEntriesForTest(t, config, "", p)[0].EntryMap["LOCAL_OVERRIDES_MODULES"]
|
||||
actual := android.AndroidMkEntriesForTest(t, ctx, p)[0].EntryMap["LOCAL_OVERRIDES_MODULES"]
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("Incorrect LOCAL_OVERRIDES_MODULES value '%s', expected '%s'", actual, expected)
|
||||
}
|
||||
@@ -4708,7 +4708,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApexWithTests(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex_test {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -4796,7 +4796,7 @@ func TestApexWithTests(t *testing.T) {
|
||||
|
||||
// Ensure the module is correctly translated.
|
||||
bundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", bundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, bundle)
|
||||
name := bundle.BaseModuleName()
|
||||
prefix := "TARGET_"
|
||||
var builder strings.Builder
|
||||
@@ -4811,7 +4811,7 @@ func TestApexWithTests(t *testing.T) {
|
||||
ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
|
||||
|
||||
flatBundle := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle)
|
||||
data = android.AndroidMkDataForTest(t, config, "", flatBundle)
|
||||
data = android.AndroidMkDataForTest(t, ctx, flatBundle)
|
||||
data.Custom(&builder, name, prefix, "", data)
|
||||
flatAndroidMk := builder.String()
|
||||
ensureContainsOnce(t, flatAndroidMk, "LOCAL_TEST_DATA := :baz :bar/baz\n")
|
||||
@@ -4819,7 +4819,7 @@ func TestApexWithTests(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInstallExtraFlattenedApexes(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -4834,7 +4834,7 @@ func TestInstallExtraFlattenedApexes(t *testing.T) {
|
||||
})
|
||||
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
ensureListContains(t, ab.requiredDeps, "myapex.flattened")
|
||||
mk := android.AndroidMkDataForTest(t, config, "", ab)
|
||||
mk := android.AndroidMkDataForTest(t, ctx, ab)
|
||||
var builder strings.Builder
|
||||
mk.Custom(&builder, ab.Name(), "TARGET_", "", mk)
|
||||
androidMk := builder.String()
|
||||
@@ -5382,7 +5382,7 @@ func TestApexAvailable_CreatedForApex(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOverrideApex(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -5450,7 +5450,7 @@ func TestOverrideApex(t *testing.T) {
|
||||
optFlags := apexRule.Args["opt_flags"]
|
||||
ensureContains(t, optFlags, "--override_apk_package_name test.overridden.package")
|
||||
|
||||
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||
var builder strings.Builder
|
||||
data.Custom(&builder, name, "TARGET_", "", data)
|
||||
androidMk := builder.String()
|
||||
@@ -5838,7 +5838,7 @@ func TestRejectNonInstallableJavaLibrary(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCarryRequiredModuleNames(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -5864,7 +5864,7 @@ func TestCarryRequiredModuleNames(t *testing.T) {
|
||||
`)
|
||||
|
||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||
name := apexBundle.BaseModuleName()
|
||||
prefix := "TARGET_"
|
||||
var builder strings.Builder
|
||||
@@ -6005,7 +6005,7 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSymlinksFromApexToSystemRequiredModuleNames(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -6043,7 +6043,7 @@ func TestSymlinksFromApexToSystemRequiredModuleNames(t *testing.T) {
|
||||
`)
|
||||
|
||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||
var builder strings.Builder
|
||||
data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
|
||||
androidMk := builder.String()
|
||||
@@ -6728,7 +6728,7 @@ func intPtr(i int) *int {
|
||||
}
|
||||
|
||||
func TestApexSet(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex_set {
|
||||
name: "myapex",
|
||||
set: "myapex.apks",
|
||||
@@ -6760,7 +6760,7 @@ func TestApexSet(t *testing.T) {
|
||||
|
||||
a := m.Module().(*ApexSet)
|
||||
expectedOverrides := []string{"foo"}
|
||||
actualOverrides := android.AndroidMkEntriesForTest(t, config, "", a)[0].EntryMap["LOCAL_OVERRIDES_MODULES"]
|
||||
actualOverrides := android.AndroidMkEntriesForTest(t, ctx, a)[0].EntryMap["LOCAL_OVERRIDES_MODULES"]
|
||||
if !reflect.DeepEqual(actualOverrides, expectedOverrides) {
|
||||
t.Errorf("Incorrect LOCAL_OVERRIDES_MODULES - expected %q vs actual %q", expectedOverrides, actualOverrides)
|
||||
}
|
||||
@@ -6933,7 +6933,7 @@ func TestNonPreferredPrebuiltDependency(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompressedApex(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -6959,7 +6959,7 @@ func TestCompressedApex(t *testing.T) {
|
||||
ensureContains(t, ab.outputFile.String(), "myapex.capex")
|
||||
|
||||
// Verify android.mk rules
|
||||
data := android.AndroidMkDataForTest(t, config, "", ab)
|
||||
data := android.AndroidMkDataForTest(t, ctx, ab)
|
||||
var builder strings.Builder
|
||||
data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data)
|
||||
androidMk := builder.String()
|
||||
@@ -6967,7 +6967,7 @@ func TestCompressedApex(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPreferredPrebuiltSharedLibDep(t *testing.T) {
|
||||
ctx, config := testApex(t, `
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
@@ -7007,7 +7007,7 @@ func TestPreferredPrebuiltSharedLibDep(t *testing.T) {
|
||||
`)
|
||||
|
||||
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||
data := android.AndroidMkDataForTest(t, config, "", ab)
|
||||
data := android.AndroidMkDataForTest(t, ctx, ab)
|
||||
var builder strings.Builder
|
||||
data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data)
|
||||
androidMk := builder.String()
|
||||
@@ -7159,7 +7159,7 @@ func TestPrebuiltStubLibDep(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
for _, otherApexEnabled := range test.otherApexEnabled {
|
||||
t.Run("otherapex_enabled_"+otherApexEnabled, func(t *testing.T) {
|
||||
ctx, config := testApex(t, fmt.Sprintf(bpBase, otherApexEnabled)+test.stublibBp)
|
||||
ctx, _ := testApex(t, fmt.Sprintf(bpBase, otherApexEnabled)+test.stublibBp)
|
||||
|
||||
type modAndMkEntries struct {
|
||||
mod *cc.Module
|
||||
@@ -7177,7 +7177,7 @@ func TestPrebuiltStubLibDep(t *testing.T) {
|
||||
if !mod.Enabled() || mod.IsHideFromMake() {
|
||||
continue
|
||||
}
|
||||
for _, ent := range android.AndroidMkEntriesForTest(t, config, "", mod) {
|
||||
for _, ent := range android.AndroidMkEntriesForTest(t, ctx, mod) {
|
||||
if ent.Disabled {
|
||||
continue
|
||||
}
|
||||
|
Reference in New Issue
Block a user