-
Notifications
You must be signed in to change notification settings - Fork 849
/
Copy pathsetup_win.bat
393 lines (327 loc) · 15.6 KB
/
setup_win.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
@echo off
REM Expect the script at /path/to/wolfssl/IDE/Espressif/ESP-IDF/
::******************************************************************************************************
::******************************************************************************************************
echo;
echo wolfSSL Windows Setup. Version 1.0a
echo;
echo This utility will copy a static snapshot of wolfSSL files to the ESP32-IDF component directory.
echo;
echo If you wish to keep your component library fresh with git pull, consider hard link with mklink.
echo;
echo "mklink [[/d] | [/h] | [/j]] <link> <target>"
echo;
::******************************************************************************************************
::******************************************************************************************************
SET COPYERROR=false
:: if there's a setup.sh, we are probably starting in the right place.
if NOT EXIST "setup.sh" (
echo Please run this script at /path/to/wolfssl/IDE/Espressif/ESP-IDF/
goto :ERR
)
:: if there's also a default user_settings.h, we are very likely starting in the right place.
if NOT EXIST "user_settings.h" (
echo Please run this script at /path/to/wolfssl/IDE/Espressif/ESP-IDF/
goto :ERR
)
:: see if there was a parameter passed for a specific EDP-IDF directory
:: this may be different than the standard ESP-IDF environment (e.g. VisualGDB)
if not "%1" == "" (
if not exist "%1" (
echo "ERROR: optional directory was specified, but not found: %1"
goto :ERR
)
SET IDF_PATH=%1
echo Using specified IDF_PATH: %IDF_PATH%
)
:: if no IDF_PATH is found, we don't know what to do. Go exit with error.
if "%IDF_PATH%" == "" (
echo Please launch the script from ESP-IDF command prompt,
echo or set your desired IDF_PATH environment variable,
echo or pass a parameter to your directory, such as for VisualGDB with ESP-IDF 4.4:
echo;
echo .\setup_win.bat C:\SysGCC\esp32\esp-idf\v4.4
echo;
goto :ERR
)
:: Here we go!
:: setup some path variables
echo;
set SCRIPTDIR=%CD%
set BASEDIR=%SCRIPTDIR%\..\..\..
set WOLFSSL_ESPIDFDIR=%BASEDIR%\IDE\Espressif\ESP-IDF
set WOLFSSLLIB_TRG_DIR=%IDF_PATH%\components\wolfssl
set WOLFSSLEXP_TRG_DIR=%IDF_PATH%\examples\protocols
echo Using SCRIPTDIR = %SCRIPTDIR%
echo Using BASEDIR = %BASEDIR%
echo Using WOLFSSL_ESPIDFDIR = %WOLFSSL_ESPIDFDIR%
echo Using WOLFSSLLIB_TRG_DIR = %WOLFSSLLIB_TRG_DIR%
echo Using WOLFSSLEXP_TRG_DIR = %WOLFSSLEXP_TRG_DIR%
echo;
echo Equivalalent destination path:
dir %WOLFSSL_ESPIDFDIR%\*.xyzzy 2> nul | findstr \
echo;
echo Equivalalent source directory paths:
:: show the path of the equivalent %VALUE% (search for files that don't exist, suppress error, and look for string with "\")
dir %BASEDIR%\*.xyzzy 2> nul | findstr \
dir %WOLFSSLLIB_TRG_DIR%\*.xyzzy 2> nul | findstr \
dir %WOLFSSLEXP_TRG_DIR%\*.xyzzy 2> nul | findstr \
:: set the FileStamp variable to the current date: YYMMYY_HHMMSS
:: the simplest method, to use existing TIME ad DATE variables:
:: date = Thu 09/17/2015
:: time = 11:13:15.47
:: 012345678901234567890
::
:: There is no leading zero for single digit hours (e.g. 9:00am), so we need to manually include the zero
:: here |
if "%TIME:~0,1%" == " " set FileStamp=%DATE:~12,2%%DATE:~7,2%%DATE:~4,2%_0%TIME:~1,1%%TIME:~3,2%%TIME:~6,2%
:: otherwise, if a space not found before the digit, it is a 2 digit hour, so no extract zero is needed
if NOT "%TIME:~0,1%" == " " set FileStamp=%DATE:~12,2%%DATE:~7,2%%DATE:~4,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
:: Backup existing user settings
if exist %WOLFSSLLIB_TRG_DIR%\include\config.h (
echo;
echo Saving: %WOLFSSLLIB_TRG_DIR%\include\config.h
echo to: %SCRIPTDIR%\config_h_%FileStamp%.bak
copy %WOLFSSLLIB_TRG_DIR%\include\config.h %SCRIPTDIR%\config_h_%FileStamp%.bak
echo;
)
if exist %WOLFSSL_ESPIDFDIR%\user_settings.h (
echo Saving: %WOLFSSLLIB_TRG_DIR%\include\user_settings.h
echo to: %SCRIPTDIR%\user_settings_h_%FileStamp%.bak
copy %WOLFSSLLIB_TRG_DIR%\include\user_settings.h %SCRIPTDIR%\user_settings_h_%FileStamp%.bak
echo;
)
::******************************************************************************************************
:: check if there's already an existing %WOLFSSLLIB_TRG_DIR% and confirm removal
::******************************************************************************************************
if exist %WOLFSSLLIB_TRG_DIR% (
echo;
echo WARNING: Existing files found in %WOLFSSLLIB_TRG_DIR%
echo;
:: clear any prior errorlevel
call;
choice /c YN /m "Delete files and proceed with install in %WOLFSSLLIB_TRG_DIR% "
if errorlevel 2 GOTO :NODELETE
GOTO :PURGE
echo;
echo Ready to copy files into %IDF_PATH%
::******************************************************************************************************
:NODELETE
::******************************************************************************************************
:: clear any prior errorlevel
echo;
call;
choice /c YN /m "Refresh files %WOLFSSLLIB_TRG_DIR% (there will be a prompt to keep or overwrite user_settings and config) "
if errorlevel 2 GOTO :NOCOPY
GOTO :REFRESH
)
::******************************************************************************************************
:PURGE
::******************************************************************************************************
:: purge existing directory
if exist %WOLFSSLLIB_TRG_DIR% (
echo;
echo Removing %WOLFSSLLIB_TRG_DIR%
rmdir %WOLFSSLLIB_TRG_DIR% /S /Q
if exist %WOLFSSLLIB_TRG_DIR% (
SET COPYERROR=true
echo;
echo WARNING: Failed to remove %WOLFSSLLIB_TRG_DIR%
echo;
echo Check permissions, open files, read-only attributes, etc.
echo;
)
echo;
) else (
echo;
echo Prior %WOLFSSLLIB_TRG_DIR% not found, installing fresh.
echo;
)
::******************************************************************************************************
:REFRESH
::******************************************************************************************************
if not exist %WOLFSSLLIB_TRG_DIR% mkdir %WOLFSSLLIB_TRG_DIR%
if not exist %WOLFSSLLIB_TRG_DIR%\src mkdir %WOLFSSLLIB_TRG_DIR%\src
if not exist %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src mkdir %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src
if not exist %WOLFSSLLIB_TRG_DIR%\wolfssl mkdir %WOLFSSLLIB_TRG_DIR%\wolfssl
if not exist %WOLFSSLLIB_TRG_DIR%\wolfssl\openssl mkdir %WOLFSSLLIB_TRG_DIR%\wolfssl\openssl
if not exist %WOLFSSLLIB_TRG_DIR%\test mkdir %WOLFSSLLIB_TRG_DIR%\test
if not exist %WOLFSSLLIB_TRG_DIR%\include mkdir %WOLFSSLLIB_TRG_DIR%\include
rem copying ... files in src/ into $WOLFSSLLIB_TRG_DIR%/src
echo;
echo Copying files to %WOLFSSLLIB_TRG_DIR%\src\
xcopy %BASEDIR%\src\*.c %WOLFSSLLIB_TRG_DIR%\src\ /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
echo;
echo Copying src\*.c files to %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src
xcopy %BASEDIR%\wolfcrypt\src\*.c %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
echo;
echo Copying src\*.i files to %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src
xcopy %BASEDIR%\wolfcrypt\src\*.i %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
echo;
echo Copying files to %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src\port\
xcopy %BASEDIR%\wolfcrypt\src\port %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src\port\ /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
echo;
echo Copying files to %WOLFSSLLIB_TRG_DIR%\wolfcrypt\test\
xcopy %BASEDIR%\wolfcrypt\test %WOLFSSLLIB_TRG_DIR%\wolfcrypt\test\ /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
:: Copy dummy test_paths.h to handle the case configure hasn't yet executed
echo;
echo Copying dummy_test_paths.h to %WOLFSSLLIB_TRG_DIR%\wolfcrypt\test\test_paths.h
echo new config > %WOLFSSLLIB_TRG_DIR%\wolfcrypt\test\test_paths.h
if %errorlevel% NEQ 0 SET COPYERROR=true
xcopy %WOLFSSL_ESPIDFDIR%\dummy_test_paths.h %WOLFSSLLIB_TRG_DIR%\wolfcrypt\test\test_paths.h /S /E /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
echo;
echo Copying files to %WOLFSSLLIB_TRG_DIR%\wolfcrypt\benchmark\
xcopy %BASEDIR%\wolfcrypt\benchmark %WOLFSSLLIB_TRG_DIR%\wolfcrypt\benchmark\ /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
echo;
echo Copying files to %WOLFSSLLIB_TRG_DIR%\wolfssl\
xcopy %BASEDIR%\wolfssl\*.h %WOLFSSLLIB_TRG_DIR%\wolfssl\ /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
echo;
echo Copying files to%WOLFSSLLIB_TRG_DIR%\wolfssl\openssl\
xcopy %BASEDIR%\wolfssl\openssl\*.h %WOLFSSLLIB_TRG_DIR%\wolfssl\openssl\ /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
echo;
echo Copying files to %WOLFSSLLIB_TRG_DIR%\wolfssl\wolfcrypt\
xcopy %BASEDIR%\wolfssl\wolfcrypt %WOLFSSLLIB_TRG_DIR%\wolfssl\wolfcrypt\ /S /E /Q /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
::******************************************************************************************************
:: user_settings and config defaults
::******************************************************************************************************
:: user_settings.h (default, may be overwritten by prior file)
echo;
echo Copying default user_settings.h to %WOLFSSLLIB_TRG_DIR%\include\
xcopy %WOLFSSL_ESPIDFDIR%\user_settings.h %WOLFSSLLIB_TRG_DIR%\include\ /F
if %errorlevel% NEQ 0 SET COPYERROR=true
:: echo Creating new config file: %WOLFSSLLIB_TRG_DIR%\include\config.h (default, may be overwritten by prior file)
echo new config > %WOLFSSLLIB_TRG_DIR%\include\config.h
xcopy %WOLFSSL_ESPIDFDIR%\dummy_config_h. %WOLFSSLLIB_TRG_DIR%\include\config.h /F /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
:: Check if operator wants to keep prior config.h
if EXIST config_h_%FileStamp%.bak (
echo;
:: clear any prior errorlevel
call;
choice /c YN /m "Use your prior config.h "
if errorlevel 2 GOTO :NO_CONFIG_RESTORE
xcopy config_h_%FileStamp%.bak %WOLFSSLLIB_TRG_DIR%\include\config.h /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
) else (
echo;
echo Prior config.h not found. Using default file.
)
::******************************************************************************************************
:NO_CONFIG_RESTORE
::******************************************************************************************************
:: Check if operator wants to keep prior config.h
if EXIST user_settings_h_%FileStamp%.bak (
echo;
:: clear any prior errorlevel
call;
choice /c YN /m "User your prior user_settings.h "
if errorlevel 2 GOTO :NO_USER_SETTINGS_RESTORE
xcopy user_settings_h_%FileStamp%.bak %WOLFSSLLIB_TRG_DIR%\include\user_settings.h /Y
if %errorlevel% NEQ 0 SET COPYERROR=true
) else (
echo;
echo Prior user_settings.h not found. Using default file.
)
::******************************************************************************************************
:NO_USER_SETTINGS_RESTORE
::******************************************************************************************************
:: unit test app
echo;
echo Copying unit files to %WOLFSSLLIB_TRG_DIR%\test\
xcopy %WOLFSSL_ESPIDFDIR%\test %WOLFSSLLIB_TRG_DIR%\test\ /S /E /Q /Y
if %errorlevel% NEQ 0 GOTO :COPYERR
echo;
echo Copying CMakeLists.txt to %WOLFSSLLIB_TRG_DIR%\
xcopy %WOLFSSL_ESPIDFDIR%\libs\CMakeLists.txt %WOLFSSLLIB_TRG_DIR%\ /F
if %errorlevel% NEQ 0 GOTO :COPYERR
echo;
echo Copying component.mk to %WOLFSSLLIB_TRG_DIR%\
xcopy %WOLFSSL_ESPIDFDIR%\libs\component.mk %WOLFSSLLIB_TRG_DIR%\ /F
if %errorlevel% NEQ 0 GOTO :COPYERR
:: Benchmark program
echo;
echo Removing %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\
rmdir %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\ /S /Q
if %errorlevel% NEQ 0 GOTO :COPYERR
echo;
echo Copying %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\main\
mkdir %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\main\
xcopy %BASEDIR%\wolfcrypt\benchmark\benchmark.c %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\main\ /F /Y
if %errorlevel% NEQ 0 GOTO :COPYERR
xcopy %WOLFSSL_ESPIDFDIR%\examples\wolfssl_benchmark %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\ /Q /Y
if %errorlevel% NEQ 0 GOTO :COPYERR
:: Crypt Test program
echo;
echo Copying %WOLFSSLEXP_TRG_DIR%\wolfssl_test\
rmdir %WOLFSSLEXP_TRG_DIR%\wolfssl_test\ /S /Q
mkdir %WOLFSSLEXP_TRG_DIR%\wolfssl_test\main\
xcopy %BASEDIR%\wolfcrypt\test\test.c %WOLFSSLEXP_TRG_DIR%\wolfssl_test\main\ /S /E /Q /Y
if %errorlevel% NEQ 0 GOTO :COPYERR
xcopy %WOLFSSL_ESPIDFDIR%\examples\wolfssl_test %WOLFSSLEXP_TRG_DIR%\wolfssl_test\ /S /E /Q /Y
if %errorlevel% NEQ 0 GOTO :COPYERR
:: TLS Client program
echo;
echo Copying %WOLFSSLEXP_TRG_DIR%\wolfssl_client\
rmdir %WOLFSSLEXP_TRG_DIR%\wolfssl_client\ /S /Q
mkdir %WOLFSSLEXP_TRG_DIR%\wolfssl_client\main\
xcopy %WOLFSSL_ESPIDFDIR%\examples\wolfssl_client %WOLFSSLEXP_TRG_DIR%\wolfssl_client\ /S /E /Q /Y
if %errorlevel% NEQ 0 GOTO :COPYERR
:: TLS Server program
echo;
echo Copying %WOLFSSLEXP_TRG_DIR%\wolfssl_server\
rmdir %WOLFSSLEXP_TRG_DIR%\wolfssl_server\ /S /Q
mkdir %WOLFSSLEXP_TRG_DIR%\wolfssl_server\main\
xcopy %WOLFSSL_ESPIDFDIR%\examples\wolfssl_server %WOLFSSLEXP_TRG_DIR%\wolfssl_server\ /S /E /Q /Y
if %errorlevel% NEQ 0 GOTO :COPYERR
goto :DONE
:: error during copy encountered
::******************************************************************************************************
:COPYERR
::******************************************************************************************************
echo;
echo Error during copy.
echo
echo Please ensure none of the target files are flagged as read-only, open, etc.
goto :ERR
:: abort at user request
::******************************************************************************************************
:NOCOPY
::******************************************************************************************************
echo;
echo Setup did not copy any files.
goto :ERR
:: ERROR
::******************************************************************************************************
:ERR
::******************************************************************************************************
exit /B 1
:: Success
::******************************************************************************************************
:DONE
::******************************************************************************************************
echo;
echo;
echo Edit config file in "%WOLFSSLLIB_TRG_DIR%\include\user_settings.h" before trying to compile.
echo;
echo See Component files for wolfSSL in %WOLFSSLLIB_TRG_DIR%
echo;
echo See additional examples at https://github.com/wolfSSL/wolfssl-examples
echo;
echo REMINDER: Ensure any wolfSSL #include definitions occur BEFORE include files in your source code.
echo;
if "%COPYERROR%" == "true" (
echo;
echo WARNING: Copy completed with errors! Check for files in use, permissions, symbolic links, etc.
echo;
)
echo setup_win.bat for ESP-IDF completed.