2 rem ***************************************************************************
4 rem * Project ___| | | | _ \| |
5 rem * / __| | | | |_) | |
6 rem * | (__| |_| | _ <| |___
7 rem * \___|\___/|_| \_\_____|
9 rem * Copyright (C) 2012 - 2015, Steve Holme, <steve_holme@hotmail.com>.
10 rem * Copyright (C) 2015, Jay Satiro, <raysatiro@yahoo.com>.
12 rem * This software is licensed as described in the file COPYING, which
13 rem * you should have received as part of this distribution. The terms
14 rem * are also available at http://curl.haxx.se/docs/copyright.html.
16 rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 rem * copies of the Software, and permit persons to whom the Software is
18 rem * furnished to do so, under the terms of the COPYING file.
20 rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 rem * KIND, either express or implied.
23 rem ***************************************************************************
26 rem Check we are running on a Windows NT derived OS
27 if not "%OS%" == "Windows_NT" goto nodos
31 set SUCCESSFUL_BUILDS=
35 rem Ensure we have the required arguments
36 if /i "%~1" == "" goto syntax
39 if "%~1" == "" goto prerequisites
41 if /i "%~1" == "vc10" (
45 set "VC_PATH=Microsoft Visual Studio 10.0\VC"
46 ) else if /i "%~1" == "vc11" (
50 set "VC_PATH=Microsoft Visual Studio 11.0\VC"
51 ) else if /i "%~1" == "vc12" (
55 set "VC_PATH=Microsoft Visual Studio 12.0\VC"
56 ) else if /i "%~1" == "vc14" (
60 set "VC_PATH=Microsoft Visual Studio 14.0\VC"
61 ) else if /i "%~1" == "x86" (
62 set BUILD_PLATFORM=x86
63 ) else if /i "%~1" == "x64" (
64 set BUILD_PLATFORM=x64
65 ) else if /i "%~1" == "debug" (
66 set BUILD_CONFIG=debug
67 ) else if /i "%~1" == "release" (
68 set BUILD_CONFIG=release
69 ) else if /i "%~1" == "-?" (
71 ) else if /i "%~1" == "-h" (
73 ) else if /i "%~1" == "-help" (
76 if not defined START_DIR (
83 shift & goto parseArgs
86 rem Compiler and platform are required parameters.
87 if not defined VC_VER goto syntax
88 if not defined BUILD_PLATFORM goto syntax
90 rem Default the start directory if one isn't specified
91 if not defined START_DIR set START_DIR=..\..\wolfssl
93 rem Calculate the program files directory
94 if defined PROGRAMFILES (
95 set "PF=%PROGRAMFILES%"
98 if defined PROGRAMFILES(x86) (
99 set "PF=%PROGRAMFILES(x86)%"
103 rem Check we have a program files directory
104 if not defined PF goto nopf
106 rem Check we have Visual Studio installed
107 if not exist "%PF%\%VC_PATH%" goto novc
109 rem Check the start directory exists
110 if not exist "%START_DIR%" goto nowolfssl
113 if "%BUILD_PLATFORM%" == "" set BUILD_PLATFORM=%OS_PLATFORM%
115 if "%BUILD_PLATFORM%" == "x86" (
116 set VCVARS_PLATFORM=x86
117 ) else if "%BUILD_PLATFORM%" == "x64" (
118 if "%VC_VER%" == "10.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
119 if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64
120 if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64
121 if "%VC_VER%" == "14.0" set VCVARS_PLATFORM=amd64
126 call "%PF%\%VC_PATH%\vcvarsall" %VCVARS_PLATFORM%
131 goto %BUILD_PLATFORM%
134 rem Calculate our output directory
135 set OUTDIR=build\Win64\%VC_DESC%
136 if not exist %OUTDIR% md %OUTDIR%
138 if "%BUILD_CONFIG%" == "release" goto x64release
141 rem Perform 64-bit Debug Build
143 call :build Debug x64
144 if errorlevel 1 goto error
146 call :build "DLL Debug" x64
147 if errorlevel 1 goto error
149 if "%BUILD_CONFIG%" == "debug" goto success
152 rem Perform 64-bit Release Build
154 call :build Release x64
155 if errorlevel 1 goto error
157 call :build "DLL Release" x64
158 if errorlevel 1 goto error
163 rem Calculate our output directory
164 set OUTDIR=build\Win32\%VC_DESC%
165 if not exist %OUTDIR% md %OUTDIR%
167 if "%BUILD_CONFIG%" == "release" goto x86release
170 rem Perform 32-bit Debug Build
172 call :build Debug Win32
173 if errorlevel 1 goto error
175 call :build "DLL Debug" Win32
176 if errorlevel 1 goto error
178 if "%BUILD_CONFIG%" == "debug" goto success
181 rem Perform 32-bit Release Build
183 call :build Release Win32
184 if errorlevel 1 goto error
186 call :build "DLL Release" Win32
187 if errorlevel 1 goto error
192 rem This function builds wolfSSL.
193 rem Usage: CALL :build <configuration> <platform>
194 rem The current directory must be the wolfSSL directory.
195 rem VS Configuration: Debug, Release, DLL Debug or DLL Release.
196 rem VS Platform: Win32 or x64.
197 rem Returns: 1 on fail, 0 on success.
198 rem An informational message should be shown before any return.
200 set MSBUILD_CONFIG=%~1
201 set MSBUILD_PLATFORM=%~2
203 if not exist wolfssl64.sln (
205 echo Error: build: wolfssl64.sln not found in "%CD%"
209 rem OUTDIR isn't a full path, only relative. MSBUILD_OUTDIR must be full and
210 rem not have trailing backslashes, which are handled later.
211 if "%MSBUILD_CONFIG%" == "Debug" (
212 set "MSBUILD_OUTDIR=%CD%\%OUTDIR%\LIB Debug"
213 ) else if "%MSBUILD_CONFIG%" == "Release" (
214 set "MSBUILD_OUTDIR=%CD%\%OUTDIR%\LIB Release"
215 ) else if "%MSBUILD_CONFIG%" == "DLL Debug" (
216 set "MSBUILD_OUTDIR=%CD%\%OUTDIR%\DLL Debug"
217 ) else if "%MSBUILD_CONFIG%" == "DLL Release" (
218 set "MSBUILD_OUTDIR=%CD%\%OUTDIR%\DLL Release"
221 echo Error: build: Configuration not recognized.
225 if not "%MSBUILD_PLATFORM%" == "Win32" if not "%MSBUILD_PLATFORM%" == "x64" (
227 echo Error: build: Platform not recognized.
231 copy /v /y "%~dp0\wolfssl_options.h" .\cyassl\options.h
232 if %ERRORLEVEL% neq 0 (
234 echo Error: build: Couldn't replace .\cyassl\options.h
238 copy /v /y "%~dp0\wolfssl_options.h" .\wolfssl\options.h
239 if %ERRORLEVEL% neq 0 (
241 echo Error: build: Couldn't replace .\wolfssl\options.h
245 rem Extra trailing \ in Dirs because otherwise it thinks a quote is escaped
246 msbuild wolfssl64.sln ^
247 -p:CustomAfterMicrosoftCommonTargets="%~dp0\wolfssl_override.props" ^
248 -p:Configuration="%MSBUILD_CONFIG%" ^
249 -p:Platform="%MSBUILD_PLATFORM%" ^
250 -p:PlatformToolset="%VC_TOOLSET%" ^
251 -p:OutDir="%MSBUILD_OUTDIR%\\" ^
252 -p:IntDir="%MSBUILD_OUTDIR%\obj\\"
254 if %ERRORLEVEL% neq 0 (
256 echo Error: Failed building wolfSSL %MSBUILD_CONFIG%^|%MSBUILD_PLATFORM%.
260 rem For tests to run properly the wolfSSL directory must remain the current.
261 set "PATH=%MSBUILD_OUTDIR%;%PATH%"
262 "%MSBUILD_OUTDIR%\testsuite.exe"
264 if %ERRORLEVEL% neq 0 (
266 echo Error: Failed testing wolfSSL %MSBUILD_CONFIG%^|%MSBUILD_PLATFORM%.
271 echo Success: Built and tested wolfSSL %MSBUILD_CONFIG%^|%MSBUILD_PLATFORM%.
274 rem This is necessary to export our local variables back to the caller.
275 endlocal & set SUCCESSFUL_BUILDS="%MSBUILD_CONFIG%|%MSBUILD_PLATFORM%" ^
282 echo Usage: build-wolfssl ^<compiler^> ^<platform^> [configuration] [directory]
286 echo vc10 - Use Visual Studio 2010
287 echo vc11 - Use Visual Studio 2012
288 echo vc12 - Use Visual Studio 2013
289 echo vc14 - Use Visual Studio 2015
293 echo x86 - Perform a 32-bit build
294 echo x64 - Perform a 64-bit build
298 echo debug - Perform a debug build
299 echo release - Perform a release build
303 echo directory - Specifies the wolfSSL source directory
308 echo Error: Unknown argument '%1'
313 echo Error: Only a Windows NT based Operating System is supported
318 echo Error: Cannot obtain the directory for Program Files
323 echo Error: %VC_DESC% is not installed
328 echo Error: %VC_DESC% does not support 64-bit builds
333 echo Error: Cannot locate wolfSSL source directory, expected "%START_DIR%"
337 if "%OS%" == "Windows_NT" endlocal
341 if defined SUCCESSFUL_BUILDS (
346 echo The following configurations were built and tested successfully:
348 echo %SUCCESSFUL_BUILDS%