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:
+34
-19
@@ -98,29 +98,44 @@ 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} {
|
||||||
# Delete existing symbolic link or file if it exists
|
_error "Source file not found" "No file or directory matches $source_file"
|
||||||
if {[file exists $target_path]} {
|
|
||||||
file delete -force $target_path
|
|
||||||
_warn "Deleted existing link or file: $target_path"
|
|
||||||
}
|
}
|
||||||
|
# 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]
|
||||||
|
|
||||||
# Handle source based on the value of LINK_SRCS
|
# Ensure the target directory exists
|
||||||
switch $link_srcs {
|
set target_dir [file dirname $target_path]
|
||||||
"y" {
|
if {![file exists $target_dir]} {
|
||||||
# Create symbolic link
|
file mkdir $target_dir
|
||||||
file link -symbolic $target_path $source_path
|
_info "Created directory: $target_dir"
|
||||||
_info "Created symbolic link: $target_path -> $source_path"
|
|
||||||
}
|
}
|
||||||
"n" {
|
|
||||||
# Copy the source file
|
# Delete existing symbolic link or file if it exists
|
||||||
file copy $source_path $target_path
|
if {[file exists $target_path]} {
|
||||||
_info "Copied source file: $source_path to $target_path"
|
file delete -force $target_path
|
||||||
|
_warn "Deleted existing link or file: $target_path"
|
||||||
}
|
}
|
||||||
default {
|
|
||||||
_error "Unknown value for LINK_SRCS: ${link_srcs}."
|
# Handle source based on the value of LINK_SRCS
|
||||||
|
switch $link_srcs {
|
||||||
|
"y" {
|
||||||
|
# Create symbolic link
|
||||||
|
file link -symbolic $target_path $eval_source
|
||||||
|
_info "Created symbolic link: $target_path -> $eval_source"
|
||||||
|
}
|
||||||
|
"n" {
|
||||||
|
# Copy the source file
|
||||||
|
file copy $eval_source $target_path
|
||||||
|
_info "Copied source file: $eval_source to $target_path"
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
_error "Unknown value for LINK_SRCS: ${link_srcs}."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user