ui_app_setup: drop HAL_PLATFORM_SDL guard so emulator builds#48
Merged
Conversation
The class was wrapped in `#if !defined(HAL_PLATFORM_SDL)`, which excluded
it from emulator builds — but ui_app_launch.cpp registers
`page_v<UISetupPage>` unconditionally, causing a fatal compile error
on emu ("'UISetupPage' was not declared").
Removing the guard is safe:
- The UI implementation already uses HAL functions (hal_wifi_*,
hal_battery_*, hal_volume_*, hal_bt_*, hal_backlight_*) that have
emulator stubs in hal/sdl/.
- Residual raw syscalls (i2c ioctl, sys/class/power_supply DIR walk,
popen for ip/whoami/hostname, sudo date, apt update) all sit either
inside an existing `#ifdef __linux__` block, or in code paths that
only fire on user actions the emulator never performs (e.g. the
user must navigate into the WiFi/Update sub-pages and confirm).
- Both popen() and system() are POSIX and compile fine on macOS/Linux
hosts. Windows static builds of APPLaunch are a separate concern
(already broken before this change due to gethostname/_popen).
This unblocks the M5CardputerZero-Emulator multi-arch CI.
GCC on MinGW (Windows MSYS2) errors with 'snprintf was not declared in this scope'. The implicit transitive include via <string.h>/<stdlib.h> holds on glibc/libc++ but not on MSYS2's headers. Other HAL files in the same directory already include <stdio.h>; this one was an oversight.
eggfly
added a commit
to CardputerZero/emulator
that referenced
this pull request
Jun 2, 2026
…orkaround Two follow-ups discovered after the previous CI round: 1. src/emu_launcher_stubs.c — provides LV_EVENT_BATTERY, LV_EVENT_WIFI_INFO, g_launch_thread_pool. Launcher's own main.cpp defines these globals on device, but the emulator runs its own src/main.cpp. The Unix shared-library path resolves them at dlopen time via dynamic_lookup; static-linked targets (Windows + Web) need real storage. Linked into both windows and web targets only. 2. cmake/patches: workaround #3 — hal_filesystem_sdl.cpp is missing <stdio.h> for snprintf. Compiles on glibc/libc++ where <string.h> transitively pulls it in, fails on MSYS2. Trivial header patch tracked by Launcher PR #48; will self-skip once that lands. Tracking PR (Launcher): CardputerZero/launcher#48
Forgot to drop the matching `#else` branch that provided a stub UISetupPage for HAL_PLATFORM_SDL builds. With the outer guard gone, the orphan `#else` produced 'else without if' on every platform and a class redefinition error. Now the file has a single, unconditional class definition.
Declared in hal_settings.h but never implemented for SDL — caused a link error on Windows / Web emulator builds (UISetupPage's WiFi menu calls it). Returns 0 (success no-op) for the emulator. Linux native and macOS link paths used dynamic_lookup so they didn't notice the missing symbol; the static-link targets do.
eggfly
added a commit
to CardputerZero/emulator
that referenced
this pull request
Jun 3, 2026
…orkaround Two follow-ups discovered after the previous CI round: 1. src/emu_launcher_stubs.c — provides LV_EVENT_BATTERY, LV_EVENT_WIFI_INFO, g_launch_thread_pool. Launcher's own main.cpp defines these globals on device, but the emulator runs its own src/main.cpp. The Unix shared-library path resolves them at dlopen time via dynamic_lookup; static-linked targets (Windows + Web) need real storage. Linked into both windows and web targets only. 2. cmake/patches: workaround #3 — hal_filesystem_sdl.cpp is missing <stdio.h> for snprintf. Compiles on glibc/libc++ where <string.h> transitively pulls it in, fails on MSYS2. Trivial header patch tracked by Launcher PR #48; will self-skip once that lands. Tracking PR (Launcher): CardputerZero/launcher#48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make UISetupPage compile on the emulator (macOS / SDL Linux / Web) so the SETTING page is actually reachable from APPLaunch.
Problem
ui_app_setup.hppis currently wrapped in#if !defined(HAL_PLATFORM_SDL), which excludes it from emu builds — butui_app_launch.cppregisterspage_v<UISetupPage>unconditionally, so the build is structurally broken under HAL_PLATFORM_SDL.This breaks the M5CardputerZero-Emulator CI on every platform.
Fix
Drop the SDL guard. The class is already HAL-clean for the parts the emu actually exercises:
hal_wifi_*,hal_battery_*,hal_volume_*,hal_bt_*,hal_backlight_*— all have stubs inhal/sdl/.<linux/i2c.h>includes — already inside#ifdef __linux__.popen,system,/sys/class/power_supplywalk):hal_account_info()/hal_eth_status()/hal_system_update_*(). Out of scope for this PR.Test
Local macOS arm64 (with M5CardputerZero-Emulator submodule pointing at this branch):
Companion PR
This unblocks CardputerZero/emulator#2 — once this merges, that PR drops the corresponding workaround in
cmake/patches/apply_vendor_workarounds.cmakeand bumps the launcher submodule.