-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathto_git.tcl
64 lines (53 loc) · 2.19 KB
/
to_git.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# ##########################################################
#
# Title : to_git.tcl
# Author : O.C.
# Description : Reduces the project to a few tcl scripts
# practical for version controlled
#
# ##########################################################
#Setting the directory where the <to_git.tcl> file resides
set origin_dir [file dirname [info script]]
set block_origin_dir $origin_dir/src/bd
# Function that recursively looks through directories -> https://stackoverflow.com/questions/429386/tcl-recursively-search-subdirectories-to-source-all-tcl-files
# findFiles
# basedir - the directory to start looking in
# pattern - A pattern, as defined by the glob command, that the files must match
proc findFiles { basedir pattern } {
# Fix the directory name, this ensures the directory name is in the
# native format for the platform and contains a final directory seperator
set basedir [string trimright [file join [file normalize $basedir] { }]]
set fileList {}
# Look in the current directory for matching files, -type {f r}
# means ony readable normal files are looked at, -nocomplain stops
# an error being thrown if the returned list is empty
foreach fileName [glob -nocomplain -type {f r} -path $basedir $pattern] {
lappend fileList $fileName
}
# Now look for any sub direcories in the current directory
foreach dirName [glob -nocomplain -type {d r} -path $basedir *] {
# Recusively call the routine on the sub directory and append any
# new files to the results
set subDirList [findFiles $dirName $pattern]
if { [llength $subDirList] > 0 } {
foreach subDirFile $subDirList {
lappend fileList $subDirFile
}
}
}
return $fileList
}
#End of function
#Looking for project name
set project_name [file rootname [file tail [findFiles $origin_dir "*.xpr"]]]
#Opening the project
puts $origin_dir/tis100/$project_name.xpr
open_project $origin_dir/tis100/$project_name.xpr
#Creating the block designs from the tcl scripts
source $origin_dir/src/bd/block_design_tcl.tcl
#Creating a tcl file that represents the project
write_project_tcl -force build.tcl
#Cleans the project (shouldn't be necessary though)
source project_cleaner.tcl
#Exiting cmd prompt
exit