diff options
author | Jooyung Han <jooyung@google.com> | 2019-07-22 15:48:36 +0900 |
---|---|---|
committer | Jooyung Han <jooyung@google.com> | 2019-07-22 16:15:25 +0900 |
commit | a0171822bea3ecf558df7dec78438410f5aa1b63 (patch) | |
tree | fe4ed91ac618294a603083e4568f30cf249c5abf | |
parent | 2ac2befc9ae5d461fda9434c553ee911fecaa4db (diff) | |
download | build_soong-a0171822bea3ecf558df7dec78438410f5aa1b63.tar.gz build_soong-a0171822bea3ecf558df7dec78438410f5aa1b63.tar.bz2 build_soong-a0171822bea3ecf558df7dec78438410f5aa1b63.zip |
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
-rw-r--r-- | android/prebuilt_etc.go | 32 | ||||
-rw-r--r-- | xml/xml.go | 9 | ||||
-rw-r--r-- | xml/xml_test.go | 37 |
3 files changed, 50 insertions, 28 deletions
diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go index 069e1f57..9722a254 100644 --- a/android/prebuilt_etc.go +++ b/android/prebuilt_etc.go @@ -91,6 +91,10 @@ func (p *PrebuiltEtc) SourceFilePath(ctx ModuleContext) Path { return PathForModuleSrc(ctx, String(p.properties.Src)) } +func (p *PrebuiltEtc) InstallDirPath() OutputPath { + return p.installDirPath +} + // This allows other derivative modules (e.g. prebuilt_etc_xml) to perform // additional steps (like validating the src) before the file is installed. func (p *PrebuiltEtc) SetAdditionalDependencies(paths Paths) { @@ -165,15 +169,16 @@ func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries { } } -func InitPrebuiltEtcModule(p *PrebuiltEtc) { +func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) { + p.installDirBase = dirBase p.AddProperties(&p.properties) } // prebuilt_etc is for a prebuilt artifact that is installed in // <partition>/etc/<sub_dir> directory. func PrebuiltEtcFactory() Module { - module := &PrebuiltEtc{installDirBase: "etc"} - InitPrebuiltEtcModule(module) + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "etc") // This module is device-only InitAndroidArchModule(module, DeviceSupported, MultilibFirst) return module @@ -182,8 +187,8 @@ func PrebuiltEtcFactory() Module { // prebuilt_etc_host is for a host prebuilt artifact that is installed in // $(HOST_OUT)/etc/<sub_dir> directory. func PrebuiltEtcHostFactory() Module { - module := &PrebuiltEtc{installDirBase: "etc"} - InitPrebuiltEtcModule(module) + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "etc") // This module is host-only InitAndroidArchModule(module, HostSupported, MultilibCommon) return module @@ -192,8 +197,8 @@ func PrebuiltEtcHostFactory() Module { // prebuilt_usr_share is for a prebuilt artifact that is installed in // <partition>/usr/share/<sub_dir> directory. func PrebuiltUserShareFactory() Module { - module := &PrebuiltEtc{installDirBase: "usr/share"} - InitPrebuiltEtcModule(module) + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "usr/share") // This module is device-only InitAndroidArchModule(module, DeviceSupported, MultilibFirst) return module @@ -202,8 +207,8 @@ func PrebuiltUserShareFactory() Module { // prebuild_usr_share_host is for a host prebuilt artifact that is installed in // $(HOST_OUT)/usr/share/<sub_dir> directory. func PrebuiltUserShareHostFactory() Module { - module := &PrebuiltEtc{installDirBase: "usr/share"} - InitPrebuiltEtcModule(module) + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "usr/share") // This module is host-only InitAndroidArchModule(module, HostSupported, MultilibCommon) return module @@ -254,8 +259,8 @@ func prebuiltEtcMutator(mctx BottomUpMutatorContext) { // prebuilt_font installs a font in <partition>/fonts directory. func PrebuiltFontFactory() Module { - module := &PrebuiltEtc{installDirBase: "fonts"} - InitPrebuiltEtcModule(module) + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "fonts") // This module is device-only InitAndroidArchModule(module, DeviceSupported, MultilibFirst) return module @@ -265,8 +270,9 @@ func PrebuiltFontFactory() Module { // If soc_specific property is set to true, the firmware file is installed to the vendor <partition>/firmware // directory for vendor image. func PrebuiltFirmwareFactory() Module { - module := &PrebuiltEtc{installDirBase: "etc/firmware", socInstallDirBase: "firmware"} - InitPrebuiltEtcModule(module) + module := &PrebuiltEtc{} + module.socInstallDirBase = "firmware" + InitPrebuiltEtcModule(module, "etc/firmware") // This module is device-only InitAndroidArchModule(module, DeviceSupported, MultilibFirst) return module @@ -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 } diff --git a/xml/xml_test.go b/xml/xml_test.go index e8fa49c2..ae3e9fe3 100644 --- a/xml/xml_test.go +++ b/xml/xml_test.go @@ -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()) } |