James E. King, III | 4d651ab | 2017-02-19 22:19:55 -0500 | [diff] [blame] | 1 | :: |
| 2 | :: Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | :: you may not use this file except in compliance with the License. |
| 4 | :: You may obtain a copy of the License at |
| 5 | :: |
| 6 | :: http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | :: |
| 8 | :: Unless required by applicable law or agreed to in writing, software |
| 9 | :: distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | :: See the License for the specific language governing permissions and |
| 12 | :: limitations under the License. |
| 13 | :: |
| 14 | |
| 15 | :: |
| 16 | :: Build script for libevent on windows |
| 17 | :: Use libevent master from github which has cmake integration |
| 18 | :: Uses the environment set up by a Visual Studio Command Prompt shortcut |
| 19 | :: to target a specific architecture and compiler |
| 20 | :: |
| 21 | :: Creates a static link library. |
| 22 | :: Links against OpenSSL and zlib statically. |
| 23 | :: |
| 24 | |
| 25 | @ECHO OFF |
| 26 | SETLOCAL EnableDelayedExpansion |
| 27 | |
| 28 | :: Sets variables for third party versions used in build |
| 29 | CALL ..\..\scripts\tpversions.bat || EXIT /B |
| 30 | |
| 31 | :: use "build-libevent.bat /yes" to skip the question part |
| 32 | IF /I "%1" == "/YES" SET NOASK=1 |
| 33 | |
| 34 | :: Set COMPILER to (vc100 - vc140) depending on the current environment |
| 35 | CALL ..\..\scripts\cl_setcompiler.bat || EXIT /B |
| 36 | |
| 37 | :: Set ARCH to either win32 or x64 depending on the current environment |
| 38 | CALL ..\..\scripts\cl_setarch.bat || EXIT /B |
| 39 | |
| 40 | IF NOT DEFINED GENERATOR SET GENERATOR=NMake Makefiles |
| 41 | IF NOT DEFINED PACKAGE_NAME SET PACKAGE_NAME=libevent |
| 42 | IF NOT DEFINED PACKAGE_VERSION SET PACKAGE_VERSION=%TP_LIBEVENT_VERSION% |
| 43 | IF NOT DEFINED SOURCEDIR SET SOURCEDIR=%~dp0%PACKAGE_NAME%-%PACKAGE_VERSION% |
| 44 | IF NOT DEFINED WIN3P_ROOT SET WIN3P_ROOT=%~dp0.. |
| 45 | |
| 46 | FOR %%X IN ( |
| 47 | Debug |
| 48 | Release |
| 49 | ) DO ( |
| 50 | SET BUILDTYPE=%%X |
| 51 | SET BUILDDIR=%WIN3P_ROOT%\build\%PACKAGE_NAME%\%PACKAGE_VERSION%\%COMPILER%\%ARCH%\!BUILDTYPE! |
| 52 | SET OUTDIR=%WIN3P_ROOT%\dist\%PACKAGE_NAME%-%PACKAGE_VERSION%\%COMPILER%\%ARCH%\!BUILDTYPE! |
| 53 | |
| 54 | IF "!BUILDTYPE!" == "Debug" (SET ZLIB_LIB_SUFFIX=d) |
| 55 | |
| 56 | SET CMAKE_DEFS=^ |
| 57 | -DEVENT__DISABLE_SAMPLES=ON ^ |
| 58 | -DEVENT__DISABLE_TESTS=ON ^ |
| 59 | -DOPENSSL_USE_STATIC_LIBS=OFF ^ |
| 60 | -DOPENSSL_ROOT_DIR=%WIN3P_ROOT%\dist\openssl-%TP_OPENSSL_VERSION%\%COMPILER%\%ARCH%\!BUILDTYPE!\dynamic ^ |
| 61 | -DZLIB_LIBRARY=%WIN3P_ROOT%\dist\zlib-%TP_ZLIB_VERSION%\%COMPILER%\%ARCH%\lib\zlib!ZLIB_LIB_SUFFIX!.lib ^ |
| 62 | -DZLIB_ROOT=%WIN3P_ROOT%\dist\zlib-%TP_ZLIB_VERSION%\%COMPILER%\%ARCH% |
| 63 | |
| 64 | ECHO/ |
| 65 | ECHO ========================================================================= |
| 66 | ECHO Building: %PACKAGE_NAME% v%PACKAGE_VERSION% %COMPILER%:%ARCH%:!BUILDTYPE! "%GENERATOR%" |
| 67 | ECHO CMake Definitions: !CMAKE_DEFS! |
| 68 | ECHO Build Directory: !BUILDDIR! |
| 69 | ECHO Install Directory: !OUTDIR! |
| 70 | ECHO Source Directory: %SOURCEDIR% |
| 71 | ECHO ========================================================================= |
| 72 | ECHO/ |
| 73 | |
| 74 | IF NOT DEFINED NOASK ( |
| 75 | CHOICE /M "Do you want to build this configuration? " /c YN |
| 76 | IF !ERRORLEVEL! NEQ 1 (EXIT /B !ERRORLEVEL!) |
| 77 | ) |
| 78 | |
| 79 | MKDIR "!BUILDDIR!" |
| 80 | CD "!BUILDDIR!" || EXIT /B |
| 81 | |
| 82 | CMAKE.EXE -G"%GENERATOR%" -DCMAKE_INSTALL_PREFIX=!OUTDIR! -DCMAKE_BUILD_TYPE=!BUILDTYPE! !CMAKE_DEFS! "%SOURCEDIR%" || EXIT /B |
| 83 | NMAKE /fMakefile install || EXIT /B |
| 84 | ) |
| 85 | |
| 86 | ENDLOCAL |