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
diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go
index 1ecdf79..27736ba 100644
--- a/android/prebuilt_etc_test.go
+++ b/android/prebuilt_etc_test.go
@@ -106,3 +106,27 @@
 		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())
+	}
+}