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.
This commit is contained in:
Gatsby Van
2024-10-28 17:24:43 +08:00
parent 72c5619f59
commit df5cc85fa7
+21 -6
View File
@@ -98,8 +98,22 @@ proc _handle_sources {app_name sources} {
}
foreach source_file $sources {
set source_path [file normalize $::root/$source_file]
set target_path [file join $::ws $app_name [file tail $source_path]]
# Expand wildcards
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
if {[file exists $target_path]} {
@@ -111,13 +125,13 @@ proc _handle_sources {app_name sources} {
switch $link_srcs {
"y" {
# Create symbolic link
file link -symbolic $target_path $source_path
_info "Created symbolic link: $target_path -> $source_path"
file link -symbolic $target_path $eval_source
_info "Created symbolic link: $target_path -> $eval_source"
}
"n" {
# Copy the source file
file copy $source_path $target_path
_info "Copied source file: $source_path to $target_path"
file copy $eval_source $target_path
_info "Copied source file: $eval_source to $target_path"
}
default {
_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} {