b3e747b900
Split the dongle session into a fast probe (xone_open) and a background start (xone_start) that loads the firmware and initializes the radio on a worker thread, so the app UI never blocks. Add xone_state/xone_error for progress display, and select the firmware image per product ID when no path is given. The Swift app polls the state each second and shows idle/starting/ready/error plus the firmware build or error string. The session destructor joins the worker so quitting the app does not terminate on a joinable thread. Note in the CLI and transport that the recover/re-enumerate path should not be used yet: a crashed SIE drops off the bus, while the MCU watchdog recovers it after ~90s of quiet. Co-Authored-By: qwen3.8-27b@q2_k_xl: async C API, Swift state display, and exit-time worker join
125 lines
5.0 KiB
CMake
125 lines
5.0 KiB
CMake
# CMake supports Swift only with the Ninja and Xcode generators.
|
|
if(NOT CMAKE_GENERATOR MATCHES "^(Ninja|Xcode)$")
|
|
message(FATAL_ERROR
|
|
"This project requires the Ninja or Xcode generator for Swift support.\n"
|
|
" Configure with: cmake -S . -B build -G Ninja")
|
|
endif()
|
|
|
|
cmake_minimum_required(VERSION 3.21)
|
|
project(xone_macos VERSION 0.1.9 LANGUAGES CXX Swift)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
# Add the deps directory to the module path
|
|
# Required for find_package injection
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps")
|
|
|
|
# Platform and compiler detection
|
|
include(Platform)
|
|
include(Flags)
|
|
include(Sanitizers)
|
|
|
|
# ==============================================================================
|
|
# Module libraries (bottom-up layering, mirrors medusalix/xone structure)
|
|
# ==============================================================================
|
|
|
|
# USB transport (IOKit / IOUSBFamily)
|
|
add_library(xone_usb STATIC
|
|
"src/usb/usb_transport.cpp"
|
|
)
|
|
target_include_directories(xone_usb PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_usb PRIVATE cxx_std_23)
|
|
target_compile_options(xone_usb PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_usb PRIVATE ${BASE_DEFINITIONS})
|
|
find_library(XONE_IOKIT IOKit)
|
|
find_library(XONE_COREFOUNDATION CoreFoundation)
|
|
target_link_libraries(xone_usb PUBLIC "${XONE_IOKIT}" "${XONE_COREFOUNDATION}")
|
|
|
|
# Auth + crypto (AES-CCMP key setup, ECDH, RSA — port from auth/)
|
|
add_library(xone_auth STATIC
|
|
"src/auth/crypto.cpp"
|
|
"src/auth/auth.cpp"
|
|
)
|
|
target_include_directories(xone_auth PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_auth PRIVATE cxx_std_23)
|
|
target_compile_options(xone_auth PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_auth PRIVATE ${BASE_DEFINITIONS})
|
|
find_library(XONE_SECURITY Security)
|
|
find_library(XONE_COREFOUNDATION CoreFoundation)
|
|
target_link_libraries(xone_auth PUBLIC "${XONE_SECURITY}" "${XONE_COREFOUNDATION}")
|
|
|
|
# MT76 chip protocol (firmware load, EFUSE, radio init, beacons)
|
|
add_library(xone_mt76 STATIC
|
|
"src/mt76/mt76.cpp"
|
|
)
|
|
target_include_directories(xone_mt76 PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_mt76 PRIVATE cxx_std_23)
|
|
target_compile_options(xone_mt76 PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_mt76 PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_mt76 PUBLIC xone_usb)
|
|
|
|
# GIP protocol (client lifecycle, handshake, status reports)
|
|
add_library(xone_gip STATIC
|
|
"src/gip/protocol.cpp"
|
|
)
|
|
target_include_directories(xone_gip PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_gip PRIVATE cxx_std_23)
|
|
target_compile_options(xone_gip PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_gip PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_gip PUBLIC xone_auth xone_mt76)
|
|
|
|
# Virtual HID gamepad presentation
|
|
add_library(xone_hid STATIC
|
|
"src/hid/hid_device.cpp"
|
|
)
|
|
target_include_directories(xone_hid PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_hid PRIVATE cxx_std_23)
|
|
target_compile_options(xone_hid PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_hid PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_hid PUBLIC xone_gip)
|
|
|
|
# C ABI bridge consumed by the Swift app and the test suite
|
|
add_library(xone_api STATIC
|
|
"src/app/api.cpp"
|
|
)
|
|
target_include_directories(xone_api PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_api PRIVATE cxx_std_23)
|
|
target_compile_options(xone_api PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_api PRIVATE XONE_VERSION="${PROJECT_VERSION}")
|
|
target_link_libraries(xone_api PUBLIC xone_hid)
|
|
|
|
# ==============================================================================
|
|
# macOS app (Swift entry point)
|
|
# ==============================================================================
|
|
add_executable(xone_app
|
|
"src/app/main.swift"
|
|
)
|
|
target_include_directories(xone_app PRIVATE "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_definitions(xone_app PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_app PRIVATE xone_api ${BASE_LIBRARIES})
|
|
|
|
# Swift sees the C ABI via a bridging header (no module map required)
|
|
target_compile_options(xone_app PRIVATE
|
|
-import-objc-header "${CMAKE_SOURCE_DIR}/include/app/xone_api.h"
|
|
)
|
|
|
|
# ==============================================================================
|
|
# Command line tool (protocol stack debugging against hardware)
|
|
# ==============================================================================
|
|
add_executable(xone_cli
|
|
"src/cli/main.cpp"
|
|
)
|
|
target_include_directories(xone_cli PRIVATE "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_definitions(xone_cli PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_cli PRIVATE xone_mt76)
|
|
|
|
# ==============================================================================
|
|
# Tests
|
|
# ==============================================================================
|
|
option(BUILD_TESTING OFF "Build Unity test suites")
|
|
if (BUILD_TESTING)
|
|
enable_testing()
|
|
find_package(Unity REQUIRED)
|
|
add_subdirectory(tests)
|
|
endif()
|