From 50b49dea266dfc013bc78360cae2b93e1f1357ad Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sun, 25 Oct 2020 20:34:44 +0100 Subject: version: make native Go Arm has no CGo support. Signed-off-by: Simon Rozman Signed-off-by: Jason A. Donenfeld --- build.bat | 4 +++- installer/build.bat | 2 +- quickinstall.bat | 2 +- resources.rc | 8 +++++--- version/useragent.go | 5 ----- version/version.go | 10 ++++++++++ version/version.h | 2 -- 7 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 version/version.go delete mode 100644 version/version.h diff --git a/build.bat b/build.bat index d7ee7dd1..6c7ae981 100644 --- a/build.bat +++ b/build.bat @@ -36,6 +36,8 @@ if exist .deps\prepared goto :render for %%a in ("ui\icon\*.svg") do convert -background none "%%~fa" -define icon:auto-resize="256,192,128,96,64,48,32,24,16" "%%~dpna.ico" || goto :error :build + for /f "tokens=3" %%a in ('findstr /r "Number.*=.*[0-9.]*" .\version\version.go') do set WIREGUARD_VERSION=%%a + set WIREGUARD_VERSION=%WIREGUARD_VERSION:"=% set GOOS=windows set GOPATH=%BUILDDIR%.deps\gopath set GOROOT=%BUILDDIR%.deps\go @@ -79,7 +81,7 @@ if exist .deps\prepared goto :render set GOARCH=%~3 mkdir %1 >NUL 2>&1 echo [+] Assembling resources %1 - windres -I ".deps\wintun\bin\%~1" -i resources.rc -o "resources_%~3.syso" -O coff || exit /b %errorlevel% + windres -I ".deps\wintun\bin\%~1" -DWIREGUARD_WINDOWS_VERSION_ARRAY=%WIREGUARD_VERSION:.=,% -DWIREGUARD_WINDOWS_VERSION_STR=%WIREGUARD_VERSION% -i resources.rc -o "resources_%~3.syso" -O coff || exit /b %errorlevel% echo [+] Building program %1 go build -ldflags="-H windowsgui -s -w" -tags walk_use_cgo -trimpath -v -o "%~1\wireguard.exe" || exit /b 1 if not exist "%~1\wg.exe" ( diff --git a/installer/build.bat b/installer/build.bat index 318fbb29..20722bc5 100644 --- a/installer/build.bat +++ b/installer/build.bat @@ -7,7 +7,7 @@ set PATHEXT=.exe set BUILDDIR=%~dp0 cd /d %BUILDDIR% || exit /b 1 -for /f "tokens=3" %%a in ('findstr /r "WIREGUARD_WINDOWS_VERSION_STRING.*[0-9.]*" ..\version\version.h') do set WIREGUARD_VERSION=%%a +for /f "tokens=3" %%a in ('findstr /r "Number.*=.*[0-9.]*" ..\version\version.go') do set WIREGUARD_VERSION=%%a set WIREGUARD_VERSION=%WIREGUARD_VERSION:"=% set WIX_CANDLE_FLAGS=-nologo -dWIREGUARD_VERSION="%WIREGUARD_VERSION%" diff --git a/quickinstall.bat b/quickinstall.bat index 9765fdb0..7499236a 100644 --- a/quickinstall.bat +++ b/quickinstall.bat @@ -11,6 +11,6 @@ call .\installer\build.bat || exit /b 1 echo [+] Uninstalling old versions for /f %%a in ('reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /d /c /e /f WireGuard ^| findstr CurrentVersion\Uninstall') do msiexec /qb /x %%~na echo [+] Installing new version -for /f "tokens=3" %%a in ('findstr /r "WIREGUARD_WINDOWS_VERSION_STRING.*[0-9.]*" .\version.h') do set WIREGUARD_VERSION=%%a +for /f "tokens=3" %%a in ('findstr /r "Number.*=.*[0-9.]*" .\version\version.go') do set WIREGUARD_VERSION=%%a set WIREGUARD_VERSION=%WIREGUARD_VERSION:"=% msiexec /qb /i installer\dist\wireguard-%PROCESSOR_ARCHITECTURE%-%WIREGUARD_VERSION%.msi diff --git a/resources.rc b/resources.rc index 063d1038..1299f62f 100644 --- a/resources.rc +++ b/resources.rc @@ -4,10 +4,12 @@ */ #include -#include "version/version.h" #pragma code_page(65001) // UTF-8 +#define STRINGIZE(x) #x +#define EXPAND(x) STRINGIZE(x) + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST manifest.xml $wireguard.ico ICON ui/icon/wireguard.ico @@ -28,12 +30,12 @@ BEGIN \ BEGIN \ VALUE "CompanyName", "WireGuard LLC" \ VALUE "FileDescription", file_desc \ - VALUE "FileVersion", WIREGUARD_WINDOWS_VERSION_STRING \ + VALUE "FileVersion", EXPAND(WIREGUARD_WINDOWS_VERSION_STR) \ VALUE "InternalName", "wireguard-windows" \ VALUE "LegalCopyright", "Copyright © 2015-2020 Jason A. Donenfeld . All Rights Reserved." \ VALUE "OriginalFilename", "wireguard.exe" \ VALUE "ProductName", "WireGuard" \ - VALUE "ProductVersion", WIREGUARD_WINDOWS_VERSION_STRING \ + VALUE "ProductVersion", EXPAND(WIREGUARD_WINDOWS_VERSION_STR) \ VALUE "Comments", comments \ END \ END \ diff --git a/version/useragent.go b/version/useragent.go index 1c1adf55..77633765 100644 --- a/version/useragent.go +++ b/version/useragent.go @@ -10,11 +10,6 @@ import ( "runtime" ) -// #include "version.h" -import "C" - -const Number = C.WIREGUARD_WINDOWS_VERSION_STRING - func UserAgent() string { return fmt.Sprintf("WireGuard/%s (%s; %s)", Number, OsName(), runtime.GOARCH) } diff --git a/version/version.go b/version/version.go new file mode 100644 index 00000000..9b22b312 --- /dev/null +++ b/version/version.go @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: MIT + * + * Copyright (C) 2019-2020 WireGuard LLC. All Rights Reserved. + */ + +package version + +const ( + Number = "0.1.1" +) diff --git a/version/version.h b/version/version.h deleted file mode 100644 index 0da08178..00000000 --- a/version/version.h +++ /dev/null @@ -1,2 +0,0 @@ -#define WIREGUARD_WINDOWS_VERSION_ARRAY 0,1,1 -#define WIREGUARD_WINDOWS_VERSION_STRING "0.1.1" -- cgit v1.2.3-59-g8ed1b