代码拉取完成,页面将自动刷新
同步操作将从 HiHope-RK3588/rk3588-librga 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package librga
import (
"android/soong/android"
"android/soong/cc"
"fmt"
"strings"
"strconv"
"unsafe"
)
func init() {
fmt.Println("librga want to conditional Compile")
android.RegisterModuleType("cc_librga", DefaultsFactory)
}
func DefaultsFactory() (android.Module) {
module := cc.DefaultsFactory()
android.AddLoadHook(module, Defaults)
return module
}
func Defaults(ctx android.LoadHookContext) {
sdkVersion := ctx.AConfig().PlatformSdkVersion()
sdkVersionInt, err := strconv.Atoi(*(*string)(unsafe.Pointer(&sdkVersion)))
if err != nil {
fmt.Printf("librga cannot get ApiLevel, %q could not be parsed as an integer\n", sdkVersion)
panic(1)
}
if (sdkVersionInt >= 29 ) {
type props struct {
Srcs []string
Cflags []string
Shared_libs []string
Include_dirs []string
Header_libs []string
Export_header_lib_headers []string
Double_loadable *bool
}
p := &props{}
p.Srcs = getSrcs(ctx, sdkVersionInt)
p.Cflags = getCflags(ctx, sdkVersionInt)
p.Shared_libs = getSharedLibs(ctx, sdkVersionInt)
p.Include_dirs = getIncludeDirs(ctx, sdkVersionInt)
p.Header_libs = getHeaders(ctx, sdkVersionInt)
p.Export_header_lib_headers = getExportHeaders(ctx, sdkVersionInt)
double_loadable := true
p.Double_loadable = &double_loadable
ctx.AppendProperties(p)
} else {
type props struct {
Srcs []string
Cflags []string
Shared_libs []string
Include_dirs []string
}
p := &props{}
p.Srcs = getSrcs(ctx, sdkVersionInt)
p.Cflags = getCflags(ctx, sdkVersionInt)
p.Shared_libs = getSharedLibs(ctx, sdkVersionInt)
p.Include_dirs = getIncludeDirs(ctx, sdkVersionInt)
ctx.AppendProperties(p)
}
}
//条件编译主要修改函数
func getSrcs(ctx android.BaseContext, sdkVersion int) ([]string) {
var src []string
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_RK_GRALLOC_VERSION"),"4") ) {
if (sdkVersion >= 30 ) {
src = append(src, "core/platform_gralloc4.cpp")
}
}
return src
}
func getCflags(ctx android.BaseContext, sdkVersion int) ([]string) {
var cppflags []string
//该打印输出为: TARGET_PRODUCT:rk3328 fmt.Println("TARGET_PRODUCT:",ctx.AConfig().Getenv("TARGET_PRODUCT")) //通过 strings.EqualFold 比较字符串,可参考go语言字符串对比
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_BOARD_PLATFORM"),"rk3368") ) {
//添加 DEBUG 宏定义
cppflags = append(cppflags,"-DRK3368=1")
}
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_RK_GRALLOC_VERSION"),"4") ) {
if (sdkVersion >= 30 ) {
cppflags = append(cppflags,"-DUSE_GRALLOC_4")
}
}
//将需要区分的环境变量在此区域添加 //....
return cppflags
}
func getSharedLibs(ctx android.BaseContext, sdkVersion int) ([]string) {
var libs []string
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_RK_GRALLOC_VERSION"),"4") ) {
if (sdkVersion >= 30 ) {
libs = append(libs, "libgralloctypes")
libs = append(libs, "libhidlbase")
libs = append(libs, "android.hardware.graphics.mapper@4.0")
}
}
if (sdkVersion < 29 ) {
libs = append(libs, "libdrm")
}
return libs
}
func getIncludeDirs(ctx android.BaseContext, sdkVersion int) ([]string) {
var dirs []string
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_RK_GRALLOC_VERSION"),"4") ) {
if (sdkVersion >= 30 ) {
dirs = append(dirs, "hardware/rockchip/libgralloc/bifrost")
dirs = append(dirs, "hardware/rockchip/libgralloc/bifrost/src")
}
}
// Add libion for RK3368
if (sdkVersion >= 29) {
if (sdkVersion >= 30) {
dirs = append(dirs, "system/memory/libion/original-kernel-headers")
} else {
dirs = append(dirs, "system/core/libion/original-kernel-headers")
}
}
return dirs
}
func getHeaders(ctx android.BaseContext, sdkVersion int) ([]string) {
var headers []string
if (sdkVersion >= 31 ) {
headers = append(headers, "libhardware_rockchip_headers")
}
return headers
}
func getExportHeaders(ctx android.BaseContext, sdkVersion int) ([]string) {
var headers []string
if (sdkVersion >= 31 ) {
headers = append(headers, "libhardware_rockchip_headers")
}
return headers
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。