golang.zx2c4.com/wireguard/windows@v0.5.4-0.20230123132234-dcc0eb72a04b/installer/build.bat (about) 1 @echo off 2 rem SPDX-License-Identifier: MIT 3 rem Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved. 4 5 setlocal 6 set PATHEXT=.exe 7 set BUILDDIR=%~dp0 8 cd /d %BUILDDIR% || exit /b 1 9 10 for /f "tokens=3" %%a in ('findstr /r "Number.*=.*[0-9.]*" ..\version\version.go') do set WIREGUARD_VERSION=%%a 11 set WIREGUARD_VERSION=%WIREGUARD_VERSION:"=% 12 13 set WIX_CANDLE_FLAGS=-nologo -dWIREGUARD_VERSION="%WIREGUARD_VERSION%" 14 set WIX_LIGHT_FLAGS=-nologo -spdb 15 set WIX_LIGHT_FLAGS=%WIX_LIGHT_FLAGS% -sice:ICE39 16 set WIX_LIGHT_FLAGS=%WIX_LIGHT_FLAGS% -sice:ICE61 17 set WIX_LIGHT_FLAGS=%WIX_LIGHT_FLAGS% -sice:ICE03 18 19 if exist .deps\prepared goto :build 20 :installdeps 21 rmdir /s /q .deps 2> NUL 22 mkdir .deps || goto :error 23 cd .deps || goto :error 24 call :download wix-binaries.zip https://wixtoolset.org/downloads/v3.14.0.4118/wix314-binaries.zip 34dcbba9952902bfb710161bd45ee2e721ffa878db99f738285a21c9b09c6edb || goto :error 25 echo [+] Extracting wix-binaries.zip 26 mkdir wix\bin || goto :error 27 tar -xf wix-binaries.zip -C wix\bin || goto :error 28 echo [+] Cleaning up wix-binaries.zip 29 del wix-binaries.zip || goto :error 30 copy /y NUL prepared > NUL || goto :error 31 cd .. || goto :error 32 33 :build 34 if exist ..\sign.bat call ..\sign.bat 35 set PATH=%BUILDDIR%..\.deps\llvm-mingw\bin;%PATH% 36 set WIX=%BUILDDIR%.deps\wix\ 37 set CFLAGS=-O3 -Wall -std=gnu11 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -municode -DUNICODE -D_UNICODE -DNDEBUG 38 set LDFLAGS=-shared -s -Wl,--kill-at -Wl,--major-os-version=6 -Wl,--minor-os-version=1 -Wl,--major-subsystem-version=6 -Wl,--minor-subsystem-version=1 -Wl,--tsaware -Wl,--dynamicbase -Wl,--nxcompat -Wl,--export-all-symbols 39 set LDLIBS=-lmsi -lole32 -lshlwapi -lshell32 -luuid -lntdll 40 call :msi x86 i686 x86 || goto :error 41 call :msi amd64 x86_64 x64 || goto :error 42 call :msi arm64 aarch64 arm64 || goto :error 43 if "%SigningCertificate%"=="" goto :success 44 if "%TimestampServer%"=="" goto :success 45 echo [+] Signing 46 signtool sign /sha1 "%SigningCertificate%" /fd sha256 /tr "%TimestampServer%" /td sha256 /d "WireGuard Setup" "dist\wireguard-*-%WIREGUARD_VERSION%.msi" || goto :error 47 48 :success 49 echo [+] Success. 50 exit /b 0 51 52 :download 53 echo [+] Downloading %1 54 curl -#fLo %1 %2 || exit /b 1 55 echo [+] Verifying %1 56 for /f %%a in ('CertUtil -hashfile %1 SHA256 ^| findstr /r "^[0-9a-f]*$"') do if not "%%a"=="%~3" exit /b 1 57 goto :eof 58 59 :msi 60 set CC=%~2-w64-mingw32-gcc 61 if not exist "%~1" mkdir "%~1" 62 echo [+] Compiling %1 63 %CC% %CFLAGS% %LDFLAGS% -o "%~1\customactions.dll" customactions.c %LDLIBS% || exit /b 1 64 if "%SigningCertificate%"=="" goto :skipsign 65 if "%TimestampServer%"=="" goto :skipsign 66 echo [+] Signing %1 67 signtool sign /sha1 "%SigningCertificate%" /fd sha256 /tr "%TimestampServer%" /td sha256 /d "WireGuard Setup Custom Actions" "%~1\customactions.dll" || exit /b 1 68 :skipsign 69 "%WIX%bin\candle" %WIX_CANDLE_FLAGS% -dWIREGUARD_PLATFORM="%~1" -out "%~1\wireguard.wixobj" -arch %3 wireguard.wxs || exit /b %errorlevel% 70 echo [+] Linking %1 71 "%WIX%bin\light" %WIX_LIGHT_FLAGS% -out "dist\wireguard-%~1-%WIREGUARD_VERSION%.msi" "%~1\wireguard.wixobj" || exit /b %errorlevel% 72 goto :eof 73 74 :error 75 echo [-] Failed with error #%errorlevel%. 76 cmd /c exit %errorlevel%