|
@@ -43,9 +43,11 @@ type AndroidMkData struct {
|
|
|
OutputFile OptionalPath
|
|
|
Disabled bool
|
|
|
|
|
|
- Custom func(w io.Writer, name, prefix, moduleDir string)
|
|
|
+ Custom func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData)
|
|
|
|
|
|
Extra []AndroidMkExtraFunc
|
|
|
+
|
|
|
+ preamble bytes.Buffer
|
|
|
}
|
|
|
|
|
|
type AndroidMkExtraFunc func(w io.Writer, outputFile Path)
|
|
@@ -166,50 +168,32 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- if data.SubName != "" {
|
|
|
- name += data.SubName
|
|
|
- }
|
|
|
+ prefix := ""
|
|
|
+ if amod.ArchSpecific() {
|
|
|
+ switch amod.Os().Class {
|
|
|
+ case Host:
|
|
|
+ prefix = "HOST_"
|
|
|
+ case HostCross:
|
|
|
+ prefix = "HOST_CROSS_"
|
|
|
+ case Device:
|
|
|
+ prefix = "TARGET_"
|
|
|
|
|
|
- if data.Custom != nil {
|
|
|
- prefix := ""
|
|
|
- if amod.ArchSpecific() {
|
|
|
- switch amod.Os().Class {
|
|
|
- case Host:
|
|
|
- prefix = "HOST_"
|
|
|
- case HostCross:
|
|
|
- prefix = "HOST_CROSS_"
|
|
|
- case Device:
|
|
|
- prefix = "TARGET_"
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- config := ctx.Config().(Config)
|
|
|
- if amod.Arch().ArchType != config.Targets[amod.Os().Class][0].Arch.ArchType {
|
|
|
- prefix = "2ND_" + prefix
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- data.Custom(w, name, prefix, filepath.Dir(ctx.BlueprintFile(mod)))
|
|
|
-
|
|
|
- return nil
|
|
|
- }
|
|
|
-
|
|
|
- if data.Disabled {
|
|
|
- return nil
|
|
|
- }
|
|
|
-
|
|
|
- if !data.OutputFile.Valid() {
|
|
|
- return nil
|
|
|
+ config := ctx.Config().(Config)
|
|
|
+ if amod.Arch().ArchType != config.Targets[amod.Os().Class][0].Arch.ArchType {
|
|
|
+ prefix = "2ND_" + prefix
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
|
- fmt.Fprintln(w, "LOCAL_PATH :=", filepath.Dir(ctx.BlueprintFile(mod)))
|
|
|
- fmt.Fprintln(w, "LOCAL_MODULE :=", name)
|
|
|
- fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", data.Class)
|
|
|
- fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", data.OutputFile.String())
|
|
|
+ fmt.Fprintln(&data.preamble, "\ninclude $(CLEAR_VARS)")
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_PATH :=", filepath.Dir(ctx.BlueprintFile(mod)))
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_MODULE :=", name+data.SubName)
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_MODULE_CLASS :=", data.Class)
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_PREBUILT_MODULE_FILE :=", data.OutputFile.String())
|
|
|
|
|
|
if len(amod.commonProperties.Required) > 0 {
|
|
|
- fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(amod.commonProperties.Required, " "))
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_REQUIRED_MODULES := "+strings.Join(amod.commonProperties.Required, " "))
|
|
|
}
|
|
|
|
|
|
archStr := amod.Arch().ArchType.String()
|
|
@@ -218,48 +202,68 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
|
|
|
case Host:
|
|
|
// Make cannot identify LOCAL_MODULE_HOST_ARCH:= common.
|
|
|
if archStr != "common" {
|
|
|
- fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_MODULE_HOST_ARCH :=", archStr)
|
|
|
}
|
|
|
host = true
|
|
|
case HostCross:
|
|
|
// Make cannot identify LOCAL_MODULE_HOST_CROSS_ARCH:= common.
|
|
|
if archStr != "common" {
|
|
|
- fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
|
|
|
}
|
|
|
host = true
|
|
|
case Device:
|
|
|
// Make cannot identify LOCAL_MODULE_TARGET_ARCH:= common.
|
|
|
if archStr != "common" {
|
|
|
- fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
|
|
|
}
|
|
|
|
|
|
if len(amod.commonProperties.Logtags) > 0 {
|
|
|
- fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES := ", strings.Join(amod.commonProperties.Logtags, " "))
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_LOGTAGS_FILES := ", strings.Join(amod.commonProperties.Logtags, " "))
|
|
|
}
|
|
|
if len(amod.commonProperties.Init_rc) > 0 {
|
|
|
- fmt.Fprintln(w, "LOCAL_INIT_RC := ", strings.Join(amod.commonProperties.Init_rc, " "))
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_INIT_RC := ", strings.Join(amod.commonProperties.Init_rc, " "))
|
|
|
}
|
|
|
if amod.commonProperties.Proprietary {
|
|
|
- fmt.Fprintln(w, "LOCAL_PROPRIETARY_MODULE := true")
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_PROPRIETARY_MODULE := true")
|
|
|
}
|
|
|
if amod.commonProperties.Vendor {
|
|
|
- fmt.Fprintln(w, "LOCAL_VENDOR_MODULE := true")
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_VENDOR_MODULE := true")
|
|
|
}
|
|
|
if amod.commonProperties.Owner != nil {
|
|
|
- fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", *amod.commonProperties.Owner)
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_MODULE_OWNER :=", *amod.commonProperties.Owner)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if host {
|
|
|
- fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", amod.Os().String())
|
|
|
- fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_MODULE_HOST_OS :=", amod.Os().String())
|
|
|
+ fmt.Fprintln(&data.preamble, "LOCAL_IS_HOST_MODULE := true")
|
|
|
}
|
|
|
|
|
|
+ blueprintDir := filepath.Dir(ctx.BlueprintFile(mod))
|
|
|
+
|
|
|
+ if data.Custom != nil {
|
|
|
+ data.Custom(w, name, prefix, blueprintDir, data)
|
|
|
+ } else {
|
|
|
+ WriteAndroidMkData(w, data)
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func WriteAndroidMkData(w io.Writer, data AndroidMkData) {
|
|
|
+ if data.Disabled {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if !data.OutputFile.Valid() {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ w.Write(data.preamble.Bytes())
|
|
|
+
|
|
|
for _, extra := range data.Extra {
|
|
|
extra(w, data.OutputFile.Path())
|
|
|
}
|
|
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
|
|
|
-
|
|
|
- return nil
|
|
|
}
|