You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.4 KiB

package libmpimmz
import (
"android/soong/android"
"android/soong/cc"
"fmt"
"strings"
"strconv"
)
func init() {
fmt.Println("libmpimmz conditional Compile")
android.RegisterModuleType("cc_libmpimmz", DefaultsFactory)
}
func DefaultsFactory() (android.Module) {
module := cc.DefaultsFactory()
android.AddLoadHook(module, Defaults)
return module
}
func Defaults(ctx android.LoadHookContext) {
type props struct {
Srcs []string
Cflags []string
}
p := &props{}
p.Srcs = getSrcs(ctx)
p.Cflags = getCflags(ctx)
ctx.AppendProperties(p)
}
func isSupportDmaBuf(version string) bool {
if (len(version) == 0) {
return true
}
parts := strings.Split(version, ".")
if len(parts) == 0 || len(parts[0]) == 0 {
return true
}
majorVersion, err := strconv.Atoi(parts[0])
if err != nil {
return true
}
return majorVersion > 4
}
func getSrcs(ctx android.BaseContext) ([]string) {
var src []string
if (isSupportDmaBuf(ctx.AConfig().Getenv("PRODUCT_KERNEL_VERSION"))) {
src = append(src, "src/BufferAllocator.cpp")
}
return src
}
func getCflags(ctx android.BaseContext) ([]string) {
var cppflags []string
if (isSupportDmaBuf(ctx.AConfig().Getenv("PRODUCT_KERNEL_VERSION"))) {
cppflags = append(cppflags,"-DSUPPORT_DMABUF_ALLOCATOR=1")
}
return cppflags
}