From 63ea626cefb38c967b7ca129427dcf0ae8d1326e Mon Sep 17 00:00:00 2001 From: omigamedev Date: Thu, 4 Jun 2026 18:58:02 +0200 Subject: [PATCH] Isolate platform SDK includes from app header --- docs/modernization/build-inventory.md | 6 ++++++ docs/modernization/debt.md | 1 + docs/modernization/roadmap.md | 4 ++++ src/app.h | 16 ++++++++-------- src/platform_legacy/legacy_platform_services.cpp | 11 +++++++++++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index f3866bb..50c42ff 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -583,6 +583,12 @@ Known local toolchain state: while non-Windows platforms still reach retained platform bridges through the debt-tracked adapter isolated in `src/platform_legacy/legacy_platform_services.*`. +- `src/app.h` now forward-declares retained platform handles instead of + including Objective-C, Android, or GLFW SDK headers. The full platform SDK + headers needed by retained non-Windows bridges are included in + `src/platform_legacy/legacy_platform_services.cpp`, keeping central app + header consumers lighter while `DEBT-0055` tracks removal of those handles + from `App`. - `pp_platform_api` also owns `plan_asset_file_load`, the SDK-free file-load policy consumed by `LayoutManager` for XML layout reload decisions. The helper preserves desktop mtime-based reload behavior and non-desktop diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 5c4bca1..d662a50 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -72,6 +72,7 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0052 | Open | Modernization | Native UI/window state saving now dispatches through `PlatformServices`, but macOS execution still lives in `src/platform_legacy/legacy_platform_services.*` and forwards to the retained Objective-C app bridge | Preserve current Windows/macOS UI persistence while platform shells are extracted incrementally | `pp_platform_api_tests`; `ctest --preset desktop-fast --build-config Debug`; Windows app build; Apple package smoke once root Apple builds exist | UI/window state persistence is owned by injected platform services with no legacy adapter branch | | DEBT-0053 | Open | Modernization | Prepared-file writable target selection and prepared-file export-dialog policy now dispatch through `PlatformServices`, but iOS/Web target selection still lives in `src/platform_legacy/legacy_platform_services.*` | Preserve mobile/Web export handoff behavior while platform shells are extracted incrementally | `pp_platform_api_tests`; `ctest --preset desktop-fast --build-config Debug`; Windows app build; Apple/Web package smoke once root package builds exist | Prepared-file target selection, export-dialog policy, and save/download handoff are owned by injected platform services with no legacy adapter branch | | DEBT-0054 | Open | Modernization | Layout XML file read/reload decisions now consume `pp_platform_api::plan_asset_file_load`, but that helper still encodes the retained compile-time platform policy: Windows/macOS use `stat` mtime reload checks, while other platforms treat already-loaded layouts as successful no-op loads | Preserve current layout hot-reload and mobile/Web single-load behavior while removing platform guards from the shared `LayoutManager` parser | `pp_platform_api_tests`; `ctest --preset desktop-fast --build-config Debug -R pp_platform_api_tests`; Windows app build | Layout reload decisions are owned by injected platform storage/file-watch services or an asset manager boundary with platform-specific file watching removed from compile-time helpers | +| DEBT-0055 | Open | Modernization | `src/app.h` now forward-declares retained iOS/macOS/Android/Linux/Web platform handles instead of including platform SDK headers, and full SDK includes are isolated in `src/platform_legacy/legacy_platform_services.cpp`, but the `App` singleton still stores those platform handles directly | Reduce central header platform coupling incrementally without rewriting non-Windows platform entrypoints before Phase 6 | Windows app build; Apple/Android/Linux/Web package smoke once platform root builds are active | Platform handles are owned by injected `pp_platform_*` shell state or services, and `App` has no platform SDK handle fields or platform conditional members | ## Closed Debt diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 257642f..f11ca13 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -658,6 +658,10 @@ Windows installs an injected `WindowsPlatformServices` implementation from other platforms still route through the debt-tracked legacy fallback adapter now isolated in `src/platform_legacy/legacy_platform_services.*`, so behavior is preserved while their platform shell implementations are extracted. +The central `App` header now forward-declares retained platform handles instead +of including Objective-C, Android, or GLFW SDK headers; the full platform +headers live in the legacy platform adapter until those handles move out of +`App` during Phase 6. Prepared-file save/download handoff is now also part of the service contract, so iOS/Web export completion routes through `PlatformServices` after the app writes the temporary/exported payload. diff --git a/src/app.h b/src/app.h index 4410d07..3a45deb 100644 --- a/src/app.h +++ b/src/app.h @@ -32,23 +32,23 @@ struct PlatformStoragePaths; } #if defined(__OBJC__) && defined(__IOS__) -#import -#import "GameViewController.h" -#import "AppDelegate.h" +@class GameViewController; +@class AppDelegate; #endif #if defined(__OBJC__) && defined(__OSX__) -#import "main.h" +@class View; +@class AppOSX; #endif #ifdef __ANDROID__ -#include "main.h" +struct android_app; +struct engine; #endif -#ifdef __LINUX__ -#include +#if __LINUX__ || __WEB__ +struct GLFWwindow; #endif - struct VRController { enum class kButton : uint8_t diff --git a/src/platform_legacy/legacy_platform_services.cpp b/src/platform_legacy/legacy_platform_services.cpp index f57654e..3798359 100644 --- a/src/platform_legacy/legacy_platform_services.cpp +++ b/src/platform_legacy/legacy_platform_services.cpp @@ -7,6 +7,7 @@ #include "renderer_gl/opengl_capabilities.h" #ifdef __ANDROID__ +#include "main.h" void displayKeyboard(bool pShow); void android_async_lock(); void android_async_swap(); @@ -18,16 +19,26 @@ void android_pick_file_save(std::function callback); std::string android_get_clipboard(); bool android_set_clipboard(const std::string& s); #elif __APPLE__ +#include +#include "objc_utils.h" +#ifdef __IOS__ +#include "AppDelegate.h" +#include "GameViewController.h" +#elif defined(__OSX__) +#include "main.h" +#endif void delete_all_files_in_path(const std::string& source_path); #ifdef __IOS__ void save_image_library(const std::string& path); #endif #elif __LINUX__ +#include #include std::string linux_home_path(); int mkpath(const std::string& dir, mode_t mode = DEFFILEMODE); void linux_update_fps(int frames); #elif __WEB__ +#include void webgl_pick_file(std::function callback); void webgl_pick_file_save( const std::string& path,