-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject_cleaner.tcl
66 lines (55 loc) · 2.11 KB
/
project_cleaner.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
65
66
# ##########################################################
#
# Title : project_cleaner.tcl
# Author : O.C.
# Description : Deletes some unwanted files:
# -vivado_*.jou
# -vivado_*.backup*
# -hs_err_pid*
# -ps_clock_registers*
# -.hdi.isWriteableTest*
#
# ###########################################################
# 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
#Setting the current directory
set origin_dir [file dirname [info script]]
#Creating a list of all the undesirable files
set undesirable_files [list \
{*}[findFiles $origin_dir "vivado_*.jou"]\
{*}[findFiles $origin_dir "vivado_*.backup*"]\
{*}[findFiles $origin_dir "hs_err_pid*"]\
{*}[findFiles $origin_dir "ps_clock_registers*"]\
{*}[findFiles $origin_dir ".hdi.isWriteableTest*"]
]
#Deleting the aforementioned files
foreach file $undesirable_files {
file delete $file
}