aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/build.bat
diff options
context:
space:
mode:
Diffstat (limited to 'build.bat')
-rw-r--r--build.bat45
1 files changed, 27 insertions, 18 deletions
diff --git a/build.bat b/build.bat
index 0c8f1831..082310d2 100644
--- a/build.bat
+++ b/build.bat
@@ -1,21 +1,8 @@
@echo off
set STARTDIR=%cd%
set OLDPATH=%PATH%
-if not exist deps\.prepared call :installdeps
-set PATH=%STARTDIR%\deps\x86_64-w64-mingw32-native\bin\;%STARTDIR%\deps\go\bin\;%PATH%
-set CC=x86_64-w64-mingw32-gcc.exe
-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
-goto :out
+if exist deps\.prepared goto :build
:installdeps
rmdir /s /q deps 2> NUL
mkdir deps || goto :error
@@ -24,19 +11,41 @@ goto :out
curl -#fo go.zip https://dl.google.com/go/go1.12.windows-amd64.zip || goto :error
echo Downloading mingw
curl -#fo mingw.zip https://musl.cc/x86_64-w64-mingw32-native.zip || goto :error
+ echo Downloading patch
+ curl -L#fo patch.zip https://sourceforge.net/projects/gnuwin32/files/patch/2.5.9-7/patch-2.5.9-7-bin.zip || goto :error
echo Extracting golang
tar -xf go.zip || goto :error
echo Extracting mingw
tar -xf mingw.zip || goto :error
+ echo Extracting patch
+ tar -xf patch.zip --strip-components 1 bin || goto :error
+ echo Patching golang
+ .\patch.exe -f -N -r- -d go -p1 --binary < ..\golang-runtime-dll-injection.patch || goto :error
echo Cleaning up
- del go.zip mingw.zip || goto :error
+ del patch.exe patch.zip go.zip mingw.zip || goto :error
copy /y NUL .prepared > NUL || goto :error
cd .. || goto :error
- exit /b
-:error
- echo Failed with error #%errorlevel%.
+: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 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
+ echo Success. Launch wireguard.exe.
+
:out
set PATH=%OLDPATH%
cd %STARTDIR%
exit /b %errorlevel%
+
+:error
+ echo Failed with error #%errorlevel%.
+ goto :out