aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-04-25 12:17:42 +0200
committerSimon Rozman <simon@rozman.si>2019-04-25 12:17:42 +0200
commit62437f07f08b7044fcec67a166d190d5104de211 (patch)
tree43eef5db4da923176f168a2d2e5ea9be5020ec4a
parentinstaller: unify dependency downloading (diff)
downloadwireguard-windows-62437f07f08b7044fcec67a166d190d5104de211.tar.xz
wireguard-windows-62437f07f08b7044fcec67a166d190d5104de211.zip
build: extend to build x86 and amd64
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r--.gitignore12
-rw-r--r--build.bat54
-rw-r--r--installer/wireguard.wxs2
3 files changed, 45 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore
index 7fbadcea..dcb7cf60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,14 @@
-*.exe
+# Dependencies
+/.deps
+
+# Build Output
+/x86
+/amd64
+
+# Misc
+/go.sum
+/sign.bat
*.swp
*.bak
*.syso
.idea
-.deps
diff --git a/build.bat b/build.bat
index f8a43b54..fa2fda5d 100644
--- a/build.bat
+++ b/build.bat
@@ -10,44 +10,38 @@ if exist .deps\prepared goto :build
rmdir /s /q .deps 2> NUL
mkdir .deps || goto :error
cd .deps || goto :error
- echo [+] Downloading golang
- curl -#fo go.zip https://dl.google.com/go/go1.12.3.windows-amd64.zip || goto :error
- echo [+] Verifying golang
- for /f %%a in ('CertUtil -hashfile go.zip SHA256 ^| findstr /r "^[0-9a-f]*$"') do if not "%%a"=="1806e089e85b84f192d782a7f70f90a32e0eccfd181405857e612f806ec04059" goto :error
- echo [+] Downloading mingw
+ call :download go.zip https://dl.google.com/go/go1.12.3.windows-amd64.zip 1806e089e85b84f192d782a7f70f90a32e0eccfd181405857e612f806ec04059 || goto :error
+ rem Mirror of https://musl.cc/i686-w64-mingw32-native.zip
+ call :download mingw-x86.zip https://download.wireguard.com/windows-toolchain/distfiles/i686-w64-mingw32-native-20190425.zip 5810b4a9af34c12690ec355ad2a237d2a4c16f5e8cb68988dc0f2e48457534d0 || goto :error
rem Mirror of https://musl.cc/x86_64-w64-mingw32-native.zip
- curl -#fo mingw.zip https://download.wireguard.com/windows-toolchain/distfiles/x86_64-w64-mingw32-native-20190307.zip || goto :error
- echo [+] Verifying mingw
- for /f %%a in ('CertUtil -hashfile mingw.zip SHA256 ^| findstr /r "^[0-9a-f]*$"') do if not "%%a"=="5390762183e181804b28eb13815b6210f85a1280057b815f749b06768215f817" goto :error
- echo [+] Extracting golang
+ call :download mingw-amd64.zip https://download.wireguard.com/windows-toolchain/distfiles/x86_64-w64-mingw32-native-20190307.zip 5390762183e181804b28eb13815b6210f85a1280057b815f749b06768215f817 || goto :error
+ echo [+] Extracting go.zip
tar -xf go.zip || goto :error
- echo [+] Extracting mingw
- tar -xf mingw.zip || goto :error
+ echo [+] Extracting mingw-x86.zip
+ tar -xf mingw-x86.zip || goto :error
+ echo [+] Extracting mingw-amd64.zip
+ tar -xf mingw-amd64.zip || goto :error
echo [+] Cleaning up
- del go.zip mingw.zip || goto :error
+ del go.zip mingw-x86.zip mingw-amd64.zip || goto :error
copy /y NUL prepared > NUL || goto :error
cd .. || goto :error
:build
- set PATH=%STARTDIR%\.deps\x86_64-w64-mingw32-native\bin\;%STARTDIR%\.deps\go\bin\;%PATH%
- set CC=x86_64-w64-mingw32-gcc.exe
+ set PATH=%STARTDIR%\.deps\go\bin\;%PATH%
set CFLAGS=-O3 -Wall -std=gnu11
set GOOS=windows
- set GOARCH=amd64
set GOPATH=%STARTDIR%\.deps\gopath
set GOROOT=%STARTDIR%\.deps\go
set CGO_ENABLED=1
- echo [+] Assembling resources
- windres.exe -i resources.rc -o resources.syso -O coff || goto :error
- echo [+] Building program
- go build -ldflags="-H windowsgui -s -w" -v -o wireguard.exe || goto :error
+ call :build_plat x86 "%STARTDIR%\.deps\i686-w64-mingw32-native\bin" i686-w64-mingw32-gcc.exe 386 || goto :error
+ call :build_plat amd64 "%STARTDIR%\.deps\x86_64-w64-mingw32-native\bin" x86_64-w64-mingw32-gcc.exe amd64 || goto :error
:sign
if exist .\sign.bat call .\sign.bat
if "%SigningCertificate%"=="" goto :success
if "%TimestampServer%"=="" goto :success
echo [+] Signing
- signtool.exe sign /sha1 "%SigningCertificate%" /fd sha256 /tr "%TimestampServer%" /td sha256 /d WireGuard wireguard.exe || goto :error
+ signtool.exe sign /sha1 "%SigningCertificate%" /fd sha256 /tr "%TimestampServer%" /td sha256 /d WireGuard x86\wireguard.exe amd64\wireguard.exe || goto :error
:success
echo [+] Success. Launch wireguard.exe.
@@ -60,3 +54,23 @@ if exist .deps\prepared goto :build
:error
echo [-] Failed with error #%errorlevel%.
goto :out
+
+:download
+ echo [+] Downloading %1
+ curl -#fLo %1 %2 || exit /b %errorlevel%
+ echo [+] Verifying %1
+ for /f %%a in ('CertUtil -hashfile %1 SHA256 ^| findstr /r "^[0-9a-f]*$"') do if not "%%a"=="%~3" exit /b 1
+ goto :eof
+
+:build_plat
+ set OLDPATH2=%PATH%
+ set PATH=%~2;%PATH%
+ set CC=%~3
+ set GOARCH=%~4
+ mkdir %1 >NUL 2>&1
+ echo [+] Assembling resources %1
+ windres.exe -i resources.rc -o resources.syso -O coff || exit /b %errorlevel%
+ echo [+] Building program %1
+ go build -ldflags="-H windowsgui -s -w" -v -o "%~1\wireguard.exe" || exit /b %errorlevel%
+ set PATH=%OLDPATH2%
+ goto :eof
diff --git a/installer/wireguard.wxs b/installer/wireguard.wxs
index ba416e2c..49ba8f45 100644
--- a/installer/wireguard.wxs
+++ b/installer/wireguard.wxs
@@ -72,7 +72,7 @@
-->
<ComponentGroup Id="WireGuardComponents">
<Component Directory="INSTALLFOLDER" Id="WireGuardExecutable" Guid="c3508d23-3362-47ce-9220-321bdb1a1acc">
- <File Source="..\wireguard.exe" KeyPath="yes">
+ <File Source="..\$(var.Platform)\wireguard.exe" KeyPath="yes">
<Shortcut Id="WireGuardStartMenuShortcut" Directory="ProgramMenuFolder" Name="WireGuard" Description="WireGuard: Fast, Modern, Secure VPN Tunnel" WorkingDirectory="INSTALLFOLDER" Advertise="yes" />
</File>
<ServiceControl Id="RemoveWireGuardManagerService" Name="WireGuardManager" Remove="both" Stop="both"></ServiceControl>