aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-07 06:27:53 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-07 20:55:12 +0100
commit9c9c8d13bbc9b58de02271d4690cb20840c1d7c2 (patch)
tree2c825b68c237a877878ffbd626a822b63e2d8fac
parentnames: better casing (diff)
downloadwireguard-windows-9c9c8d13bbc9b58de02271d4690cb20840c1d7c2.tar.xz
wireguard-windows-9c9c8d13bbc9b58de02271d4690cb20840c1d7c2.zip
ui: embed resource the old fashioned way
If we ever get rid of the cgo requirement, we can return to rsrc or some variant of it. But given that win32 GUI stuff benefits from the larger cgo stacks, that seems unlikely. This gives us a bit more latitude to embed all sorts of interesting things in here as well. Clean up the makefile while we're at it and reduce the size of the exe.
-rw-r--r--Makefile24
-rw-r--r--build.bat5
-rw-r--r--go.mod1
-rw-r--r--manifest.xml (renamed from ui/manifest.xml)14
-rw-r--r--resources.rc39
-rw-r--r--ui/ui.go2
-rw-r--r--version.h1
7 files changed, 73 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 0fb865a9..720c0099 100644
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,27 @@
-CFLAGS ?= -O3
-CFLAGS += -Wall -std=gnu11
+export CFLAGS := -O3 -Wall -std=gnu11
+export CC := x86_64-w64-mingw32-gcc
+WINDRES := x86_64-w64-mingw32-windres
+export CGO_ENABLED := 1
+export GOOS := windows
+export GOARCH := amd64
+
+DEPLOYMENT_HOST ?= winvm
+DEPLOYMENT_PATH ?= Desktop
all: wireguard.exe
-resources.syso: ui/icon/icon.ico ui/manifest.xml go.mod
- go run github.com/akavel/rsrc -manifest ui/manifest.xml -ico ui/icon/icon.ico -arch amd64 -o resources.syso
+resources.syso: resources.rc manifest.xml ui/icon/icon.ico
+ $(WINDRES) -i $< -o $@ -O coff
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
wireguard.exe: resources.syso $(call rwildcard,,*.go *.c *.h)
- CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags="-H windowsgui" -o $@
+ go build -ldflags="-H windowsgui -s -w" -v -o $@
-run: wireguard.exe
- wine wireguard.exe
+deploy: wireguard.exe
+ -ssh $(DEPLOYMENT_HOST) -- 'taskkill /im wireguard.exe /f'
+ scp wireguard.exe $(DEPLOYMENT_HOST):$(DEPLOYMENT_PATH)
clean:
rm -rf resources.syso wireguard.exe
-.PHONY: run clean all
+.PHONY: deploy clean all
diff --git a/build.bat b/build.bat
index 2d2224dd..0c8f1831 100644
--- a/build.bat
+++ b/build.bat
@@ -4,15 +4,16 @@ 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
-go run github.com/akavel/rsrc -manifest ui/manifest.xml -ico ui/icon/icon.ico -arch amd64 -o resources.syso || goto :error
+windres.exe -i resources.rc -o resources.syso -O coff || goto :error
echo Building program
-go build -ldflags="-H windowsgui" -o wireguard.exe || goto :error
+go build -ldflags="-H windowsgui -s -w" -v -o wireguard.exe || goto :error
goto :out
:installdeps
diff --git a/go.mod b/go.mod
index 5c6d8f27..10d466cc 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,6 @@ require (
)
replace (
- github.com/akavel/rsrc => golang.zx2c4.com/wireguard/windows pkg/rsrc
github.com/lxn/walk => golang.zx2c4.com/wireguard/windows pkg/walk
github.com/lxn/win => golang.zx2c4.com/wireguard/windows pkg/walk-win
)
diff --git a/ui/manifest.xml b/manifest.xml
index a14c4be4..72e407d3 100644
--- a/ui/manifest.xml
+++ b/manifest.xml
@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
- <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="wireguard-manager" type="win32"/>
+ <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="wireguard" type="win32"/>
+ <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+ <application>
+ <!-- Windows 10 -->
+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
+ <!-- Windows 8.1 -->
+ <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
+ <!-- Windows 8 -->
+ <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
+ <!-- Windows 7 -->
+ <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
+ </application>
+ </compatibility>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
diff --git a/resources.rc b/resources.rc
new file mode 100644
index 00000000..fd3a521d
--- /dev/null
+++ b/resources.rc
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
+ */
+
+#include <windows.h>
+#include "version.h"
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST manifest.xml
+
+1 ICON ui/icon/icon.ico
+
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION 0,0,0,1
+PRODUCTVERSION 0,0,0,1
+FILEOS VOS_NT_WINDOWS32
+FILETYPE VFT_APP
+FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "WireGuard LLC"
+ VALUE "FileDescription", "WireGuard: Fast, Modern, Secure VPN Tunnel"
+ VALUE "FileVersion", WIREGUARD_WINDOWS_VERSION
+ VALUE "InternalName", "wireguard"
+ VALUE "LegalCopyright", "Copyright \xa9 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved."
+ VALUE "OriginalFilename", "wireguard.exe"
+ VALUE "ProductName", "WireGuard"
+ VALUE "ProductVersion", WIREGUARD_WINDOWS_VERSION
+ VALUE "Comments", "https://www.wireguard.com/"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
diff --git a/ui/ui.go b/ui/ui.go
index 2abd6de0..f82d3f4d 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -28,7 +28,7 @@ AllowedIPs = 0.0.0.0/0
`
func RunUI() {
- icon, _ := walk.NewIconFromResourceId(8)
+ icon, _ := walk.NewIconFromResourceId(1)
mw, _ := walk.NewMainWindowWithName("WireGuard")
tray, _ := walk.NewNotifyIcon(mw)
diff --git a/version.h b/version.h
new file mode 100644
index 00000000..8da652db
--- /dev/null
+++ b/version.h
@@ -0,0 +1 @@
+#define WIREGUARD_WINDOWS_VERSION "0.0.20190307"