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.

81 lines
2.4 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. close $file
  40. # Initialize the repo
  41. exec git {*}$args
  42. exec git add .gitignore
  43. }
  44. proc git_commit {args} {
  45. # Get project name
  46. set proj_file [current_project].tcl
  47. # Generate project and add it
  48. write_project_tcl_git -no_copy_sources -force $proj_file
  49. puts $proj_file
  50. exec git add $proj_file
  51. # Now commit everything
  52. exec git {*}$args
  53. }
  54. proc wproj {} {
  55. # Change directory project directory if not in it yet
  56. set proj_dir [regsub {\/vivado_project$} [get_property DIRECTORY [current_project]] {}]
  57. set current_dir [pwd]
  58. if {
  59. [string compare -nocase $proj_dir $current_dir]
  60. } then {
  61. puts "Not in project directory"
  62. puts "Changing directory to: ${proj_dir}"
  63. cd $proj_dir
  64. }
  65. # Generate project
  66. set proj_file [current_project].tcl
  67. puts $proj_file
  68. write_project_tcl_git -no_copy_sources -force $proj_file
  69. }
  70. }