From 0e09f62cc17a316ca1b06b5d315e3e1755285b66 Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Wed, 25 Mar 2026 14:38:55 +0900 Subject: [PATCH 1/2] desktop: Add Windows Docker cross-compilation. Add a Dockerfile for cross-compiling bisonw-desktop.exe from Linux and add more docs. --- .dockerignore | 2 + client/cmd/bisonw-desktop/README.md | 4 + client/cmd/bisonw-desktop/windows/Dockerfile | 76 +++++++++++++++++++ .../windows/{Build-Windows.md => README.md} | 63 ++++++++++++++- .../bisonw-desktop/windows/pkg-windows.cmd | 42 +++++++--- .../windows/windows-msi/BisonWallet.wxs | 16 ++++ .../windows-msi/BisonWallet_Installer.wixproj | 5 ++ 7 files changed, 195 insertions(+), 13 deletions(-) create mode 100644 client/cmd/bisonw-desktop/windows/Dockerfile rename client/cmd/bisonw-desktop/windows/{Build-Windows.md => README.md} (50%) diff --git a/.dockerignore b/.dockerignore index 48a87b69cc..b9f8c832db 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,5 @@ client/webserver/site/node_modules/ spec/ docs/ +.git/ +build/ diff --git a/client/cmd/bisonw-desktop/README.md b/client/cmd/bisonw-desktop/README.md index 5767784724..eae4e976a8 100644 --- a/client/cmd/bisonw-desktop/README.md +++ b/client/cmd/bisonw-desktop/README.md @@ -45,6 +45,10 @@ sudo ufw disable # if ufw is installed on the host, this is neccessary for lxd t 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). +## Windows + +See [windows/README.md](windows/README.md) for full instructions on setting up the build environment and building the Windows binary and MSI installer. + ## macOS (darwin) macOS builds use Electron. diff --git a/client/cmd/bisonw-desktop/windows/Dockerfile b/client/cmd/bisonw-desktop/windows/Dockerfile new file mode 100644 index 0000000000..ccaaaa06ce --- /dev/null +++ b/client/cmd/bisonw-desktop/windows/Dockerfile @@ -0,0 +1,76 @@ +# Dockerfile for cross-compiling bisonw-desktop.exe for Windows from Linux. +# +# Prerequisites: +# The site bundle must be built before running the docker build: +# cd client/webserver/site && npm clean-install && npm run build +# +# Build (from the repo root): +# docker build -t bisonw-desktop-windows -f client/cmd/bisonw-desktop/windows/Dockerfile . +# +# Build with XMR support: +# docker build -t bisonw-desktop-windows --build-arg XMR=1 -f client/cmd/bisonw-desktop/windows/Dockerfile . +# +# Extract the exe and DLLs: +# mkdir -p build && docker run --rm bisonw-desktop-windows tar -cf - -C /out . | tar -xf - -C ./build + +FROM golang:1.24-bookworm + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + gcc-mingw-w64-x86-64 \ + g++-mingw-w64-x86-64 \ + mingw-w64-tools \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +ARG XMR=0 +ARG WEBVIEW2_VERSION=1.0.3856.49 + +COPY . /src +WORKDIR /src/client/cmd/bisonw-desktop + +# Fetch the WebView2 NuGet package for the runtime DLL (WebView2Loader.dll). +RUN mkdir -p /tmp/webview2 && \ + curl -sSL "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}" -o /tmp/webview2.zip && \ + unzip -q /tmp/webview2.zip -d /tmp/webview2 && \ + rm /tmp/webview2.zip + +# Create a stub EventToken.h. The webview_go module's bundled WebView2.h +# includes this Windows SDK header, which MinGW does not provide. +RUN mkdir -p /tmp/winsdk && \ + printf '#pragma once\ntypedef struct EventRegistrationToken { __int64 value; } EventRegistrationToken;\n' \ + > /tmp/winsdk/EventToken.h + +# Generate a MinGW import library for the XMR DLL. The MinGW linker cannot +# link directly against a .dll. Named .a (not .dll.a) because webview_go's +# CGO LDFLAGS include -static, which makes the linker skip .dll.a files. +RUN if [ "$XMR" = "1" ]; then \ + cd /src/client/asset/xmr/lib/windows-amd64 && \ + gendef libwallet2_api_c.dll && \ + x86_64-w64-mingw32-dlltool -d libwallet2_api_c.def \ + -l libwallet2_api_c.a -D libwallet2_api_c.dll; \ + fi + +RUN mkdir -p /out + +ENV GOOS=windows +ENV GOARCH=amd64 +ENV CGO_ENABLED=1 +ENV CC=x86_64-w64-mingw32-gcc +ENV CXX=x86_64-w64-mingw32-g++ +ENV CGO_CXXFLAGS="-I/tmp/winsdk" + +RUN if [ "$XMR" = "1" ]; then \ + go build -v -tags xmr -ldflags="-H windowsgui" -o /out/bisonw-desktop.exe; \ + else \ + go build -v -ldflags="-H windowsgui" -o /out/bisonw-desktop.exe; \ + fi + +# Bundle runtime DLLs that are not present on a stock Windows install. +RUN cp /tmp/webview2/runtimes/win-x64/native/WebView2Loader.dll /out/ && \ + cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /out/ + +RUN if [ "$XMR" = "1" ]; then \ + cp /src/client/asset/xmr/lib/windows-amd64/libwallet2_api_c.dll /out/; \ + fi diff --git a/client/cmd/bisonw-desktop/windows/Build-Windows.md b/client/cmd/bisonw-desktop/windows/README.md similarity index 50% rename from client/cmd/bisonw-desktop/windows/Build-Windows.md rename to client/cmd/bisonw-desktop/windows/README.md index c5f472988c..7231d94184 100644 --- a/client/cmd/bisonw-desktop/windows/Build-Windows.md +++ b/client/cmd/bisonw-desktop/windows/README.md @@ -1,10 +1,12 @@ -## Windows build +# Windows build + +## Native build ### Setting up the build environment This build setup is expected to be run on a freshly installed system (e.g. in a VM), which is the best practice for building binaries for release on Windows, therefore there are no prerequisites. The setup script will install all components of the toolchain, dependencies and SDKs required to build the `bisonw-desktop` binary and the MSI (MS installer), there is no need to install anything manually before running this (it can actually cause issues if different versions of the dependencies are already on the system). The builder was tested on Windows 10, Windows 11 and server equivalents, 2019/2022. -Download and run setup as Administrator (privileges are required in order to set environment variables). Open a command prompt as Administrator, and run: +Download and run setup as Administrator (privileges are required in order to set environment variables). Open a **Command Prompt** (cmd.exe) as Administrator (not PowerShell), and run: ```batch cd %UserProfile% @@ -22,7 +24,7 @@ Download and run setup as Administrator (privileges are required in order to set cd dcrdex\client\cmd\bisonw-desktop ``` -Build the Windows binary: +Build the Windows binary: ```batch windows\build-windows.cmd @@ -39,3 +41,58 @@ windows\pkg-windows.cmd ``` The resulting installer binary will be located in `build\msi`. + +## Cross-compiling from Linux with Docker + +The Windows `.exe` can be cross-compiled from Linux using Docker. This does not produce the MSI installer. + +### Prerequisites + +Build the site bundle if it hasn't been built already: + +```bash +cd client/webserver/site +npm clean-install +npm run build +cd ../../.. +``` + +### Build the exe + +From the repo root: + +```bash +docker build -t bisonw-desktop-windows -f client/cmd/bisonw-desktop/windows/Dockerfile . +``` + +To include XMR support: + +```bash +docker build -t bisonw-desktop-windows --build-arg XMR=1 -f client/cmd/bisonw-desktop/windows/Dockerfile . +``` + +### Extract the build output + +```bash +mkdir -p build && docker run --rm bisonw-desktop-windows tar -cf - -C /out . | tar -xf - -C ./build +``` + +The `build/` directory will contain `bisonw-desktop.exe`, `WebView2Loader.dll`, `libwinpthread-1.dll`, and `libwallet2_api_c.dll` if XMR was enabled. + +### Packaging the MSI on Windows + +The MSI installer can only be built on Windows. If you cross-compiled the exe on Linux, copy the contents of `build/` to `client\cmd\bisonw-desktop\build\windows\` in the repo on a Windows machine with the build environment set up, then run from `client\cmd\bisonw-desktop`: + +```batch +windows\pkg-windows.cmd --skip-build +``` + +To include XMR support in the MSI: + +```batch +windows\pkg-windows.cmd --skip-build --xmr +``` + +The resulting installer will be in `build\msi`. + +**Note:** The Docker cross-compilation uses MinGW, which produces a binary that depends on `libwinpthread-1.dll`. This DLL is bundled automatically by the Dockerfile. Native Windows builds use MSVC and do not require this DLL. diff --git a/client/cmd/bisonw-desktop/windows/pkg-windows.cmd b/client/cmd/bisonw-desktop/windows/pkg-windows.cmd index ae44d24a48..b1abc144ab 100644 --- a/client/cmd/bisonw-desktop/windows/pkg-windows.cmd +++ b/client/cmd/bisonw-desktop/windows/pkg-windows.cmd @@ -4,18 +4,40 @@ call windows\env-windows.cmd -:: Run build -call windows\build-windows.cmd %* - -:: Check the error level after the first command -if %errorlevel% equ 0 ( - echo Build completed successfully. - echo Building MSI - dotnet build --property:Platform=x64 --configuration Release --output build\msi -noWarn:WIX1076 windows\windows-msi\BisonWallet_Installer.wixproj - echo MSI built in build\msi +:: Parse flags. +set "XMR_ENABLED=0" +set "SKIP_BUILD=0" +:parse_args +if "%~1"=="" goto done_args +if "%~1"=="--xmr" set "XMR_ENABLED=1" +if "%~1"=="--skip-build" set "SKIP_BUILD=1" +shift +goto parse_args +:done_args + +if "%SKIP_BUILD%"=="1" ( + echo Skipping build, packaging existing files in build\windows... + goto :MSI +) + +:: Run build. Only forward --xmr if set; build-windows.cmd does not +:: understand --skip-build. +if "%XMR_ENABLED%"=="1" ( + call windows\build-windows.cmd --xmr ) else ( + call windows\build-windows.cmd +) + +if %errorlevel% neq 0 ( echo Error occurred during build. + exit /b 1 ) +echo Build completed successfully. + +:MSI +echo Building MSI +dotnet build --property:Platform=x64 --configuration Release --output build\msi -noWarn:WIX1076 -p:XmrEnabled=%XMR_ENABLED% -p:CrossCompiled=%SKIP_BUILD% windows\windows-msi\BisonWallet_Installer.wixproj +echo MSI built in build\msi echo Signing %exeFile% -call windows\sign-windows.cmd %exeFile% \ No newline at end of file +call windows\sign-windows.cmd %exeFile% diff --git a/client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet.wxs b/client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet.wxs index 0ac2671948..3634d07bc8 100644 --- a/client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet.wxs +++ b/client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet.wxs @@ -9,6 +9,16 @@ + + + + + + + + + + @@ -25,6 +35,12 @@ + + + + + + diff --git a/client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet_Installer.wixproj b/client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet_Installer.wixproj index 9d426b9039..8133fef36d 100644 --- a/client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet_Installer.wixproj +++ b/client/cmd/bisonw-desktop/windows/windows-msi/BisonWallet_Installer.wixproj @@ -1,2 +1,7 @@  + + 0 + 0 + XmrEnabled=$(XmrEnabled);CrossCompiled=$(CrossCompiled) + From e90db3bdc84717cceb842fd62bc7a22137013aac Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Thu, 26 Mar 2026 16:21:25 +0900 Subject: [PATCH 2/2] tor: Update to tor 0.4.9.6. The pinned tor 0.4.7.x has a SYS_SECCOMP macro in sandbox.h that conflicts with newer glibc/kernel headers which now also define it. Update to tor 0.4.9.6 which has the fix upstream. --- client/tor/build_linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/tor/build_linux.sh b/client/tor/build_linux.sh index ebf94c007c..756f509f42 100755 --- a/client/tor/build_linux.sh +++ b/client/tor/build_linux.sh @@ -4,7 +4,7 @@ BASE_DIR=$(realpath $(dirname $0)) BUILD_DIR="${BASE_DIR}/build" REPO_DIR="${BUILD_DIR}/torrepo" -COMMIT_HASH=3cb6a690be60fcdab60130402ff88dcfc0657596 +COMMIT_HASH=d133d41f5d285c2f0a9c2fd75acde285d67afd3d rm -r -f "${REPO_DIR}" mkdir -p "${REPO_DIR}"