@ -0,0 +1,2 @@ | |||||
write_project_tcl_git.tcl eol=lf | |||||
*.tcl eol=crlf |
@ -0,0 +1,31 @@ | |||||
# vivado-git | |||||
Trying to make Vivado more git-friendly on Windows. | |||||
### Requirements | |||||
[Git for Windows.](https://git-scm.com/download/win) | |||||
### Installation | |||||
Append/replace/add `init.tcl` and the `scripts` directory to `%APPDATA%\Roaming\Xilinx\Vivado`. | |||||
### How it works | |||||
Vivado is a pain in the ass to source control decently, so these scripts provide: | |||||
- A modified `write_project_tcl_git` script to generate a project generator script without absolute paths. | |||||
- A git wrapper that will regenerate the project script and add it before commiting. | |||||
### Workflow | |||||
When first starting with a project, create it at a folder like `C:/.../PROJECT_NAME/work`. All the untracked files will be under this directory. | |||||
Place your source files anywhere you want in your project folder. | |||||
Then go to your project directory using the Tcl Console with `cd C:/.../PROJECT_NAME` before adding or committing you files. | |||||
When you are done, just add your files and `git commit` your project. A `PROJECT_NAME.tcl` script will be created in your `PROJECT_NAME` folder and added to your commit. | |||||
When reopening the project, make sure to do it by using `Tools -> Run Tcl Script...`. The Tcl Console will change the directory to your project folder automatically. |
@ -0,0 +1,7 @@ | |||||
set init_dir [file dirname [info script]] | |||||
source $init_dir/scripts/write_project_tcl_git.tcl | |||||
namespace import ::custom::write_project_tcl_git | |||||
source $init_dir/scripts/git_wrapper.tcl | |||||
namespace import ::git_wrapper::git |
@ -0,0 +1,50 @@ | |||||
################################################################################ | |||||
# | |||||
# This file provides a basic wrapper to use git directly from the tcl console in | |||||
# Vivado. | |||||
# It requires the write_project_tcl_git.tcl script to work properly. | |||||
# Unversioned files will be put in the work/ folder | |||||
# | |||||
# Ricardo Barbedo | |||||
# | |||||
################################################################################ | |||||
namespace eval ::git_wrapper { | |||||
namespace export git | |||||
namespace import ::custom::write_project_tcl_git | |||||
namespace import ::current_project | |||||
namespace import ::common::get_property | |||||
proc git {args} { | |||||
set command [lindex $args 0] | |||||
switch $command { | |||||
"init" {git_init {*}$args} | |||||
"commit" {git_commit {*}$args} | |||||
"default" {exec git {*}$args} | |||||
} | |||||
} | |||||
proc git_init {args} { | |||||
# Generate gitignore file | |||||
set file [open ".gitignore" "w"] | |||||
puts $file "work/*" | |||||
close $file | |||||
# Initialize the repo | |||||
exec git {*}$args | |||||
} | |||||
proc git_commit {args} { | |||||
# Get project name | |||||
set proj_file [current_project].tcl | |||||
# Generate project and add it | |||||
write_project_tcl_git -no_copy_sources -force $proj_file | |||||
puts $proj_file | |||||
exec git add $proj_file | |||||
# Now commit everything | |||||
exec git {*}$args | |||||
} | |||||
} |