Add macOS and Windows ARM64 builds; fix memory_monitor for macOS

Add macOS matrix job (arm64/macos-15, x86-64/macos-13) using Homebrew.
Add Windows ARM64 job using windows-11-arm runner with MSYS2 CLANGARM64.
Fix memory_monitor.cpp: add __APPLE__ branch using sysctl hw.memsize/hw.usermem
instead of Linux-only sysinfo/proc.
This commit is contained in:
Kelsi 2026-02-18 17:42:42 -08:00
parent 85e28ccec9
commit 880960dcc1
2 changed files with 107 additions and 2 deletions

View file

@ -65,6 +65,91 @@ jobs:
path: build/bin/
if-no-files-found: error
build-macos:
name: Build (macOS ${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
runner: macos-15
- arch: x86-64
runner: macos-13
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Clone ImGui
run: git clone --depth 1 https://github.com/ocornut/imgui.git extern/imgui
- name: Install dependencies
run: |
brew install cmake pkg-config sdl2 glew glm openssl@3 zlib ffmpeg unicorn
- name: Configure
run: |
BREW=$(brew --prefix)
export PKG_CONFIG_PATH="$BREW/lib/pkgconfig:$(brew --prefix ffmpeg)/lib/pkgconfig:$(brew --prefix openssl@3)/lib/pkgconfig"
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="$BREW" \
-DOPENSSL_ROOT_DIR="$(brew --prefix openssl@3)"
- name: Build
run: cmake --build build --parallel $(sysctl -n hw.logicalcpu)
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: wowee-macos-${{ matrix.arch }}
path: build/bin/
if-no-files-found: error
build-windows-arm:
name: Build (windows-arm64)
runs-on: windows-11-arm
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: CLANGARM64
update: false
install: >-
mingw-w64-clang-aarch64-cmake
mingw-w64-clang-aarch64-clang
mingw-w64-clang-aarch64-pkgconf
mingw-w64-clang-aarch64-SDL2
mingw-w64-clang-aarch64-glew
mingw-w64-clang-aarch64-glm
mingw-w64-clang-aarch64-openssl
mingw-w64-clang-aarch64-zlib
mingw-w64-clang-aarch64-ffmpeg
git
- name: Clone ImGui
shell: msys2 {0}
run: git clone --depth 1 https://github.com/ocornut/imgui.git extern/imgui
- name: Configure
shell: msys2 {0}
run: cmake -S . -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
- name: Build
shell: msys2 {0}
run: cmake --build build --parallel $(nproc)
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: wowee-windows-arm64
path: build/bin/
if-no-files-found: error
build-windows:
name: Build (windows-x86-64)
runs-on: windows-latest

View file

@ -5,6 +5,9 @@
#include <sstream>
#ifdef _WIN32
#include <windows.h>
#elif defined(__APPLE__)
#include <sys/types.h>
#include <sys/sysctl.h>
#else
#include <sys/sysinfo.h>
#endif
@ -12,7 +15,7 @@
namespace wowee {
namespace core {
#ifndef _WIN32
#if !defined(_WIN32) && !defined(__APPLE__)
namespace {
size_t readMemAvailableBytesFromProc() {
std::ifstream meminfo("/proc/meminfo");
@ -31,7 +34,7 @@ size_t readMemAvailableBytesFromProc() {
return 0;
}
} // namespace
#endif
#endif // !_WIN32 && !__APPLE__
MemoryMonitor& MemoryMonitor::getInstance() {
static MemoryMonitor instance;
@ -48,6 +51,16 @@ void MemoryMonitor::initialize() {
totalRAM_ = 16ull * 1024 * 1024 * 1024;
LOG_WARNING("Could not detect system RAM, assuming 16GB");
}
#elif defined(__APPLE__)
int64_t physmem = 0;
size_t len = sizeof(physmem);
if (sysctlbyname("hw.memsize", &physmem, &len, nullptr, 0) == 0) {
totalRAM_ = static_cast<size_t>(physmem);
LOG_INFO("System RAM detected: ", totalRAM_ / (1024 * 1024 * 1024), " GB");
} else {
totalRAM_ = 16ull * 1024 * 1024 * 1024;
LOG_WARNING("Could not detect system RAM, assuming 16GB");
}
#else
struct sysinfo info;
if (sysinfo(&info) == 0) {
@ -69,6 +82,13 @@ size_t MemoryMonitor::getAvailableRAM() const {
return static_cast<size_t>(status.ullAvailPhys);
}
return totalRAM_ / 2;
#elif defined(__APPLE__)
int64_t usermem = 0;
size_t len = sizeof(usermem);
if (sysctlbyname("hw.usermem", &usermem, &len, nullptr, 0) == 0) {
return static_cast<size_t>(usermem);
}
return totalRAM_ / 2;
#else
// Best source on Linux for reclaimable memory headroom.
if (size_t memAvailable = readMemAvailableBytesFromProc(); memAvailable > 0) {