aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-08-09 08:57:30 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-08-12 09:11:27 +0200
commitd7571e1ed4070a50324f1c9a3e8755e57bb841ab (patch)
tree6e4c5e64e7315a56f8e67d374eaa7926506cbb8c
parentinstaller: port custom actions from JScript to C (diff)
downloadwireguard-windows-d7571e1ed4070a50324f1c9a3e8755e57bb841ab.tar.xz
wireguard-windows-d7571e1ed4070a50324f1c9a3e8755e57bb841ab.zip
build: use setlocal to keep build environment local
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r--build.bat16
-rw-r--r--installer/build.bat21
2 files changed, 12 insertions, 25 deletions
diff --git a/build.bat b/build.bat
index 235c480f..f6a5d304 100644
--- a/build.bat
+++ b/build.bat
@@ -2,12 +2,11 @@
rem SPDX-License-Identifier: MIT
rem Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
+setlocal
set BUILDDIR=%~dp0
-set OLDPATH=%PATH%
set PATH=%BUILDDIR%.deps\go\bin;%BUILDDIR%.deps;%PATH%
-set OLDPATHEXT=%PATHEXT%
set PATHEXT=.exe
-pushd %BUILDDIR% || exit /b 1
+cd /d %BUILDDIR% || exit /b 1
if exist .deps\prepared goto :render
:installdeps
@@ -51,16 +50,11 @@ if exist .deps\prepared goto :render
:success
echo [+] Success. Launch wireguard.exe.
-
-:out
- set PATH=%OLDPATH%
- set PATHEXT=%OLDPATHEXT%
- popd
- exit /b %errorlevel%
+ exit /b 0
:error
echo [-] Failed with error #%errorlevel%.
- goto :out
+ exit /b %errorlevel%
:download
echo [+] Downloading %1
@@ -74,7 +68,6 @@ if exist .deps\prepared goto :render
goto :eof
:build_plat
- set OLDPATH2=%PATH%
set PATH=%BUILDDIR%.deps\%~2-w64-mingw32-native\bin;%PATH%
set CC=%~2-w64-mingw32-gcc
set GOARCH=%~3
@@ -89,5 +82,4 @@ if exist .deps\prepared goto :render
make --no-print-directory -C .deps\src\tools PLATFORM=windows CC=%CC% V=1 LDFLAGS=-s RUNSTATEDIR= SYSTEMDUNITDIR= -j%NUMBER_OF_PROCESSORS% || exit /b 1
move /Y .deps\src\tools\wg.exe "%~1\wg.exe" > NUL || exit /b 1
)
- set PATH=%OLDPATH2%
goto :eof
diff --git a/installer/build.bat b/installer/build.bat
index a0a17c27..295ce437 100644
--- a/installer/build.bat
+++ b/installer/build.bat
@@ -2,11 +2,10 @@
rem SPDX-License-Identifier: MIT
rem Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
-set OLDWIX=%WIX%
-set OLDPATHEXT=%PATHEXT%
+setlocal
set PATHEXT=.exe
set BUILDDIR=%~dp0
-pushd %BUILDDIR% || exit /b 1
+cd /d %BUILDDIR% || exit /b 1
for /f "tokens=3" %%a in ('findstr /r "WIREGUARD_WINDOWS_VERSION_STRING.*[0-9.]*" ..\version.h') do set WIREGUARD_VERSION=%%a
set WIREGUARD_VERSION=%WIREGUARD_VERSION:"=%
@@ -39,20 +38,18 @@ if exist .deps\prepared goto :build
call :msi x86 i686 x86 || goto :error
call :msi amd64 x86_64 x64 || goto :error
if exist ..\sign.bat call ..\sign.bat
- if "%SigningCertificate%"=="" goto :out
- if "%TimestampServer%"=="" goto :out
+ if "%SigningCertificate%"=="" goto :success
+ if "%TimestampServer%"=="" goto :success
echo [+] Signing
signtool sign /sha1 "%SigningCertificate%" /fd sha256 /tr "%TimestampServer%" /td sha256 /d "WireGuard Setup" "dist\wireguard-*-%WIREGUARD_VERSION%.msi" || goto :error
-:out
- set WIX=%OLDWIX%
- set PATHEXT=%OLDPATHEXT%
- popd
- exit /b %errorlevel%
+:success
+ echo [+] Success.
+ exit /b 0
:error
echo [-] Failed with error #%errorlevel%.
- goto :out
+ exit /b %errorlevel%
:download
echo [+] Downloading %1
@@ -62,7 +59,6 @@ if exist .deps\prepared goto :build
goto :eof
:msi
- set OLDPATH2=%PATH%
set PATH=%BUILDDIR%..\.deps\%~2-w64-mingw32-native\bin;%PATH%
set CC=%~2-w64-mingw32-gcc
set CFLAGS=-O3 -Wall -std=gnu11 -DWINVER=0x0601 -municode -DUNICODE -D_UNICODE -DNDEBUG
@@ -75,5 +71,4 @@ if exist .deps\prepared goto :build
"%WIX%bin\candle" %WIX_CANDLE_FLAGS% -dWIREGUARD_PLATFORM="%~1" -out "%~1\wireguard.wixobj" -arch %3 wireguard.wxs || exit /b %errorlevel%
echo [+] Linking %1
"%WIX%bin\light" %WIX_LIGHT_FLAGS% -out "dist\wireguard-%~1-%WIREGUARD_VERSION%.msi" "%~1\wireguard.wixobj" || exit /b %errorlevel%
- set PATH=%OLDPATH2%
goto :eof