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.

125 lines
4.3 KiB

8 years ago
8 years ago
8 years ago
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 work_dir 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 {\/work_dir$} [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. set vivado_version [version -short]
  37. set current_project [current_project]
  38. # Generate gitignore file
  39. puts "Generate gitignore file"
  40. set file [open ".gitignore" "w"]
  41. puts $file "work_dir/*"
  42. puts $file ".Xil/*"
  43. puts $file "*.str"
  44. puts $file "*.log"
  45. puts $file "*.jobs"
  46. puts $file "*.jou"
  47. close $file
  48. # Generate readme file
  49. puts "Generate readme file"
  50. set file [open "README.md" "w"]
  51. puts $file "# ${current_project}"
  52. puts $file ""
  53. puts $file "Created with Vivado Version ${vivado_version}"
  54. puts $file ""
  55. puts $file "### Getting started"
  56. puts $file ""
  57. puts $file "Clone repo with `git clone --recurse-submodules`"
  58. puts $file ""
  59. puts $file "After cloning this repo open the project with Vivado by using `Tools -> Run Tcl Script...` and selecting the `${current_project}.tcl` file"
  60. puts $file ""
  61. puts $file "### Workflow"
  62. puts $file ""
  63. puts $file "- Place source/design files in folder created in the top directory of the repo (e.g. `REPO/src/` or `REPO/design/`)."
  64. puts $file ""
  65. puts $file "- **The `work_dir` folder will be untracked!**"
  66. puts $file ""
  67. puts $file "- Wenn you are done, `git add` your source/design files."
  68. puts $file ""
  69. puts $file "- Use the **Tcl Console** from Vivado to `git commit -m \"COMMIT_MESSAGE\"` your work. The `${current_project}.tcl` file will be recreated"
  70. puts $file ""
  71. puts $file "### Notes"
  72. puts $file ""
  73. puts $file "#### Block design"
  74. puts $file ""
  75. puts $file "When you change a block design, **befor you run synthesis** you have to *delete* the current HDL wrapper and *create a new* HDL wrapper for each changed design!"
  76. close $file
  77. # Initialize the repo
  78. puts "Initialize the repo"
  79. exec git {*}$args
  80. exec git add .gitignore
  81. exec git add README.md
  82. git_commit commit -m "create project"
  83. puts "finished!"
  84. }
  85. proc git_commit {args} {
  86. # Get project name
  87. set proj_file [current_project].tcl
  88. # Generate project and add it
  89. write_project_tcl_git -no_copy_sources -use_bd_files -force $proj_file
  90. puts $proj_file
  91. exec git add $proj_file
  92. # Now commit everything
  93. exec git {*}$args
  94. }
  95. proc wproj {} {
  96. # Change directory project directory if not in it yet
  97. set proj_dir [regsub {\/work_dir$} [get_property DIRECTORY [current_project]] {}]
  98. set current_dir [pwd]
  99. if {
  100. [string compare -nocase $proj_dir $current_dir]
  101. } then {
  102. puts "Not in project directory"
  103. puts "Changing directory to: ${proj_dir}"
  104. cd $proj_dir
  105. }
  106. # Generate project
  107. set proj_file [current_project].tcl
  108. puts $proj_file
  109. write_project_tcl_git -no_copy_sources -use_bd_files -force $proj_file
  110. }
  111. }