Skip to content

Commit 8960ad6

Browse files
JoeGruffinsvboxuser
authored andcommitted
desktop: Add Windows Docker cross-compilation.
Add a Dockerfile for cross-compiling bisonw-desktop.exe from Linux, add a Windows section to the main README pointing to Build-Windows.md, clarify that the native Windows setup requires CMD (not PowerShell).
1 parent e5cd27b commit 8960ad6

6 files changed

Lines changed: 120 additions & 51 deletions

File tree

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
client/webserver/site/node_modules/
22
spec/
33
docs/
4+
.git/
5+
build/

client/cmd/bisonw-desktop/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ sudo ufw disable # if ufw is installed on the host, this is neccessary for lxd t
4545

4646
The snap can be uploaded to the Snap Store using `./linux/publish-snap.sh`. This requires [Snapcraft developer account credentials](https://snapcraft.io/docs/releasing-your-app). After this is completed, the package can be installed on any system running `snap` by running `snap install bisonw`. The app will be available on the [Snap Store](https://snapcraft.io/store/bisonw).
4747

48+
## Windows
49+
50+
See [windows/README.md](windows/README.md) for full instructions on setting up the build environment and building the Windows binary and MSI installer.
51+
4852
## macOS (darwin)
4953

5054
macOS builds use Electron.

client/cmd/bisonw-desktop/windows/Build-Windows.md

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Dockerfile for cross-compiling bisonw-desktop.exe for Windows from Linux.
2+
#
3+
# Prerequisites:
4+
# The site bundle must be built before running the docker build:
5+
# cd client/webserver/site && npm clean-install && npm run build
6+
#
7+
# Build (from the repo root):
8+
# docker build -t bisonw-desktop-windows -f client/cmd/bisonw-desktop/windows/Dockerfile .
9+
#
10+
# Build with XMR support:
11+
# docker build -t bisonw-desktop-windows --build-arg XMR=1 -f client/cmd/bisonw-desktop/windows/Dockerfile .
12+
#
13+
# Extract the exe and DLLs:
14+
# mkdir -p build && docker run --rm bisonw-desktop-windows tar -cf - -C /out . | tar -xf - -C ./build
15+
16+
FROM golang:1.24-bookworm
17+
18+
ENV DEBIAN_FRONTEND=noninteractive
19+
20+
RUN apt-get update && apt-get install -y \
21+
gcc-mingw-w64-x86-64 \
22+
g++-mingw-w64-x86-64 \
23+
mingw-w64-tools \
24+
unzip \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
ARG XMR=0
28+
ARG WEBVIEW2_VERSION=1.0.3856.49
29+
30+
COPY . /src
31+
WORKDIR /src/client/cmd/bisonw-desktop
32+
33+
# Fetch the WebView2 NuGet package for the runtime DLL (WebView2Loader.dll).
34+
RUN mkdir -p /tmp/webview2 && \
35+
curl -sSL "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}" -o /tmp/webview2.zip && \
36+
unzip -q /tmp/webview2.zip -d /tmp/webview2 && \
37+
rm /tmp/webview2.zip
38+
39+
# Create a stub EventToken.h. The webview_go module's bundled WebView2.h
40+
# includes this Windows SDK header, which MinGW does not provide.
41+
RUN mkdir -p /tmp/winsdk && \
42+
printf '#pragma once\ntypedef struct EventRegistrationToken { __int64 value; } EventRegistrationToken;\n' \
43+
> /tmp/winsdk/EventToken.h
44+
45+
# Generate a MinGW import library for the XMR DLL. The MinGW linker cannot
46+
# link directly against a .dll. Named .a (not .dll.a) because webview_go's
47+
# CGO LDFLAGS include -static, which makes the linker skip .dll.a files.
48+
RUN if [ "$XMR" = "1" ]; then \
49+
cd /src/client/asset/xmr/lib/windows-amd64 && \
50+
gendef libwallet2_api_c.dll && \
51+
x86_64-w64-mingw32-dlltool -d libwallet2_api_c.def \
52+
-l libwallet2_api_c.a -D libwallet2_api_c.dll; \
53+
fi
54+
55+
RUN mkdir -p /out
56+
57+
ENV GOOS=windows
58+
ENV GOARCH=amd64
59+
ENV CGO_ENABLED=1
60+
ENV CC=x86_64-w64-mingw32-gcc
61+
ENV CXX=x86_64-w64-mingw32-g++
62+
ENV CGO_CXXFLAGS="-I/tmp/winsdk"
63+
64+
RUN if [ "$XMR" = "1" ]; then \
65+
go build -v -tags xmr -ldflags="-H windowsgui -extldflags -static" -o /out/bisonw-desktop.exe; \
66+
else \
67+
go build -v -ldflags="-H windowsgui -extldflags -static" -o /out/bisonw-desktop.exe; \
68+
fi
69+
70+
RUN cp /tmp/webview2/runtimes/win-x64/native/WebView2Loader.dll /out/
71+
72+
RUN if [ "$XMR" = "1" ]; then \
73+
cp /src/client/asset/xmr/lib/windows-amd64/libwallet2_api_c.dll /out/; \
74+
fi

client/cmd/bisonw-desktop/windows/pkg-windows.cmd

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,40 @@
44

55
call windows\env-windows.cmd
66

7-
:: Run build
8-
call windows\build-windows.cmd %*
9-
10-
:: Check the error level after the first command
11-
if %errorlevel% equ 0 (
12-
echo Build completed successfully.
13-
echo Building MSI
14-
dotnet build --property:Platform=x64 --configuration Release --output build\msi -noWarn:WIX1076 windows\windows-msi\BisonWallet_Installer.wixproj
15-
echo MSI built in build\msi
7+
:: Parse flags.
8+
set "XMR_ENABLED=0"
9+
set "SKIP_BUILD=0"
10+
:parse_args
11+
if "%~1"=="" goto done_args
12+
if "%~1"=="--xmr" set "XMR_ENABLED=1"
13+
if "%~1"=="--skip-build" set "SKIP_BUILD=1"
14+
shift
15+
goto parse_args
16+
:done_args
17+
18+
if "%SKIP_BUILD%"=="1" (
19+
echo Skipping build, packaging existing files in build\windows...
20+
goto :MSI
21+
)
22+
23+
:: Run build. Only forward --xmr if set; build-windows.cmd does not
24+
:: understand --skip-build.
25+
if "%XMR_ENABLED%"=="1" (
26+
call windows\build-windows.cmd --xmr
1627
) else (
28+
call windows\build-windows.cmd
29+
)
30+
31+
if %errorlevel% neq 0 (
1732
echo Error occurred during build.
33+
exit /b 1
1834
)
35+
echo Build completed successfully.
36+
37+
:MSI
38+
echo Building MSI
39+
dotnet build --property:Platform=x64 --configuration Release --output build\msi -noWarn:WIX1076 -p:DefineConstants="XmrEnabled=%XMR_ENABLED%" windows\windows-msi\BisonWallet_Installer.wixproj
40+
echo MSI built in build\msi
1941

2042
echo Signing %exeFile%
21-
call windows\sign-windows.cmd %exeFile%
43+
call windows\sign-windows.cmd %exeFile%

client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet.wxs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<File Source="..\..\build\windows\Bisonw-desktop.exe" Id="BisonwDesktopExe" KeyPath="yes" Checksum="yes" />
1010
<File Source="..\..\build\windows\WebView2Loader.dll" Checksum="yes" />
1111
</Component>
12+
<?if $(var.XmrEnabled) = 1 ?>
13+
<Component Id="XmrLibrary" Guid="b7a3e1f4-5c82-4d19-9a6b-3e8f2d7c1a05">
14+
<File Source="..\..\build\windows\libwallet2_api_c.dll" Checksum="yes" />
15+
</Component>
16+
<?endif ?>
1217
</DirectoryRef>
1318

1419
<DirectoryRef Id="ApplicationProgramsFolder">
@@ -25,6 +30,9 @@
2530
<Feature Id="MainApplication" Title="Main Application" Level="1">
2631
<ComponentRef Id="BisonwDesktopExe" />
2732
<ComponentRef Id="ApplicationShortcut" />
33+
<?if $(var.XmrEnabled) = 1 ?>
34+
<ComponentRef Id="XmrLibrary" />
35+
<?endif ?>
2836
</Feature>
2937

3038
<StandardDirectory Id="ProgramFiles64Folder">

0 commit comments

Comments
 (0)