diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index f80762b..cfa5693 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -98,29 +98,44 @@ 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]] - - # Delete existing symbolic link or file if it exists - if {[file exists $target_path]} { - file delete -force $target_path - _warn "Deleted existing link or file: $target_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] - # Handle source based on the value of LINK_SRCS - switch $link_srcs { - "y" { - # Create symbolic link - file link -symbolic $target_path $source_path - _info "Created symbolic link: $target_path -> $source_path" + # 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" } - "n" { - # Copy the source file - file copy $source_path $target_path - _info "Copied source file: $source_path to $target_path" + + # Delete existing symbolic link or file if it exists + if {[file exists $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}." + } } } }