Compare commits

...
3 Commits
Author SHA1 Message Date
Gatsby Van 3ada35e863 docs(platform/xilinx): add description for sources section, fix typos
Added a description of the `sources` field, detailing its use of relative paths and wildcard support. Fixed minor typos for clarity.
2024-10-28 17:39:46 +08:00
Gatsby Van df5cc85fa7 feat(platform/xilinx): enable wildcard support in source file configuration
Allow wildcards in the source file section of the configuration. The script evaluates wildcards and adds matching source files automatically.
2024-10-28 17:24:43 +08:00
Gatsby Van 72c5619f59 fix(platform/xilinx): set library-search-path as workspace-relative path 2024-10-28 17:21:28 +08:00
2 changed files with 42 additions and 27 deletions
+3 -3
View File
@@ -171,13 +171,13 @@
} }
``` ```
- **sources**: 源文件列表(相对配置文件路径); - **sources**: 源文件列表,应为相对当前配置文件的路径,可使用通配符。例如,`"src/*"` 会将配置文件所在目录下的 `src` 文件夹中的所有文件复制或链接到相应工程目录下的 `src` 文件夹中。
- **target_cpu**: 目标 CPU ID[^2]; - **target_cpu**: 目标 CPU ID[^2];
- **os**: 操作系统类型[^1],必须与 BSP/Domain 匹配; - **os**: 操作系统类型[^1],必须与 BSP/Domain 匹配;
- **language**: 编程语言,"C" 或 "C++"; - **language**: 编程语言,"C" 或 "C++";
- *bsp*: 应用所使用的 BSP 名称,若未指定则会自动创建名为 `<os>_<cpu_id>` 的 BSP/Domain. - *bsp*: 应用所使用的 BSP 名称,若未指定则会自动创建名为 `<os>_<cpu_id>` 的 BSP/Domain.
- *bsp_lib*: 针对自动创建的 BSP/Domain 所使用库的配置,与 [bsps](#-bsps) 中 `libs` 对应; - *bsp_lib*: 针对自动创建的 BSP/Domain 所使用库的配置,与 [bsps](#bsps) 中 `libs` 对应;
- *bsp_config*: 针对自动创建的 BSP/Domain 配置与 [bsps](#-bsps) 中 `config` 对应; - *bsp_config*: 针对自动创建的 BSP/Domain 配置与 [bsps](#bsps) 中 `config` 对应;
- *mem_layout*: 应用内存布局,包括堆栈大小和堆大小等; - *mem_layout*: 应用内存布局,包括堆栈大小和堆大小等;
-*heap_size*: 堆大小,必须写为十六进制,例如 "0x80000"; -*heap_size*: 堆大小,必须写为十六进制,例如 "0x80000";
-*stack_size*: 栈大小,必须写为十六进制,例如 "0x4000"; -*stack_size*: 栈大小,必须写为十六进制,例如 "0x4000";
+26 -11
View File
@@ -98,8 +98,22 @@ proc _handle_sources {app_name sources} {
} }
foreach source_file $sources { foreach source_file $sources {
set source_path [file normalize $::root/$source_file] # Expand wildcards
set target_path [file join $::ws $app_name [file tail $source_path]] set expanded_sources [glob -nocomplain -directory $::root $source_file]
if {[llength $expanded_sources] == 0} {
_error "Source file not found" "No file or directory matches $source_file"
}
# Hanle each expanded source
foreach eval_source $expanded_sources {
set relative_source [string range $eval_source [expr [string length $::root] + 1] end]
set target_path [file join $::ws $app_name $relative_source]
# Ensure the target directory exists
set target_dir [file dirname $target_path]
if {![file exists $target_dir]} {
file mkdir $target_dir
_info "Created directory: $target_dir"
}
# Delete existing symbolic link or file if it exists # Delete existing symbolic link or file if it exists
if {[file exists $target_path]} { if {[file exists $target_path]} {
@@ -111,13 +125,13 @@ proc _handle_sources {app_name sources} {
switch $link_srcs { switch $link_srcs {
"y" { "y" {
# Create symbolic link # Create symbolic link
file link -symbolic $target_path $source_path file link -symbolic $target_path $eval_source
_info "Created symbolic link: $target_path -> $source_path" _info "Created symbolic link: $target_path -> $eval_source"
} }
"n" { "n" {
# Copy the source file # Copy the source file
file copy $source_path $target_path file copy $eval_source $target_path
_info "Copied source file: $source_path to $target_path" _info "Copied source file: $eval_source to $target_path"
} }
default { default {
_error "Unknown value for LINK_SRCS: ${link_srcs}." _error "Unknown value for LINK_SRCS: ${link_srcs}."
@@ -125,6 +139,7 @@ proc _handle_sources {app_name sources} {
} }
} }
} }
}
proc _update_app_mem_layout {app_name mem_layout} { proc _update_app_mem_layout {app_name mem_layout} {
@@ -181,17 +196,17 @@ proc _update_app_build_config {app_name build_type build_config is_vitis} {
dict for {param value} $build_config { dict for {param value} $build_config {
switch -exact -- $param { switch -exact -- $param {
"include-path" { "include-path" -
"library-search-path" {
foreach path $value { foreach path $value {
set path_str [format "\"\${workspace_loc:/%s/%s}\"" $app_name $path] set path_str [format "\"\${workspace_loc:/%s/%s}\"" $app_name $path]
eval $cmd $app_name include-path [list $path_str] eval $cmd $app_name $param [list $path_str]
_info "Append included path: $path for $app_name." _info "Append $param: $path for $app_name."
} }
} }
"define-compiler-symbols" - "define-compiler-symbols" -
"undef-compiler-symbols" - "undef-compiler-symbols" -
"libraries" - "libraries" {
"library-search-path" {
foreach item $value { foreach item $value {
eval $cmd $app_name $param $item eval $cmd $app_name $param $item
_info "Append parameter $param: $item for $app_name." _info "Append parameter $param: $item for $app_name."