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.

123 lines
4.2 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 "After cloning this repo open the project with Vivado by using `Tools -> Run Tcl Script...` and selecting the `${current_project}.tcl` file"
  58. puts $file ""
  59. puts $file "### Workflow"
  60. puts $file ""
  61. puts $file "- Place source/design files in folder created in the top directory of the repo (e.g. `REPO/src/` or `REPO/design/`)."
  62. puts $file ""
  63. puts $file "- **The `work_dir` folder will be untracked!**"
  64. puts $file ""
  65. puts $file "- Wenn you are done, `git add` your source/design files."
  66. puts $file ""
  67. puts $file "- Use the Tcl Console from Vivado to `git commit -m \"COMMIT_MESSAGE\"` your work. The `${current_project}.tcl` file will be recreated"
  68. puts $file ""
  69. puts $file "### Notes"
  70. puts $file ""
  71. puts $file "#### Block design"
  72. puts $file ""
  73. puts $file "When you change a block design, **befor you run synthesis** you have to disable the current HDL wrapper and create a new HDL wrapper for each design!"
  74. close $file
  75. # Initialize the repo
  76. puts "Initialize the repo"
  77. exec git {*}$args
  78. exec git add .gitignore
  79. exec git add README.md
  80. git_commit commit -m "create project"
  81. puts "finished!"
  82. }
  83. proc git_commit {args} {
  84. # Get project name
  85. set proj_file [current_project].tcl
  86. # Generate project and add it
  87. write_project_tcl_git -no_copy_sources -force $proj_file
  88. puts $proj_file
  89. exec git add $proj_file
  90. # Now commit everything
  91. exec git {*}$args
  92. }
  93. proc wproj {} {
  94. # Change directory project directory if not in it yet
  95. set proj_dir [regsub {\/work_dir$} [get_property DIRECTORY [current_project]] {}]
  96. set current_dir [pwd]
  97. if {
  98. [string compare -nocase $proj_dir $current_dir]
  99. } then {
  100. puts "Not in project directory"
  101. puts "Changing directory to: ${proj_dir}"
  102. cd $proj_dir
  103. }
  104. # Generate project
  105. set proj_file [current_project].tcl
  106. puts $proj_file
  107. write_project_tcl_git -no_copy_sources -force $proj_file
  108. }
  109. }