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.
86 lines
2.2 KiB
86 lines
2.2 KiB
package libpq
|
|
|
|
import (
|
|
"android/soong/android"
|
|
"android/soong/cc"
|
|
"strings"
|
|
)
|
|
|
|
var SUPPORT_TARGET_PLATFORM = [...]string{
|
|
"rk3588",
|
|
"rk3576",
|
|
}
|
|
|
|
func init() {
|
|
android.RegisterModuleType("cc_libpq_prebuilt_library", libpqFactory)
|
|
}
|
|
|
|
func libpqFactory() (android.Module) {
|
|
module := cc.PrebuiltSharedLibraryFactory()
|
|
android.AddLoadHook(module, libpqPrebuiltLibrary)
|
|
return module
|
|
}
|
|
|
|
func libpqPrebuiltLibrary(ctx android.LoadHookContext) {
|
|
|
|
type props struct {
|
|
Multilib struct {
|
|
Lib64 struct {
|
|
Srcs []string
|
|
}
|
|
Lib32 struct {
|
|
Srcs []string
|
|
}
|
|
}
|
|
Shared_libs []string
|
|
}
|
|
p := &props{}
|
|
|
|
p.Multilib.Lib64.Srcs = getlibpqLibrary(ctx, "arm64")
|
|
p.Multilib.Lib32.Srcs = getlibpqLibrary(ctx, "arm")
|
|
p.Shared_libs = getSharedLibrary(ctx);
|
|
ctx.AppendProperties(p)
|
|
}
|
|
|
|
func checkEnabled(ctx android.LoadHookContext) bool {
|
|
var soc string = getTargetSoc(ctx)
|
|
for i := 0; i < len(SUPPORT_TARGET_PLATFORM); i++ {
|
|
if (strings.EqualFold(SUPPORT_TARGET_PLATFORM[i], soc)) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func getlibpqLibrary(ctx android.LoadHookContext, arch string) ([]string) {
|
|
var src []string
|
|
var soc string = getTargetSoc(ctx)
|
|
var prefix string = soc
|
|
|
|
if (!checkEnabled(ctx)) {
|
|
prefix = "RK3588"
|
|
}
|
|
src = append(src, "lib/" + prefix + "/" + arch + "/libpq.so")
|
|
return src
|
|
}
|
|
|
|
func getTargetSoc(ctx android.LoadHookContext) (string) {
|
|
var platform string = strings.ToUpper(ctx.AConfig().Getenv("TARGET_BOARD_PLATFORM"))
|
|
if(platform == "") {
|
|
platform = strings.ToUpper(ctx.Config().VendorConfig("core_rockchip").String("platform"))
|
|
}
|
|
return platform
|
|
}
|
|
|
|
func getSharedLibrary(ctx android.LoadHookContext) ([]string) {
|
|
var libs []string
|
|
var soc string = getTargetSoc(ctx)
|
|
if(strings.EqualFold(soc, "RK3576")) {
|
|
libs = append(libs,"librkswpq")
|
|
libs = append(libs,"librkhwpq")
|
|
libs = append(libs,"libvdpp")
|
|
} else if (strings.EqualFold(soc, "RK3588")) {
|
|
libs = append(libs,"librkswpq")
|
|
}
|
|
return libs
|
|
} |