-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean_vivado.bat
158 lines (127 loc) · 3.49 KB
/
clean_vivado.bat
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
echo off
echo.
echo.
echo Start cleaning ...
echo.
echo.
echo.
set would=
set be=
if "%1" == "-t" set would=would
if "%1" == "-t" set be=be
rem ****************************
rem Clean Vivado project folder
echo [105mClean Vivado project folder[0m
set /A VFFILECOUNT=0
set /A VFDELFILECOUNT=0
set /A VFFOLDERCOUNT=0
set keep=
for /F "tokens=* delims==" %%f in ('dir "Vivado" /S /B /A:-D' ) do (
set keep=
if %%~xf == .xpr set keep=true
if not defined keep (
if not "%1" == "-t" del "%%f"
set /A VFDELFILECOUNT+=1
)
set /A VFFILECOUNT+=1
)
for /F "tokens=* delims==" %%g in ('dir "Vivado" /S /B /A:D ^| sort /r' ) do (
if not "%1" == "-t" rd "%%g" > nul 2>&1
)
echo.
echo Done
echo.
echo.
rem ****************************
rem Clean Vivado IPs folder
echo [105mClean Vivado IPs folder[0m
set /A IPCOUNT=0
set /A IPFILECOUNT=0
set /A IPDELFILECOUNT=0
set res=
for /D /r %%G in (*Vivado_ip*) do (
echo(
echo [36mVivado IPs found in folder [1m%%G[0m
for /F "tokens=* delims==" %%f in ('dir "%%G" /B /A:D' ) do (
echo [32mProcessing [1m%%f[0m
for /F "tokens=* delims==" %%t in ('dir "%%G\%%f" /B /A:-D' ) do (
set res=
if %%~xt == .xci set res=T
if %%~xt == .coe set res=T
if %%~xt == .xci set /A IPCOUNT+=1
if defined res (
echo I %would%keep file: %%G\%%f\%%t
) else (
echo I %would%delete file: %%G\%%f\%%t
set /A IPDELFILECOUNT+=1
if not "%1" == "-t" del "%%G\%%f\%%t"
)
set /A IPFILECOUNT+=1
)
for /F "tokens=* delims==" %%y in ('dir "%%G\%%f" /B /A:D ^| sort /r' ) do (
echo I %would%remove folder: %%G\%%f\%%y
if not "%1" == "-t" rd "%%G\%%f\%%y" /s /q > nul 2>&1
)
)
)
echo.
echo Done
echo.
echo.
rem ****************************
rem Clean Vivado BDs folder
echo [105mClean Vivado BDs folder[0m
set /A BDCOUNT=0
set /A BDFILECOUNT=0
set /A BDDELFILECOUNT=0
set res=
for /D /r %%G in (*Vivado_bd*) do (
echo(
echo [36mVivado BDs found in folder [1m%%G[0m
for /F "tokens=* delims==" %%f in ('dir "%%G" /B /A:D' ) do (
echo [32mProcessing [1m%%f[0m
for /F "tokens=* delims==" %%t in ('dir "%%G\%%f" ? /B /A:-D' ) do (
set res=
if %%~xt == .bd set res=T
if %%~xt == .ui set res=T
if %%~xt == .bd set /A BDCOUNT+=1
if defined res (
echo I %would%keep file: %%G\%%f\%%t
) else (
echo I %would%delete file: %%G\%%f\%%t
set /A BDDELFILECOUNT+=1
if not "%1" == "-t" del "%%G\%%f\%%t"
)
SET /A BDFILECOUNT+=1
)
for /F "tokens=* delims==" %%y in ('dir "%%G\%%f" /B /A:D' ) do (
echo %%G\%%f
if %%y == ui (
echo I %would%keep folder: %%G\%%f\%%y
) else (
echo I %would%remove folder: %%G\%%f\%%y
if not "%1" == "-t" rd "%%G\%%f\%%y" /s /q
)
)
)
)
echo.
echo Done
echo.
echo.
echo.
echo.
echo ---------------------------------------------------------------------
echo.
echo %VFDELFILECOUNT% Files in Vivado folder %would%%be%deleted
echo.
echo %IPCOUNT% IPs found
echo %IPFILECOUNT% IPs files processed
echo %IPDELFILECOUNT% IPs files %would%%be%deleted
echo.
echo %BDCOUNT% BDs found
echo %BDFILECOUNT% BDs files processed
echo %BDDELFILECOUNT% BDs files %would%%be%deleted
echo.
echo.
echo Finished: Vivado work files %would%%be%cleaned