fix: prebuilt_etc_xml
Since aosp/872653 and aosp/904233 landed, prebuilt_etc_xml has been broken. aosp/872653: Enable arch variant properties in prebuilt_etc. aosp/904233: Add a prebuilt module type for usr/share. This change fixes 1) pass baseDir "etc" to initialize PrebuiltEtc struct 2) change "multlib" argument to MultilibFirst to reflect aosp/872653 Bug: 138082739 Test: m com.google.vr.platform.xml && see if it is installed in /system/etc Change-Id: I4802107fd8ccf28a1170d7d165700c92df32e341
This commit is contained in:
@@ -71,10 +71,6 @@ func (p *prebuiltEtcXml) timestampFilePath(ctx android.ModuleContext) android.Wr
|
||||
return android.PathForModuleOut(ctx, p.PrebuiltEtc.SourceFilePath(ctx).Base()+"-timestamp")
|
||||
}
|
||||
|
||||
func (p *prebuiltEtcXml) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
p.PrebuiltEtc.DepsMutator(ctx)
|
||||
}
|
||||
|
||||
func (p *prebuiltEtcXml) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
p.PrebuiltEtc.GenerateAndroidBuildActions(ctx)
|
||||
|
||||
@@ -125,9 +121,8 @@ func (p *prebuiltEtcXml) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
||||
func PrebuiltEtcXmlFactory() android.Module {
|
||||
module := &prebuiltEtcXml{}
|
||||
module.AddProperties(&module.properties)
|
||||
|
||||
android.InitPrebuiltEtcModule(&module.PrebuiltEtc)
|
||||
android.InitPrebuiltEtcModule(&module.PrebuiltEtc, "etc")
|
||||
// This module is device-only
|
||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
||||
return module
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ func testXml(t *testing.T, bp string) *android.TestContext {
|
||||
"foo.dtd": nil,
|
||||
"bar.xml": nil,
|
||||
"bar.xsd": nil,
|
||||
"baz.xml": nil,
|
||||
}
|
||||
ctx.MockFileSystem(mockFiles)
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
@@ -59,6 +60,13 @@ func teardown(buildDir string) {
|
||||
os.RemoveAll(buildDir)
|
||||
}
|
||||
|
||||
func assertEqual(t *testing.T, name, expected, actual string) {
|
||||
t.Helper()
|
||||
if expected != actual {
|
||||
t.Errorf(name+" expected %q != got %q", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
// Minimal test
|
||||
func TestPrebuiltEtcXml(t *testing.T) {
|
||||
ctx := testXml(t, `
|
||||
@@ -72,15 +80,28 @@ func TestPrebuiltEtcXml(t *testing.T) {
|
||||
src: "bar.xml",
|
||||
schema: "bar.xsd",
|
||||
}
|
||||
prebuilt_etc_xml {
|
||||
name: "baz.xml",
|
||||
src: "baz.xml",
|
||||
}
|
||||
`)
|
||||
|
||||
xmllint := ctx.ModuleForTests("foo.xml", "android_common").Rule("xmllint")
|
||||
input := xmllint.Input.String()
|
||||
if input != "foo.xml" {
|
||||
t.Errorf("input expected %q != got %q", "foo.xml", input)
|
||||
}
|
||||
schema := xmllint.Args["dtd"]
|
||||
if schema != "foo.dtd" {
|
||||
t.Errorf("dtd expected %q != got %q", "foo.dtdl", schema)
|
||||
for _, tc := range []struct {
|
||||
rule, input, schemaType, schema string
|
||||
}{
|
||||
{rule: "xmllint-dtd", input: "foo.xml", schemaType: "dtd", schema: "foo.dtd"},
|
||||
{rule: "xmllint-xsd", input: "bar.xml", schemaType: "xsd", schema: "bar.xsd"},
|
||||
{rule: "xmllint-minimal", input: "baz.xml"},
|
||||
} {
|
||||
t.Run(tc.schemaType, func(t *testing.T) {
|
||||
rule := ctx.ModuleForTests(tc.input, "android_arm64_armv8-a").Rule(tc.rule)
|
||||
assertEqual(t, "input", tc.input, rule.Input.String())
|
||||
if tc.schemaType != "" {
|
||||
assertEqual(t, "schema", tc.schema, rule.Args[tc.schemaType])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
m := ctx.ModuleForTests("foo.xml", "android_arm64_armv8-a").Module().(*prebuiltEtcXml)
|
||||
assertEqual(t, "installDir", "target/product/test_device/system/etc", m.InstallDirPath().RelPathString())
|
||||
}
|
||||
|
Reference in New Issue
Block a user