apex: AndroidMk writes common properties

AndroidMkEntries handles bunch of common properties(e.g. LOCAL_INIT_RC,
LOCAL_VINTF_FRAGMENTS, etc).

However apex defines its own Custom() writer, so those properties should
be handled manually.

For example, when an apex defines "init_rc" properties, the value should
be passed to Make via LOCAL_INIT_RC.

Bug: 159211312
Test: m
Change-Id: I65e7a456486c9f5fe70c91b78ff181425035fcf2
This commit is contained in:
Jooyung Han
2020-06-24 23:26:26 +09:00
parent dd85fd89b0
commit 2ed99d00b4
3 changed files with 53 additions and 19 deletions

View File

@@ -58,7 +58,7 @@ type AndroidMkData struct {
Extra []AndroidMkExtraFunc
preamble bytes.Buffer
Entries AndroidMkEntries
}
type AndroidMkExtraFunc func(w io.Writer, outputFile Path)
@@ -427,7 +427,7 @@ func translateGoBinaryModule(ctx SingletonContext, w io.Writer, mod blueprint.Mo
func (data *AndroidMkData) fillInData(config Config, bpPath string, mod blueprint.Module) {
// Get the preamble content through AndroidMkEntries logic.
entries := AndroidMkEntries{
data.Entries = AndroidMkEntries{
Class: data.Class,
SubName: data.SubName,
DistFile: data.DistFile,
@@ -438,16 +438,12 @@ func (data *AndroidMkData) fillInData(config Config, bpPath string, mod blueprin
Host_required: data.Host_required,
Target_required: data.Target_required,
}
entries.fillInEntries(config, bpPath, mod)
// preamble doesn't need the footer content.
entries.footer = bytes.Buffer{}
entries.write(&data.preamble)
data.Entries.fillInEntries(config, bpPath, mod)
// copy entries back to data since it is used in Custom
data.Required = entries.Required
data.Host_required = entries.Host_required
data.Target_required = entries.Target_required
data.Required = data.Entries.Required
data.Host_required = data.Entries.Host_required
data.Target_required = data.Entries.Target_required
}
func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Module,
@@ -503,7 +499,9 @@ func WriteAndroidMkData(w io.Writer, data AndroidMkData) {
return
}
w.Write(data.preamble.Bytes())
// write preamble via Entries
data.Entries.footer = bytes.Buffer{}
data.Entries.write(w)
for _, extra := range data.Extra {
extra(w, data.OutputFile.Path())