Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 24 additions & 13 deletions AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
## Architecture: Three-Layer Strict Dependency

```
desktop/ (Layer 3) → ui/ (Layer 2) → base/ (Layer 1) → Qt/OS API
main/ (Layer 3) → ui/ (Layer 2) → base/ (Layer 1) → Qt/OS API
```

**Rules (STRICT single-direction):**
- `base/` MUST NOT `#include` from `ui/` or `desktop/`
- `ui/` MUST NOT `#include` from `desktop/`
- `desktop/` MAY `#include` from `ui/` and `base/`
- Verify: `grep -r '#include.*\(ui/\|desktop/\)' base/` must return nothing
- Verify: `grep -r '#include.*desktop/' ui/` must return nothing
- `base/` MUST NOT `#include` from `ui/` or `main/`
- `ui/` MUST NOT `#include` from `main/`
- `main/` MAY `#include` from `ui/` and `base/`
- Verify: `grep -r '#include.*\(ui/\|main/\)' base/` must return nothing
- Verify: `grep -r '#include.*main/' ui/` must return nothing

## Build System

Expand Down Expand Up @@ -93,13 +93,24 @@ Material Design 3 UI framework (5-layer pipeline):
- Layer 4: Material Behavior (`StateMachine`, `RippleHelper`, `MdElevationController`)
- Layer 5: Widget Adapter (19 MD3 widgets: Button, TextField, Slider, etc.)

### desktop/ → CFDesktop_shared
Desktop environment implementation.
- `main/` — DAG-based initialization chain + entry point
- `base/config_manager/` — 4-layer ConfigStore (Temp/App/User/System) with JSON backend
- `base/logger/` — Async multi-sink logging (lock-free MPSC queue)
- `ui/components/` — Core interfaces (`IWindow`, `IDisplayServerBackend`)
- `ui/platform/` — Platform backends (Windows, WSL X11, Wayland planned)
### base/ → cfbase + desktop infrastructure (merged)
Foundation layer: hardware probes + desktop infrastructure (cfbase SHARED + 6 desktop-base STATIC modules).
- `cfbase/` — Hardware probes (CPU/memory/GPU/network) + HWTier + console (SHARED)
- `config_manager/` — 4-layer ConfigStore (Temp/App/User/System) with JSON backend
- `logger/` — Async multi-sink logging (lock-free MPSC queue, SHARED)
- `path/` / `file_operations/` / `fundamental/` / `ascii_art/` — path resolution, file ops, helpers

### ui/ → CFDesktopUi
Shell-specific Material Design 3 UI (the reusable widget lib is the QuarkWidgets submodule).
- `components/` — Core interfaces (`IWindow`, `IDisplayServerBackend`)
- `platform/` — Platform backends (Windows, WSL X11, Wayland planned)
- `widget/` / `models/` / `render/` / `base/`

### main/ → CFDesktopMain (+ CFDesktop_shared assembled at top level)
Desktop entry point + initialization.
- `init/` — DAG-based initialization chain
- `early_session/` — Pre-QApplication setup
- `desktop_entry.cpp` + top-level `main.cpp` + `desktop_run_session.cpp` — entry + session

## Phase System

Expand Down
107 changes: 101 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,113 @@ setup_third_party(
# Standalone desktop apps now live in the separate `CFDeskit` repo
# (https://github.com/Awesome-Embedded-Learning-Studio/CFDeskit). The main
# repo no longer compiles apps — they are deployed as prebuilt artifacts into
# <bin>/../apps/<id>/ at install/runtime, where AppDiscoverer scans them.
# See apps/README.md for the deployment contract.
# <active_root>/apps/<id>/ at install/runtime, where AppDiscoverer scans them.
# See third_party/apps/README.md for the deployment contract.

log_module_start("desktop")
add_subdirectory(desktop)
# Log base module end
log_module_end("desktop")
# ============================================================
# UI layer (Material Design 3 components, platform backends; was desktop/ui/)
# ============================================================
log_module_start("ui")
add_subdirectory(ui)
log_module_end("ui")

# ============================================================
# Main layer (init chain + entry; was desktop/main/)
# ============================================================
log_module_start("main")
add_subdirectory(main)
log_module_end("main")

# ============================================================
# Unified CFDesktop Shared Library — assembles static libs from base/ui/main.
# Moved here from the deleted desktop/CMakeLists.txt.
# ============================================================
log_info("Desktop" "Creating unified CFDesktop shared library")

add_library(CFDesktop_shared SHARED)

if(WIN32)
target_compile_definitions(CFDesktop_shared PRIVATE CFDESKTOP_EXPORTS)
endif()
if(UNIX AND NOT APPLE)
target_compile_options(CFDesktop_shared PRIVATE -fvisibility=hidden)
endif()

target_include_directories(CFDesktop_shared PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/base>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/main>
)

# Static libs folded into the .so via --whole-archive.
set(CFDESKTOP_STATIC_LIBS
cffilesystem
cfconfig
cfasciiart
CFDesktopMain
CFDesktopUi
cf_desktop_render
)

# Sources compiled directly into the DLL (with CFDESKTOP_EXPORTS defined).
target_sources(CFDesktop_shared PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/main/desktop_run_session.cpp
)

if(MSVC)
target_link_libraries(CFDesktop_shared PRIVATE ${CFDESKTOP_STATIC_LIBS})
foreach(_cfdesktop_module IN LISTS CFDESKTOP_STATIC_LIBS)
target_link_options(CFDesktop_shared PRIVATE "/WHOLEARCHIVE:$<TARGET_FILE:${_cfdesktop_module}>")
endforeach()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT APPLE)
target_link_libraries(CFDesktop_shared PRIVATE
"-Wl,--whole-archive"
${CFDESKTOP_STATIC_LIBS}
"-Wl,--no-whole-archive"
)
else()
target_link_libraries(CFDesktop_shared PRIVATE ${CFDESKTOP_STATIC_LIBS})
endif()

target_link_libraries(CFDesktop_shared PUBLIC
Qt6::Core
Qt6::Gui
Qt6::Widgets
)
# QuarkWidgets::quarkwidgets is PUBLIC so the thin EXE can include the
# QApplication subclass (MaterialApplication) it instantiates in main.cpp.
target_link_libraries(CFDesktop_shared
PRIVATE
cfbase
cflogger
PUBLIC
QuarkWidgets::quarkwidgets
)

if(WIN32)
target_link_libraries(CFDesktop_shared PUBLIC
wbemuuid PowrProf pdh psapi
)
endif()

add_library(CFDesktop::lib ALIAS CFDesktop_shared)

# ============================================================
# Main executable — thin shell that calls into the DLL
# ============================================================
add_executable(CFDesktop main.cpp)
target_link_libraries(CFDesktop PRIVATE CFDesktop_shared)

log_info("Desktop Buildings" "Configuring Desktop Buildings Done")

log_module_start("example")
add_subdirectory("example")
log_module_end("example")

# Enable CTest at the top level so CTestTestfile.cmake is generated for the
# build root (enable_testing() inside test/CMakeLists.txt only covers that scope).
enable_testing()

# Log test module start
log_module_start("test")
add_subdirectory(test)
Expand Down
101 changes: 14 additions & 87 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,87 +1,14 @@
# Base library - fundamental utilities and platform abstractions
cmake_minimum_required(VERSION 3.16)

# ============================================================
# Header-only exposure for base/include (system probes + platform helpers).
# Foundation utilities (expected, scope_guard, weak_ptr, macro, ...) were
# extracted to the aex submodule; retained headers (e.g. windows/co_helper.hpp)
# include them, so aex::aex is propagated here.
# ============================================================
add_library(cfbase_headers INTERFACE)
target_include_directories(cfbase_headers INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(cfbase_headers INTERFACE aex::aex)
add_library(CFDesktop::base_headers ALIAS cfbase_headers)

# Include subdirectory CMakeLists (static libraries)
add_subdirectory(system)
add_subdirectory(device)

# ============================================================
# Unified Base Library - Single DLL: cfbase.dll
# ============================================================

# Create the unified shared library
add_library(cfbase SHARED)

set(CFBASE_MODULE_TARGETS
cfbase_cpu
cfbase_memory
cfbase_network
cfbase_gpu
cfbase_console
cfbase_hardware_tier
)

# Link static libraries from sub-modules with --whole-archive to ensure
# all symbols (including dllexport) are included in cfbase.dll.
# Without this, the linker skips static lib objects since cfbase has no own sources.
# Force all objects into cfbase.dll (PRIVATE: only affects cfbase's link step).
if(MSVC)
target_link_libraries(cfbase PRIVATE ${CFBASE_MODULE_TARGETS})
foreach(_cfbase_module IN LISTS CFBASE_MODULE_TARGETS)
target_link_options(cfbase PRIVATE "/WHOLEARCHIVE:$<TARGET_FILE:${_cfbase_module}>")
endforeach()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT APPLE)
target_link_libraries(cfbase PRIVATE
-Wl,--whole-archive
${CFBASE_MODULE_TARGETS}
-Wl,--no-whole-archive
)
else()
target_link_libraries(cfbase PRIVATE ${CFBASE_MODULE_TARGETS})
endif()

# Set include directories
# Expose both include/ (for public headers) and . (for sub-module headers like device/console)
target_include_directories(cfbase PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)

# Link dependencies
target_link_libraries(cfbase PUBLIC
Qt6::Core
aex::aex
)

# Platform-specific link libraries
if(WIN32)
target_link_libraries(cfbase PUBLIC
wbemuuid
PowrProf
pdh
psapi
)
endif()

# ============================================================
# Aliases
# ============================================================
add_library(CFDesktop::base ALIAS cfbase)
# For backward compatibility
add_library(CFDesktop::base_cpu ALIAS cfbase)
add_library(CFDesktop::base_memory ALIAS cfbase)
add_library(CFDesktop::base_console ALIAS cfbase)
# ============================================================
# base/ — Foundation layer
# Merges cfbase (hardware probes + HWTier + console, SHARED) with the desktop
# infrastructure (logger/config/path/filesystem/fundamental/ascii_art, STATIC)
# into a single base layer. Downstream (main/CFDesktop_shared) consumes them
# via the existing target aliases (CFDesktop::base, cfconfig, cfpath, ...).
# ============================================================
add_subdirectory(cfbase)
add_subdirectory(fundamental)
add_subdirectory(path)
add_subdirectory(logger)
add_subdirectory(file_operations)
add_subdirectory(config_manager)
add_subdirectory(ascii_art)
File renamed without changes.
87 changes: 87 additions & 0 deletions base/cfbase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Base library - fundamental utilities and platform abstractions
cmake_minimum_required(VERSION 3.16)

# ============================================================
# Header-only exposure for base/include (system probes + platform helpers).
# Foundation utilities (expected, scope_guard, weak_ptr, macro, ...) were
# extracted to the aex submodule; retained headers (e.g. windows/co_helper.hpp)
# include them, so aex::aex is propagated here.
# ============================================================
add_library(cfbase_headers INTERFACE)
target_include_directories(cfbase_headers INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(cfbase_headers INTERFACE aex::aex)
add_library(CFDesktop::base_headers ALIAS cfbase_headers)

# Include subdirectory CMakeLists (static libraries)
add_subdirectory(system)
add_subdirectory(device)

# ============================================================
# Unified Base Library - Single DLL: cfbase.dll
# ============================================================

# Create the unified shared library
add_library(cfbase SHARED)

set(CFBASE_MODULE_TARGETS
cfbase_cpu
cfbase_memory
cfbase_network
cfbase_gpu
cfbase_console
cfbase_hardware_tier
)

# Link static libraries from sub-modules with --whole-archive to ensure
# all symbols (including dllexport) are included in cfbase.dll.
# Without this, the linker skips static lib objects since cfbase has no own sources.
# Force all objects into cfbase.dll (PRIVATE: only affects cfbase's link step).
if(MSVC)
target_link_libraries(cfbase PRIVATE ${CFBASE_MODULE_TARGETS})
foreach(_cfbase_module IN LISTS CFBASE_MODULE_TARGETS)
target_link_options(cfbase PRIVATE "/WHOLEARCHIVE:$<TARGET_FILE:${_cfbase_module}>")
endforeach()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT APPLE)
target_link_libraries(cfbase PRIVATE
-Wl,--whole-archive
${CFBASE_MODULE_TARGETS}
-Wl,--no-whole-archive
)
else()
target_link_libraries(cfbase PRIVATE ${CFBASE_MODULE_TARGETS})
endif()

# Set include directories
# Expose both include/ (for public headers) and . (for sub-module headers like device/console)
target_include_directories(cfbase PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)

# Link dependencies
target_link_libraries(cfbase PUBLIC
Qt6::Core
aex::aex
)

# Platform-specific link libraries
if(WIN32)
target_link_libraries(cfbase PUBLIC
wbemuuid
PowrProf
pdh
psapi
)
endif()

# ============================================================
# Aliases
# ============================================================
add_library(CFDesktop::base ALIAS cfbase)
# For backward compatibility
add_library(CFDesktop::base_cpu ALIAS cfbase)
add_library(CFDesktop::base_memory ALIAS cfbase)
add_library(CFDesktop::base_console ALIAS cfbase)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading