refactor(platform/xilinx): replace symbolic links with hard links for better compatibility
- Replaced symbolic links with hard links in the Vitis project source management. - Symbolic links often cause reference issues during debugging in Xilinx Vitis. - This change improves source visibility and debugger integration.
This commit is contained in:
+58
-28
@@ -90,6 +90,46 @@ proc _configure_bsp {bsp_name bsp_config platform_name is_vitis} {
|
|||||||
return $bsp_name
|
return $bsp_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Helper procedure to recursively create hard links for files in a directory
|
||||||
|
proc _link_or_copy_dir {source_dir target_dir link_mode} {
|
||||||
|
# Create target directory if it doesn't exist
|
||||||
|
if {![file exists $target_dir]} {
|
||||||
|
file mkdir $target_dir
|
||||||
|
_info "Created directory: $target_dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Process each file and subdirectory in the source directory
|
||||||
|
foreach item [glob -nocomplain -directory $source_dir *] {
|
||||||
|
set item_name [file tail $item]
|
||||||
|
set target_item [file join $target_dir $item_name]
|
||||||
|
|
||||||
|
# Remove existing file or directory
|
||||||
|
if {[file exists $target_item]} {
|
||||||
|
file delete -force $target_item
|
||||||
|
_warn "Deleted existing item: $target_item"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {[file isfile $item]} {
|
||||||
|
# Handle file - create hard link or copy
|
||||||
|
if {$link_mode eq "y"} {
|
||||||
|
if {[catch {
|
||||||
|
file link -hard $target_item $item
|
||||||
|
} err]} {
|
||||||
|
error "Failed to create hard link: $err"
|
||||||
|
} else {
|
||||||
|
_info "Created hard link: $target_item -> $item"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file copy $item $target_item
|
||||||
|
_info "Copied file: $item to $target_item"
|
||||||
|
}
|
||||||
|
} elseif {[file isdirectory $item]} {
|
||||||
|
# Handle subdirectory recursively
|
||||||
|
_link_or_copy_dir $item $target_item $link_mode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Helper procedure to handle source files: link or copy based on LINK_SRCS
|
# Helper procedure to handle source files: link or copy based on LINK_SRCS
|
||||||
proc _handle_sources {app_name sources} {
|
proc _handle_sources {app_name sources} {
|
||||||
# Check environment variable LINK_SRCS
|
# Check environment variable LINK_SRCS
|
||||||
@@ -104,52 +144,41 @@ proc _handle_sources {app_name sources} {
|
|||||||
if {[llength $expanded_sources] == 0} {
|
if {[llength $expanded_sources] == 0} {
|
||||||
_error "Source file not found" "No file or directory matches $source_file"
|
_error "Source file not found" "No file or directory matches $source_file"
|
||||||
}
|
}
|
||||||
# Hanle each expanded source
|
|
||||||
|
# Handle each expanded source
|
||||||
foreach eval_source $expanded_sources {
|
foreach eval_source $expanded_sources {
|
||||||
set relative_source [string range $eval_source [expr [string length $::root] + 1] end]
|
set relative_source [string range $eval_source [expr [string length $::root] + 1] end]
|
||||||
set target_path [file join $::ws $app_name $relative_source]
|
set target_path [file join $::ws $app_name $relative_source]
|
||||||
|
|
||||||
# Ensure the target directory exists
|
if {[file isfile $eval_source]} {
|
||||||
|
# For files, ensure the parent directory exists
|
||||||
set target_dir [file dirname $target_path]
|
set target_dir [file dirname $target_path]
|
||||||
if {![file exists $target_dir]} {
|
if {![file exists $target_dir]} {
|
||||||
file mkdir $target_dir
|
file mkdir $target_dir
|
||||||
_info "Created directory: $target_dir"
|
_info "Created directory: $target_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete existing symbolic link or file if it exists
|
# Delete existing file if it exists
|
||||||
if {[file exists $target_path]} {
|
if {[file exists $target_path]} {
|
||||||
file delete -force $target_path
|
file delete -force $target_path
|
||||||
_warn "Deleted existing link or file: $target_path"
|
_warn "Deleted existing file: $target_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle source based on the value of LINK_SRCS
|
# Handle file based on LINK_SRCS
|
||||||
switch $link_srcs {
|
if {$link_srcs eq "y"} {
|
||||||
"y" {
|
|
||||||
# Create symbolic link
|
|
||||||
# -- Symbolic link for file dose not support on NTFS
|
|
||||||
if {$::tcl_platform(platform) eq "windows" && [file isfile $eval_source]} {
|
|
||||||
if {[catch {
|
if {[catch {
|
||||||
file link -hard $target_path $eval_source
|
file link -hard $target_path $eval_source
|
||||||
} err]} {
|
} err]} {
|
||||||
error "Failed to create file hard link: $err"
|
error "Failed to create hard link: $err"
|
||||||
|
}
|
||||||
|
_info "Created hard link: $target_path -> $eval_source"
|
||||||
|
} else {
|
||||||
|
file copy $eval_source $target_path
|
||||||
|
_info "Copied file: $eval_source to $target_path"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if {[catch {
|
# For directories, use the helper function
|
||||||
file link -symbolic $target_path $eval_source
|
_link_or_copy_dir $eval_source $target_path $link_srcs
|
||||||
} err]} {
|
|
||||||
error "Failed to create symbolic link: $err"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_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}."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +261,8 @@ proc _update_app_build_config {app_name build_type build_config is_vitis} {
|
|||||||
"linker-misc" -
|
"linker-misc" -
|
||||||
"linker-script" {
|
"linker-script" {
|
||||||
if {$value ne ""} {
|
if {$value ne ""} {
|
||||||
eval $cmd $app_name -set $param $value
|
set value_list [list $value]
|
||||||
|
eval $cmd $app_name -set $param $value_list
|
||||||
_info "Set $param: $value for $app_name."
|
_info "Set $param: $value for $app_name."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user