Add filename_from_src property to prebuilt_etc

Base name of the output file of a prebuilt_etc is by default the module
name. This default behavior can be customized by either via the
'filename' property or the new 'filename_from_src' property. The former
explicitly sets the base name while the latter makes the file name to be
that of the source file.

Test: m (prebuilt_etc_test added)
Change-Id: Ic2900417bda62993f6de2612d993234b82b74479
This commit is contained in:
Jiyong Park
2018-11-13 11:59:12 +09:00
parent 2fcac47e9d
commit 1a7cf08ebb
2 changed files with 37 additions and 1 deletions

View File

@@ -106,3 +106,27 @@ func TestPrebuiltEtcOutputPath(t *testing.T) {
t.Errorf("expected foo.installed.conf, got %q", p.outputFilePath.Base())
}
}
func TestPrebuiltEtcGlob(t *testing.T) {
ctx := testPrebuiltEtc(t, `
prebuilt_etc {
name: "my_foo",
src: "foo.*",
}
prebuilt_etc {
name: "my_bar",
src: "bar.*",
filename_from_src: true,
}
`)
p := ctx.ModuleForTests("my_foo", "android_common_core").Module().(*PrebuiltEtc)
if p.outputFilePath.Base() != "my_foo" {
t.Errorf("expected my_foo, got %q", p.outputFilePath.Base())
}
p = ctx.ModuleForTests("my_bar", "android_common_core").Module().(*PrebuiltEtc)
if p.outputFilePath.Base() != "bar.conf" {
t.Errorf("expected bar.conf, got %q", p.outputFilePath.Base())
}
}