Last active
October 24, 2019 08:04
-
-
Save zedalaye/0490a98b3111a11d0ad917cdb706a4ef to your computer and use it in GitHub Desktop.
Build ZeroMQ (LibZMQ/CZMQ/Zyre) Ecosystem from sources on Windows using Visual Studio 2017
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
@REM Build LibZMQ, CZMQ et Zyre with their dependencies | |
@REM Toolchain : Visual Studio 2017 | |
@REM Dependencies : CMAKE, GIT (Git for Windows), PERL (Strawberry Perl), NASM | |
@REM | |
@REM After successful build the resulting DLL are moved into zmq_build_%TODAY%\out | |
@REM | |
@REM To regenerate CZMQ/Zyre bindings a Linux system is required : | |
@REM * Ubuntu : Install build-essential and libpcre3-dev | |
@REM * Install GSL | |
@REM $ git clone https://github.com/zeromq/gsl.git | |
@REM $ cd gsl/src && make && sudo make install | |
@REM * Install ZProject | |
@REM $ git clone https://github.com/zeromq/zproject.git | |
@REM $ cd zproject && ./autogen.sh && ./configure && make && sudo make install | |
@REM * Get sources of CZMQ et Zyre | |
@REM $ git clone https://github.com/zeromq/czmq.git | |
@REM $ git clone https://github.com/zeromq/zyre.git | |
@REM * Rebuild files maintained by ZProject | |
@REM $ cd czmq && gsl project.xml | |
@REM $ cd zyre && gsl project.xml | |
if not defined VisualStudioVersion ( | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\vsdevcmd.bat" | |
) | |
@REM Check for presence of useful binaries | |
call :_which git.exe Git | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
call :_which cmake.exe CMake | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
call :_which msbuild.exe MSBuild | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
call :_which nmake.exe NMake | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
call :_which perl.exe Perl | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
call :_which nasm.exe MASM | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
@REM Bare clone repositories of ZeroMQ and its dependencies | |
if not exist sources ( | |
mkdir sources | |
) | |
pushd sources | |
call :_get_sources curl https://github.com/curl/curl.git | |
call :_get_sources czmq https://github.com/zeromq/czmq.git | |
call :_get_sources libmicrohttpd https://git.gnunet.org/libmicrohttpd.git | |
call :_get_sources libsodium https://github.com/jedisct1/libsodium.git | |
call :_get_sources libzmq https://github.com/zeromq/libzmq.git | |
call :_get_sources lz4 https://github.com/lz4/lz4.git | |
call :_get_sources nghttp2 https://github.com/nghttp2/nghttp2.git | |
call :_get_sources openssl https://github.com/openssl/openssl.git | |
call :_get_sources zyre https://github.com/zeromq/zyre.git | |
popd | |
@REM Build a timestamped root directory | |
for /f %%X in ('wmic path win32_localtime get Year^,Month^,Day /format:list ^| findstr "="') do (set %%X) | |
set TODAY=%Year%-%Month%-%Day% | |
set BUILD_ROOT=%~dp0 | |
set BUILD_ROOT=!BUILD_ROOT:~0,-1!\zmq_build_%TODAY% | |
set TODAY= | |
@REM Prepare working directory | |
if exist %BUILD_ROOT% ( | |
rd %BUILD_ROOT% /S /Q | |
) | |
mkdir %BUILD_ROOT% | |
mkdir %BUILD_ROOT%\out | |
mkdir %BUILD_ROOT%\deps | |
mkdir %BUILD_ROOT%\deps\bin | |
mkdir %BUILD_ROOT%\deps\include | |
mkdir %BUILD_ROOT%\deps\include\nghttp2 | |
mkdir %BUILD_ROOT%\deps\lib | |
cd %BUILD_ROOT% | |
@REM Build OpenSSL | |
call :_clone_local openssl | |
git checkout OpenSSL_1_0_2-stable | |
perl Configure VC-WIN32 shared --prefix=%BUILD_ROOT%\deps | |
call ms\do_nasm.bat | |
nmake -f ms\ntdll.mak | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
nmake -f ms\ntdll.mak test | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
nmake -f ms\ntdll.mak install | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
@REM Build LibSodium | |
call :_clone_local libsodium | |
cd builds\msvc\vs2017 | |
msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=Win32 libsodium.sln | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
@REM Build LibZMQ | |
call :_clone_local libzmq | |
cmake -G"Visual Studio 15 2017"^ | |
-DSODIUM_LIBRARIES=..\libsodium\bin\Win32\Release\v141\dynamic\libsodium.lib^ | |
-DSODIUM_INCLUDE_DIRS=..\libsodium\src\libsodium\include^ | |
-DWITH_LIBSODIUM=1^ | |
-DPOLLER=epoll^ | |
-DCMAKE_BUILD_TYPE=Release^ | |
--enable-drafts^ | |
-H.^ | |
-Bbuild | |
cmake --build build --config Release | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
@REM Build NgHTTP2 | |
call :_clone_local nghttp2 | |
cmake -G"Visual Studio 15 2017"^ | |
-DCMAKE_BUILD_TYPE=Release^ | |
-DENABLE_LIB_ONLY=ON^ | |
-DENABLE_STATIC_LIB=ON^ | |
-DENABLE_SHARED_LIB=OFF^ | |
-H.^ | |
-Bbuild | |
cmake --build build --config Release | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
copy nghttp2\build\lib\includes\nghttp2\*.h %BUILD_ROOT%\deps\include\nghttp2\ | |
copy nghttp2\lib\includes\nghttp2\*.h %BUILD_ROOT%\deps\include\nghttp2\ | |
copy nghttp2\build\lib\Release\nghttp2_static.lib %BUILD_ROOT%\deps\lib\ | |
@REM Build LibCURL | |
call :_clone_local curl | |
call buildconf.bat | |
cd winbuild | |
nmake /f Makefile.vc mode=dll machine=x86 with_ssl=dll with_nghttp2=static with_prefix=%BUILD_ROOT%\deps | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
@REM Build LibMicroHTTPd | |
call :_clone_local libmicrohttpd | |
git apply ..\..\libmicrohttpd_fix_windows_build.diff | |
cd w32\VS2017 | |
msbuild /m /v:n /p:Configuration="Release-static" /p:Platform=Win32 libmicrohttpd.sln | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
@REM Build LZ4 | |
call :_clone_local lz4 | |
cd visual\VS2017 | |
msbuild /m /v:n /p:Configuration=Release /p:Platform=Win32 lz4.sln | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
@REM Build CZMQ | |
call :_clone_local czmq | |
cmake -G"Visual Studio 15 2017"^ | |
-DCMAKE_BUILD_TYPE=Release^ | |
-DENABLE_DRAFTS=yes^ | |
-DLIBZMQ_LIBRARIES=..\libzmq\build\lib\Release\libzmq-v141-mt-4_3_3.lib^ | |
-DLIBZMQ_INCLUDE_DIRS=..\libzmq\include^ | |
-DLIBMICROHTTPD_LIBRARIES=..\libmicrohttpd\w32\VS2017\Output\libmicrohttpd.lib^ | |
-DLIBMICROHTTPD_INCLUDE_DIRS=..\libmicrohttpd\w32\VS2017\Output^ | |
-DLZ4_LIBRARIES=..\lz4\visual\VS2017\bin\Win32_Release\liblz4_static.lib^ | |
-DLZ4_INCLUDE_DIRS=..\lz4\lib^ | |
-DLIBCURL_LIBRARIES=..\deps\lib\libcurl.lib^ | |
-DLIBCURL_INCLUDE_DIRS=..\curl\include^ | |
-H.^ | |
-Bbuild | |
cmake --build build --config Release | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
@REM Build Zyre | |
call :_clone_local zyre | |
cmake -G"Visual Studio 15 2017"^ | |
-DCMAKE_BUILD_TYPE=Release^ | |
-DLIBZMQ_LIBRARIES=..\libzmq\build\lib\Release\libzmq-v141-mt-4_3_3.lib^ | |
-DLIBZMQ_INCLUDE_DIRS=..\libzmq\include^ | |
-DCZMQ_LIBRARIES=..\czmq\build\Release\czmq.lib^ | |
-DCZMQ_INCLUDE_DIRS=..\czmq\include^ | |
-DENABLE_DRAFTS=yes^ | |
-H.^ | |
-Bbuild | |
cmake --build build --config Release | |
if %ERRORLEVEL% GEQ 1 goto :eof | |
popd | |
@REM Copy compiled librairies into %BUILD_ROOT%\out | |
copy deps\bin\*.dll %BUILD_ROOT%\out\ | |
copy libsodium\bin\Win32\Release\v141\dynamic\libsodium.dll %BUILD_ROOT%\out\ | |
copy libzmq\build\bin\Release\libzmq-v141-mt-4_3_3.dll %BUILD_ROOT%\out\ | |
copy czmq\build\Release\libczmq.dll %BUILD_ROOT%\out\ | |
copy zyre\build\Release\libzyre.dll %BUILD_ROOT%\out\ | |
@echo( | |
@echo Done. | |
@echo Build was done into: %BUILD_ROOT% | |
@echo Libraries have been moved to: %BUILD_ROOT%\out | |
goto :eof | |
:_which | |
@REM Check if an executable exists | |
for %%X in (%1) do (set FOUND=%%~$PATH:X) | |
if not defined FOUND ( | |
@echo %2 not found, bye | |
exit /B 1 | |
) | |
exit /B 0 | |
:_get_sources | |
@REM Clone or update a bare git repository | |
if exist .\%1.git\ ( | |
cd %1.git | |
git fetch | |
cd .. | |
) else ( | |
git clone --bare %2 %1.git | |
) | |
exit /B 0 | |
:_clone_local | |
@REM Prepare local worktree by cloning local bare repo and moving into it | |
cd %BUILD_ROOT% | |
git clone ..\sources\%1.git %1 | |
pushd %1 | |
exit /B 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
w32/common/libmicrohttpd-files.vcxproj | 2 ++ | |
1 file changed, 2 insertions(+) | |
diff --git a/w32/common/libmicrohttpd-files.vcxproj b/w32/common/libmicrohttpd-files.vcxproj | |
index 512c18bb..e4f2cada 100644 | |
--- a/w32/common/libmicrohttpd-files.vcxproj | |
+++ b/w32/common/libmicrohttpd-files.vcxproj | |
@@ -21,6 +21,7 @@ | |
<ClCompile Include="$(MhdSrc)microhttpd\mhd_sockets.c" /> | |
<ClCompile Include="$(MhdSrc)microhttpd\mhd_itc.c" /> | |
<ClCompile Include="$(MhdSrc)microhttpd\mhd_compat.c" /> | |
+ <ClCompile Include="$(MhdSrc)microhttpd\mhd_send.c" /> | |
</ItemGroup> | |
<ItemGroup> | |
<ClInclude Include="$(MhdSrc)include\autoinit_funcs.h" /> | |
@@ -48,6 +49,7 @@ | |
<ClInclude Include="$(MhdSrc)microhttpd\mhd_itc.h" /> | |
<ClInclude Include="$(MhdSrc)microhttpd\mhd_itc_types.h" /> | |
<ClInclude Include="$(MhdSrc)microhttpd\mhd_compat.h" /> | |
+ <ClInclude Include="$(MhdSrc)microhttpd\mhd_send.h" /> | |
<ClInclude Include="$(MhdW32Common)MHD_config.h" /> | |
</ItemGroup> | |
<ItemGroup> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment