You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.8 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  1. ################################################################################
  2. #
  3. # This file provides a basic wrapper to use git directly from the tcl console in
  4. # Vivado.
  5. # It requires the write_project_tcl_git.tcl script to work properly.
  6. # Unversioned files will be put in the work/ folder
  7. #
  8. # Ricardo Barbedo
  9. #
  10. ################################################################################
  11. namespace eval ::git_wrapper {
  12. namespace export git
  13. namespace import ::custom::write_project_tcl_git
  14. namespace import ::current_project
  15. namespace import ::common::get_property
  16. proc git {args} {
  17. set command [lindex $args 0]
  18. # Change directory project directory if not in it yet
  19. set proj_dir [regsub {\/vivado_proj$} [get_property DIRECTORY [current_project]] {}]
  20. set current_dir [pwd]
  21. if {
  22. [string compare -nocase $proj_dir $current_dir]
  23. } then {
  24. puts "Not in project directory"
  25. puts "Changing directory to: ${proj_dir}"
  26. cd $proj_dir
  27. }
  28. switch $command {
  29. "init" {git_init {*}$args}
  30. "commit" {git_commit {*}$args}
  31. "default" {exec git {*}$args}
  32. }
  33. }
  34. proc git_init {args} {
  35. # Generate gitignore file
  36. set file [open ".gitignore" "w"]
  37. puts $file "vivado_proj/*"
  38. close $file
  39. # Initialize the repo
  40. exec git {*}$args
  41. exec git add .gitignore
  42. }
  43. proc git_commit {args} {
  44. # Get project name
  45. set proj_file [current_project].tcl
  46. # Generate project and add it
  47. write_project_tcl_git -no_copy_sources -force $proj_file
  48. puts $proj_file
  49. exec git add $proj_file
  50. # Now commit everything
  51. exec git {*}$args
  52. }
  53. }