Native MacOS hello world (#10309)

* Native MacOS hello world

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update variants/native/portduino/platformio.ini

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: ensure null-termination in getSerialString() and handle len==0

Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/e5647919-2255-48ad-bcaa-7a2c2fdbf212

Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com>

---------

Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
Ben Meadors
2026-04-27 07:07:49 -05:00
co-authored by Jonathan Bennett Copilot copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
parent 47a6c4c6a0
commit 126861fd16
15 changed files with 151 additions and 26 deletions
+56
View File
@@ -117,3 +117,59 @@ build_flags = -lgcov --coverage -fprofile-abs-path -fsanitize=address ${env:nati
test_testing_command =
${platformio.build_dir}/${this.__env__}/meshtasticd
-s
; ---------------------------------------------------------------------------
; Native build for macOS (Darwin / arm64 + x86_64). Headless meshtasticd that
; runs in SimRadio mode (`-s`) or against real LoRa hardware via a CH341
; USB-SPI bridge. No BlueZ, libgpiod, or Linux I2C — those require Linux.
;
; Prerequisites (Homebrew):
; brew install platformio yaml-cpp libuv openssl@3 libusb argp-standalone pkg-config
;
; The macOS-side patches now live upstream:
; * meshtastic/platform-native — `String.h`-shadow shim, `-Wno-enum-constexpr-conversion`,
; empty-variant-dir guard. Pulled via `portduino_base.platform` zip pin.
; * meshtastic/framework-portduino — LinuxHardwareI2C macOS stubs, AsyncUDP
; SOCK_NONBLOCK fallback, Common.h __APPLE__ guard, WiFiServer.cpp extern-C
; fix, package.json URL refresh. Pulled by platform-native at its pinned commit.
; This env therefore only carries the firmware-side build flags and src filter.
; ---------------------------------------------------------------------------
[env:native-macos]
extends = native_base
; Apple's ld doesn't accept GNU ld's `-Wl,-Map,<file>` syntax (inherited from
; the top-level platformio.ini). Strip it; the linker map isn't useful for
; the macOS dev loop anyway, and Apple ld's equivalent (`-Wl,-map,<file>`)
; uses different argument shape.
build_unflags = -Wl,-Map,"${platformio.build_dir}"/output.map
build_flags = ${portduino_base.build_flags_common}
-I variants/native/portduino
-I/opt/homebrew/include
-I/opt/homebrew/opt/argp-standalone/include
-I/opt/homebrew/opt/yaml-cpp/include
-L/opt/homebrew/lib
-L/opt/homebrew/opt/argp-standalone/lib
-L/opt/homebrew/opt/yaml-cpp/lib
-largp
-DPORTDUINO_DARWIN
; Headless build — variants/native/portduino/variant.h would otherwise
; default HAS_SCREEN to 1 and pull in screen-renderer source that uses
; VLA-with-initializer (a GNU/GCC extension Apple Clang rejects).
; MESHTASTIC_EXCLUDE_SCREEN gates the optional `screen->setHeading(...)`-
; style screen-driver hooks scattered through sensor sources.
-DHAS_SCREEN=0
-DMESHTASTIC_EXCLUDE_SCREEN=1
!pkg-config --libs openssl --silence-errors || :
; src/input/Linux*.{cpp,h} drive evdev (`<linux/input.h>`) which doesn't exist
; on macOS. graphics/Panel_sdl.* and graphics/TFTDisplay.cpp pull LovyanGFX
; (which we lib_ignore on macOS for the <malloc.h> issue). 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> (Linux-only) and is only needed by TFT
; variants — not relevant for the headless macOS build.
lib_ignore =
${portduino_base.lib_ignore}
LovyanGFX