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.

84 lines
2.5 KiB

8 years ago
8 years ago
8 years ago
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 vivado_project folder
  7. #
  8. # Ricardo Barbedo
  9. #
  10. ################################################################################
  11. namespace eval ::git_wrapper {
  12. namespace export git
  13. namespace export wproj
  14. namespace import ::custom_projutils::write_project_tcl_git
  15. namespace import ::current_project
  16. namespace import ::common::get_property
  17. proc git {args} {
  18. set command [lindex $args 0]
  19. # Change directory project directory if not in it yet
  20. set proj_dir [regsub {\/vivado_project$} [get_property DIRECTORY [current_project]] {}]
  21. set current_dir [pwd]
  22. if {
  23. [string compare -nocase $proj_dir $current_dir]
  24. } then {
  25. puts "Not in project directory"
  26. puts "Changing directory to: ${proj_dir}"
  27. cd $proj_dir
  28. }
  29. switch $command {
  30. "init" {git_init {*}$args}
  31. "commit" {git_commit {*}$args}
  32. "default" {exec git {*}$args}
  33. }
  34. }
  35. proc git_init {args} {
  36. # Generate gitignore file
  37. set file [open ".gitignore" "w"]
  38. puts $file "vivado_project/*"
  39. puts $file ".Xil/*"
  40. puts $file "*.str"
  41. puts $file "*.log"
  42. close $file
  43. # Initialize the repo
  44. exec git {*}$args
  45. exec git add .gitignore
  46. }
  47. proc git_commit {args} {
  48. # Get project name
  49. set proj_file [current_project].tcl
  50. # Generate project and add it
  51. write_project_tcl_git -no_copy_sources -force $proj_file
  52. puts $proj_file
  53. exec git add $proj_file
  54. # Now commit everything
  55. exec git {*}$args
  56. }
  57. proc wproj {} {
  58. # Change directory project directory if not in it yet
  59. set proj_dir [regsub {\/vivado_project$} [get_property DIRECTORY [current_project]] {}]
  60. set current_dir [pwd]
  61. if {
  62. [string compare -nocase $proj_dir $current_dir]
  63. } then {
  64. puts "Not in project directory"
  65. puts "Changing directory to: ${proj_dir}"
  66. cd $proj_dir
  67. }
  68. # Generate project
  69. set proj_file [current_project].tcl
  70. puts $proj_file
  71. write_project_tcl_git -no_copy_sources -force $proj_file
  72. }
  73. }