Add native Windows build of meshtasticd (#11031)

This commit is contained in:
Thomas Göttgens
2026-07-19 23:31:19 +02:00
committed by GitHub
co-authored by GitHub
parent 4726375282
commit a808e992a1
16 changed files with 910 additions and 21 deletions
+77
View File
@@ -251,6 +251,83 @@ build_flags = ${env:native-macos.build_flags}
build_src_filter = ${env:native-macos.build_src_filter}
lib_ignore = ${env:native-macos.lib_ignore}
; ---------------------------------------------------------------------------
; Native build for Windows (x86_64) via the MSYS2 UCRT64 MinGW-w64 toolchain.
; Headless meshtasticd.exe running in SimRadio mode (`-s`). No BlueZ, libgpiod or
; Linux I2C, and no UDP multicast: the framework's AsyncUDP.cpp is BSD sockets,
; so HAS_UDP_MULTICAST stays unset here as it does on macOS.
;
; MSVC is not an option: platform-native's builder calls env.Tool("gcc") and the
; firmware builds as gnu17/gnu++17 with GNU extensions throughout.
;
; Prerequisites (MSYS2, https://www.msys2.org/):
; pacman -S --needed mingw-w64-ucrt-x86_64-{gcc,pkgconf,yaml-cpp,libuv,jsoncpp,openssl,libusb}
;
; argp is not packaged for MSYS2's mingw environments (msys/libargp links the
; msys-2.0.dll emulation layer and can't be used for a native binary), yet
; Arduino.h includes <argp.h> and main.cpp calls argp_parse(). Build it once from
; source, the same dependency macOS meets with `brew install argp-standalone`:
; git clone https://github.com/tom42/argp-standalone
; cd argp-standalone && cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release .
; cmake --build build
; cp include/argp-standalone/argp.h /ucrt64/include/argp.h ; ships no install() rules
; cp build/src/libargp-standalone.a /ucrt64/lib/libargp.a
;
; Build from any shell with /ucrt64/bin on PATH:
; pio run -e native-windows
; .pio/build/native-windows/meshtasticd.exe -s
; ---------------------------------------------------------------------------
[env:native-windows]
extends = native_base
build_flags = ${portduino_base.build_flags_common}
-I variants/native/portduino
; Our drop-in libpinedio-usb.h, replacing the libusb one: libusb can only reach
; a device bound to WinUSB, which means Zadig on every machine. See
; src/platform/portduino/windows/libpinedio_ch341dll.c.
-I src/platform/portduino/windows/include
-largp
-lws2_32 ; GpsdSerial.cpp's TCP client
-lbcrypt ; BCryptGenRandom() in HardwareRNG.cpp
-liphlpapi ; GetAdaptersAddresses() host-MAC fallback in PortduinoGlue.cpp
; libch341's libpinedio-usb.h pulls in libusb.h and so <windows.h>, which
; collides with the Arduino API: winuser.h's `typedef struct tagINPUT INPUT` vs
; the PinMode enumerator, and rpcndr.h's `typedef unsigned char boolean` vs
; Arduino's `typedef bool boolean`. NOUSER and WIN32_LEAN_AND_MEAN keep those
; headers out, NOMINMAX stops min/max being macroed over std::min/std::max.
-DWIN32_LEAN_AND_MEAN
-DNOMINMAX
-DNOUSER
-DNOGDI
; yaml-cpp declares its API __declspec(dllimport) unless told the link is
; static, leaving every YAML symbol undefined as __imp_*.
-DYAML_CPP_STATIC_DEFINE
; Headless: variant.h would otherwise default HAS_SCREEN to 1 and pull in the
; screen renderer; EXCLUDE_SCREEN gates the `screen->...` hooks in the sensors.
-DHAS_SCREEN=0
-DMESHTASTIC_EXCLUDE_SCREEN=1
!pkg-config --cflags --libs openssl --silence-errors || :
build_unflags =
-fPIC ; ignored on Windows, where all code is position-independent
; Static link, so meshtasticd.exe stands alone and can't be hijacked by a stray
; System32 DLL. PlatformIO only feeds build_flags to the compile step, hence the script.
extra_scripts =
${env.extra_scripts}
post:extra_scripts/windows_link_flags.py
; LinuxInput drives evdev; Panel_sdl/TFTDisplay pull LovyanGFX. Neither is needed
; for the headless build.
build_src_filter = ${native_base.build_src_filter}
-<input/LinuxInput.cpp>
-<input/LinuxInputImpl.cpp>
-<graphics/Panel_sdl.cpp>
-<graphics/TFTDisplay.cpp>
; LovyanGFX includes <malloc.h> and is only needed by the TFT variants. The pine64
; libch341 is the libusb backend that libpinedio_ch341dll.c replaces; keeping both
; would duplicate every pinedio_* symbol.
lib_ignore =
${portduino_base.lib_ignore}
LovyanGFX
Pine libch341-spi Userspace library
; ---------------------------------------------------------------------------
; WASM (Emscripten) - the portduino node compiled to WebAssembly, driving a real
; LoRa radio over WebUSB through a CH341 (src/platform/portduino/wasm/). The same