Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 63 additions & 3 deletions scripts/git_wrapper.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace eval ::git_wrapper {
exec git {*}$args
}

proc wproj {} {
proc wproj {args} {
# Change directory project directory if not in it yet
set proj_dir [regsub {\/vivado_project$} [get_property DIRECTORY [current_project]] {}]
set current_dir [pwd]
Expand All @@ -82,7 +82,67 @@ namespace eval ::git_wrapper {

# Generate project
set proj_file [current_project].tcl
puts $proj_file
puts "$proj_dir"
write_project_tcl_git -no_copy_sources -force $proj_file
#if { ("-mig" in $args) } {
set PathList {}
if {[catch {open $proj_file r} file]} {
puts "Error: Unable to open file $proj_file"
} else {
while {[gets $file line] != -1} {
if {[string match "*\[file normalize *\[\"*\]*.prj\"*\]*" $line]} {

set start [string first "\"" $line]
set end [string last "\"" $line]
set path [string range $line [expr {$start + 1}] [expr {$end - 1}]]


if {[string match "*{origin_dir}/vivado_project/*" $path]} {
set pathTemp [string map [list "\${origin_dir}/" ""] $path]
set destination_path "$proj_dir/prj_files/$pathTemp"
set directory [file dirname $pathTemp]
set destDirectory "$proj_dir/prj_files/$directory"
set newInFilePath "\${origin_dir}/prj_files/$pathTemp"
lappend PathList [list $path $newInFilePath]

if {![file isdirectory $destDirectory]} {
puts "\[INFO\] prj_files Directory Created"
file mkdir $destDirectory
}

file copy -force $pathTemp $destination_path
}
}
}
close $file
}


if {[file exists $proj_file]} {
# Open the input file for reading
if {[catch {open $proj_file r} original_scriptfile]} {
puts "Error: Unable to open file $proj_file"
} else {
set script_content [read $original_scriptfile]
close $original_scriptfile
foreach {inputPath} $PathList {
set oldPath [lindex $inputPath 0]
set newPath [lindex $inputPath 1]
set script_content [string map [list $oldPath $newPath] $script_content]
set oldPath [string map {"{" "" "}" ""} $oldPath]
set newPath [string map {"{" "" "}" ""} $newPath]
set script_content [string map [list $oldPath $newPath] $script_content]
}

set modified_script_file $proj_file
set modified_script [open $modified_script_file w]
# Write the modified content to the modified script file
puts -nonewline $modified_script $script_content

# Close the modified script file
close $modified_script
}
}
# }
}
}
}