diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go index 42c7c2c6f..e1803427c 100644 --- a/android/prebuilt_etc.go +++ b/android/prebuilt_etc.go @@ -145,6 +145,9 @@ func (p *PrebuiltEtc) AndroidMk() AndroidMkData { fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) fmt.Fprintln(w, "LOCAL_MODULE :=", name+nameSuffix) fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") + if p.commonProperties.Owner != nil { + fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", *p.commonProperties.Owner) + } fmt.Fprintln(w, "LOCAL_MODULE_TAGS := optional") fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", p.outputFilePath.String()) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString()) diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go index 8ab978b88..d1a80af9f 100644 --- a/android/prebuilt_etc_test.go +++ b/android/prebuilt_etc_test.go @@ -15,8 +15,11 @@ package android import ( + "bufio" + "bytes" "io/ioutil" "os" + "strings" "testing" ) @@ -130,3 +133,47 @@ func TestPrebuiltEtcGlob(t *testing.T) { t.Errorf("expected bar.conf, got %q", p.outputFilePath.Base()) } } + +func TestPrebuiltEtcAndroidMk(t *testing.T) { + ctx := testPrebuiltEtc(t, ` + prebuilt_etc { + name: "foo", + src: "foo.conf", + owner: "abc", + filename_from_src: true, + } + `) + + data := AndroidMkData{} + data.Required = append(data.Required, "modA", "moduleB") + + expected := map[string]string{ + "LOCAL_MODULE": "foo", + "LOCAL_MODULE_CLASS": "ETC", + "LOCAL_MODULE_OWNER": "abc", + "LOCAL_INSTALLED_MODULE_STEM": "foo.conf", + "LOCAL_REQUIRED_MODULES": "modA moduleB", + } + + mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) + buf := &bytes.Buffer{} + mod.AndroidMk().Custom(buf, "foo", "", "", data) + for k, expected := range expected { + found := false + scanner := bufio.NewScanner(bytes.NewReader(buf.Bytes())) + for scanner.Scan() { + line := scanner.Text() + tok := strings.Split(line, " := ") + if tok[0] == k { + found = true + if tok[1] != expected { + t.Errorf("Incorrect %s '%s', expected '%s'", k, tok[1], expected) + } + } + } + + if !found { + t.Errorf("No %s defined, saw %s", k, buf.String()) + } + } +}