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.
95 lines
2.7 KiB
95 lines
2.7 KiB
package rockchip_platform
|
|
|
|
import (
|
|
"android/soong/android"
|
|
"android/soong/cc"
|
|
"fmt" // required if we want to print usefull messages on the console
|
|
"os"
|
|
//"strings"
|
|
)
|
|
|
|
// Define the list of supported Rockchip platforms
|
|
// Default none
|
|
var rockchipPlatforms = []string{
|
|
"none",
|
|
}
|
|
|
|
func rkcamera_get_platform_board(ctx android.BaseContext) string {
|
|
var board = ctx.Config().Getenv("TARGET_BOARD_PLATFORM")
|
|
if(board == ""){
|
|
board = ctx.Config().VendorConfig("core_rockchip").String("platform")
|
|
}
|
|
fmt.Fprintf(os.Stderr, "rkcamera_get_platform_board >>>>>>>>>>>>>>>>>>>>> %s\n", board)
|
|
return board;
|
|
}
|
|
|
|
func rkcamera_get_aicamera_enable_flags(ctx android.BaseContext) string {
|
|
var aicamera_enable = ctx.Config().Getenv("BOARD_ENABLE_AICAMERA_PRODUCT")
|
|
if(aicamera_enable == ""){
|
|
aicamera_enable = ctx.Config().VendorConfig("camera_rockchip").String("ai_camera_enabled")
|
|
}
|
|
fmt.Fprintf(os.Stderr, "rkcamera_get_platform_board >>>>>>>>>>>>>>>>>>>>> %v\n", aicamera_enable)
|
|
return aicamera_enable;
|
|
}
|
|
|
|
func rkcamera_getSrcsFiles(soc string, isSuppored bool) []string {
|
|
|
|
var srcs []string;
|
|
|
|
if isSuppored {
|
|
srcs = append(srcs, "src/**/*.java")
|
|
srcs = append(srcs, "src_pd/**/*.java")
|
|
srcs = append(srcs, "src_pd_gcam/**/*.java")
|
|
}
|
|
|
|
for i, v := range srcs {
|
|
fmt.Printf("%d %s\n", i, v)
|
|
}
|
|
fmt.Printf("srcs size: %d\n", len(srcs))
|
|
return srcs;
|
|
}
|
|
|
|
func init() {
|
|
android.RegisterModuleType("rkcamera_module_compile_defaults", rkcamera_module_defaultsFactory)
|
|
}
|
|
|
|
func rkcamera_module_defaultsFactory() android.Module {
|
|
module := cc.DefaultsFactory()
|
|
android.AddLoadHook(module, rkCameraPlatformHook)
|
|
return module
|
|
}
|
|
|
|
// Core logic: Check if the current platform is in the list
|
|
func rkCameraPlatformHook(ctx android.LoadHookContext) {
|
|
type props struct {
|
|
Srcs []string
|
|
Cflags []string
|
|
Enabled *bool
|
|
}
|
|
p := &props{}
|
|
|
|
soc := rkcamera_get_platform_board(ctx)
|
|
rkcamera_get_aicamera_enable_flags(ctx)
|
|
isSupportedPlatForm := false
|
|
// Check if it is in the support list
|
|
for _, platform := range rockchipPlatforms {
|
|
if soc == platform {
|
|
isSupportedPlatForm = true
|
|
break
|
|
}
|
|
}
|
|
|
|
fmt.Printf("%s is current Supported Platform Board?: %v\n", soc, isSupportedPlatForm);
|
|
|
|
p.Srcs = rkcamera_getSrcsFiles(soc, isSupportedPlatForm)
|
|
// Dynamically add compilation options
|
|
if (isSupportedPlatForm) {
|
|
enabled := true
|
|
p.Enabled = &enabled
|
|
} else {
|
|
enabled := false
|
|
p.Enabled = &enabled
|
|
}
|
|
// Application conditional logic
|
|
ctx.AppendProperties(p)
|
|
} |