From af92cd0a53187b9a916a2725be415df634d281c1 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Thu, 31 Oct 2024 11:36:07 +0800 Subject: [PATCH] feat(platform/xilinx): add support for specifying application template --- platform/xilinx/HOWTO.md | 2 ++ platform/xilinx/template.json | 1 + platform/xilinx/util.tcl | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/platform/xilinx/HOWTO.md b/platform/xilinx/HOWTO.md index f012208..625fd0b 100644 --- a/platform/xilinx/HOWTO.md +++ b/platform/xilinx/HOWTO.md @@ -135,6 +135,7 @@ "target_cpu": "", "os": "", "language": "", + "template": "", "bsp": "", "bsp_lib": { "": { @@ -175,6 +176,7 @@ - **target_cpu**: 目标 CPU ID[^2]; - **os**: 操作系统类型[^1],必须与 BSP/Domain 匹配; - **language**: 编程语言,"C" 或 "C++"; +- *template*: 所使用的应用模板名称,不指定则默认为对应语言的 “Empty Application”; - *bsp*: 应用所使用的 BSP 名称,若未指定则会自动创建名为 `_bsp` 的 BSP/Domain. - *bsp_lib*: 针对自动创建的 BSP/Domain 所使用库的配置,与 [bsps](#bsps) 中 `libs` 对应; - *bsp_config*: 针对自动创建的 BSP/Domain 配置与 [bsps](#bsps) 中 `config` 对应; diff --git a/platform/xilinx/template.json b/platform/xilinx/template.json index a42c0c6..5ac3580 100644 --- a/platform/xilinx/template.json +++ b/platform/xilinx/template.json @@ -31,6 +31,7 @@ "target_cpu": "", "os": "", "language": "", + "template": "", "bsp": "", "bsp_lib": { "": { diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index 671a4bd..9ab4476 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -248,9 +248,22 @@ proc _update_app_build_config {app_name build_type build_config is_vitis} { proc _create_app {app_name app_config platform_name is_vitis} { set cpu [dict get $app_config target_cpu] set os [dict get $app_config os] - set lang [dict get $app_config language] set sources [dict get $app_config sources] set bsp_name "${app_name}_bsp" + set lang [dict get $app_config language] + if { $lang ne "C" && $lang ne "C++" } { + _error "Unsupport language" "language should be C or C++" + } + if { [dict exists $app_config template] } { + set template [dict get $app_config template] + } elseif { !$is_vitis } { + set template "Empty Application" + } elseif { $lang eq "C++" } { + set template "Empty Application (C++)" + } else { + set template "Empty Application(C)" + } + # Configure BSP/Domain for application if {[dict exists $app_config bsp] && [dict get $app_config bsp] ne ""} { @@ -280,7 +293,7 @@ proc _create_app {app_name app_config platform_name is_vitis} { -os $os \ -lang $lang \ -sysproj $::project_name \ - -template "Empty Application($lang)" + -template "$template" _info "Application '$app_name' created for Vitis." } else { sdk createapp -name $app_name \ @@ -289,7 +302,7 @@ proc _create_app {app_name app_config platform_name is_vitis} { -proc $cpu \ -os $os \ -lang $lang \ - -app "Empty Application" + -template "$template" _info "Application '$app_name' created for Xilinx SDK." }