refactor(build): enhance build_cleaner.py for auto-discovery of CMake libraries
- Updated the discover_cmake_libraries function to support new marker comments for auto-maintenance. - Improved variable extraction logic to handle decomposed libraries and subdirectory detection. - Removed hardcoded CMake source blocks in favor of auto-discovery, streamlining the management of graphics library sources. Benefits: - Simplifies the maintenance of CMake files by automating source list updates. - Enhances build efficiency and clarity by reducing manual configuration requirements.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
# ==============================================================================
|
||||
# YAZE GFX Library Refactoring: Tiered Graphics Architecture
|
||||
# YAZE GFX Library: Tiered Graphics Architecture
|
||||
#
|
||||
# This file implements the tiered graphics architecture as proposed in
|
||||
# docs/gfx-refactor.md. The monolithic yaze_gfx library is decomposed
|
||||
# into smaller, layered static libraries to improve build times and clarify
|
||||
# dependencies.
|
||||
# This file implements a layered graphics library to avoid circular dependencies
|
||||
# and improve build times.
|
||||
#
|
||||
# IMPORTANT FOR BUILD_CLEANER:
|
||||
# - Source lists marked with "build_cleaner:auto-maintain" are managed automatically
|
||||
# - Paths MUST be relative to SOURCE_ROOT (src/) for consistency
|
||||
# - All other sections (macros, link structure) are manually configured
|
||||
# ==============================================================================
|
||||
|
||||
# ==============================================================================
|
||||
@@ -41,119 +44,110 @@ macro(configure_gfx_library name)
|
||||
endmacro()
|
||||
|
||||
# ==============================================================================
|
||||
# 3.1. gfx_types (Foundation)
|
||||
# Responsibility: Pure data structures for SNES graphics primitives.
|
||||
# Dependencies: None
|
||||
# SOURCE LISTS (auto-maintained by build_cleaner.py)
|
||||
# Paths are relative to src/ directory
|
||||
# ==============================================================================
|
||||
|
||||
# build_cleaner:auto-maintain
|
||||
set(GFX_TYPES_SRC
|
||||
app/gfx/types/snes_color.cc
|
||||
app/gfx/types/snes_palette.cc
|
||||
app/gfx/types/snes_tile.cc
|
||||
)
|
||||
add_library(yaze_gfx_types STATIC ${GFX_TYPES_SRC})
|
||||
configure_gfx_library(yaze_gfx_types)
|
||||
message(STATUS " - GFX Tier: gfx_types configured")
|
||||
|
||||
# ==============================================================================
|
||||
# 3.2. gfx_backend (Rendering Abstraction)
|
||||
# Responsibility: Low-level rendering interface and SDL2 implementation.
|
||||
# Dependencies: SDL2
|
||||
# ==============================================================================
|
||||
# build_cleaner:auto-maintain
|
||||
set(GFX_BACKEND_SRC
|
||||
app/gfx/backend/sdl2_renderer.cc
|
||||
)
|
||||
add_library(yaze_gfx_backend STATIC ${GFX_BACKEND_SRC})
|
||||
configure_gfx_library(yaze_gfx_backend)
|
||||
target_link_libraries(yaze_gfx_backend PUBLIC ${SDL_TARGETS})
|
||||
message(STATUS " - GFX Tier: gfx_backend configured")
|
||||
|
||||
# ==============================================================================
|
||||
# 3.3. gfx_resource (Resource Management)
|
||||
# Responsibility: Manages memory and GPU resources.
|
||||
# Dependencies: gfx_backend
|
||||
# ==============================================================================
|
||||
# build_cleaner:auto-maintain
|
||||
set(GFX_RESOURCE_SRC
|
||||
app/gfx/resource/arena.cc
|
||||
app/gfx/resource/memory_pool.cc
|
||||
)
|
||||
add_library(yaze_gfx_resource STATIC ${GFX_RESOURCE_SRC})
|
||||
configure_gfx_library(yaze_gfx_resource)
|
||||
target_link_libraries(yaze_gfx_resource PUBLIC yaze_gfx_backend)
|
||||
message(STATUS " - GFX Tier: gfx_resource configured")
|
||||
|
||||
# ==============================================================================
|
||||
# 3.4. gfx_core (Core Graphics Object)
|
||||
# Responsibility: The central Bitmap class.
|
||||
# Dependencies: gfx_types, gfx_resource
|
||||
# ==============================================================================
|
||||
# build_cleaner:auto-maintain
|
||||
set(GFX_CORE_SRC
|
||||
app/gfx/core/bitmap.cc
|
||||
)
|
||||
add_library(yaze_gfx_core STATIC ${GFX_CORE_SRC})
|
||||
configure_gfx_library(yaze_gfx_core)
|
||||
target_link_libraries(yaze_gfx_core PUBLIC
|
||||
yaze_gfx_types
|
||||
yaze_gfx_resource
|
||||
)
|
||||
message(STATUS " - GFX Tier: gfx_core configured")
|
||||
|
||||
# ==============================================================================
|
||||
# 3.5. gfx_util (Utilities)
|
||||
# Responsibility: Standalone graphics data conversion and compression.
|
||||
# Dependencies: gfx_core
|
||||
# ==============================================================================
|
||||
# build_cleaner:auto-maintain
|
||||
set(GFX_UTIL_SRC
|
||||
app/gfx/util/bpp_format_manager.cc
|
||||
app/gfx/util/compression.cc
|
||||
app/gfx/util/scad_format.cc
|
||||
app/gfx/util/palette_manager.cc
|
||||
app/gfx/util/scad_format.cc
|
||||
)
|
||||
add_library(yaze_gfx_util STATIC ${GFX_UTIL_SRC})
|
||||
configure_gfx_library(yaze_gfx_util)
|
||||
target_link_libraries(yaze_gfx_util PUBLIC yaze_gfx_core)
|
||||
message(STATUS " - GFX Tier: gfx_util configured")
|
||||
|
||||
# ==============================================================================
|
||||
# 3.6. gfx_render (High-Level Rendering)
|
||||
# Responsibility: Advanced rendering strategies.
|
||||
# Dependencies: gfx_core, gfx_backend
|
||||
# ==============================================================================
|
||||
# build_cleaner:auto-maintain
|
||||
set(GFX_RENDER_SRC
|
||||
app/gfx/render/atlas_renderer.cc
|
||||
app/gfx/render/background_buffer.cc
|
||||
app/gfx/render/texture_atlas.cc
|
||||
app/gfx/render/tilemap.cc
|
||||
)
|
||||
add_library(yaze_gfx_render STATIC ${GFX_RENDER_SRC})
|
||||
configure_gfx_library(yaze_gfx_render)
|
||||
target_link_libraries(yaze_gfx_render PUBLIC
|
||||
yaze_gfx_core
|
||||
yaze_gfx_backend
|
||||
)
|
||||
message(STATUS " - GFX Tier: gfx_render configured")
|
||||
|
||||
# ==============================================================================
|
||||
# 3.7. gfx_debug (Performance & Analysis)
|
||||
# Responsibility: Profiling, debugging, and optimization tools.
|
||||
# Dependencies: gfx_util, gfx_render
|
||||
# ==============================================================================
|
||||
# build_cleaner:auto-maintain
|
||||
set(GFX_DEBUG_SRC
|
||||
app/gfx/debug/graphics_optimizer.cc
|
||||
app/gfx/debug/performance/performance_dashboard.cc
|
||||
app/gfx/debug/performance/performance_profiler.cc
|
||||
app/gfx/debug/graphics_optimizer.cc
|
||||
)
|
||||
add_library(yaze_gfx_debug STATIC ${GFX_DEBUG_SRC})
|
||||
configure_gfx_library(yaze_gfx_debug)
|
||||
target_link_libraries(yaze_gfx_debug PUBLIC
|
||||
yaze_gfx_util
|
||||
yaze_gfx_render
|
||||
)
|
||||
message(STATUS " - GFX Tier: gfx_debug configured")
|
||||
|
||||
# ==============================================================================
|
||||
# Aggregate INTERFACE Library (yaze_gfx)
|
||||
# Provides a single link target for external consumers (e.g., yaze_gui).
|
||||
# LIBRARY DEFINITIONS AND LINK STRUCTURE (manually configured)
|
||||
# DO NOT AUTO-MAINTAIN - Dependency order is critical to avoid circular deps
|
||||
# ==============================================================================
|
||||
|
||||
# Layer 1: Foundation types (no dependencies)
|
||||
add_library(yaze_gfx_types STATIC ${GFX_TYPES_SRC})
|
||||
configure_gfx_library(yaze_gfx_types)
|
||||
|
||||
# Layer 2: Backend (depends on types)
|
||||
add_library(yaze_gfx_backend STATIC ${GFX_BACKEND_SRC})
|
||||
configure_gfx_library(yaze_gfx_backend)
|
||||
target_link_libraries(yaze_gfx_backend PUBLIC
|
||||
yaze_gfx_types
|
||||
${SDL_TARGETS}
|
||||
)
|
||||
|
||||
# Layer 3a: Resource management (depends on backend)
|
||||
add_library(yaze_gfx_resource STATIC ${GFX_RESOURCE_SRC})
|
||||
configure_gfx_library(yaze_gfx_resource)
|
||||
target_link_libraries(yaze_gfx_resource PUBLIC yaze_gfx_backend)
|
||||
|
||||
# Layer 3b: Rendering (depends on types, NOT on core to avoid circular dep)
|
||||
add_library(yaze_gfx_render STATIC ${GFX_RENDER_SRC})
|
||||
configure_gfx_library(yaze_gfx_render)
|
||||
target_link_libraries(yaze_gfx_render PUBLIC
|
||||
yaze_gfx_types
|
||||
yaze_gfx_backend
|
||||
)
|
||||
|
||||
# Layer 3c: Debug tools (depends on types only at this level)
|
||||
add_library(yaze_gfx_debug STATIC ${GFX_DEBUG_SRC})
|
||||
configure_gfx_library(yaze_gfx_debug)
|
||||
target_link_libraries(yaze_gfx_debug PUBLIC
|
||||
yaze_gfx_types
|
||||
ImGui
|
||||
)
|
||||
|
||||
# Layer 4: Core bitmap (depends on resource, render, debug)
|
||||
add_library(yaze_gfx_core STATIC ${GFX_CORE_SRC})
|
||||
configure_gfx_library(yaze_gfx_core)
|
||||
target_link_libraries(yaze_gfx_core PUBLIC
|
||||
yaze_gfx_types
|
||||
yaze_gfx_resource
|
||||
yaze_gfx_render
|
||||
yaze_gfx_debug
|
||||
)
|
||||
|
||||
# Layer 5: Utilities (depends on core)
|
||||
add_library(yaze_gfx_util STATIC ${GFX_UTIL_SRC})
|
||||
configure_gfx_library(yaze_gfx_util)
|
||||
target_link_libraries(yaze_gfx_util PUBLIC yaze_gfx_core)
|
||||
|
||||
# Aggregate INTERFACE library for easy linking
|
||||
add_library(yaze_gfx INTERFACE)
|
||||
target_link_libraries(yaze_gfx INTERFACE
|
||||
yaze_gfx_types
|
||||
@@ -163,9 +157,6 @@ target_link_libraries(yaze_gfx INTERFACE
|
||||
yaze_gfx_util
|
||||
yaze_gfx_render
|
||||
yaze_gfx_debug
|
||||
yaze_util
|
||||
yaze_common
|
||||
${ABSL_TARGETS}
|
||||
)
|
||||
|
||||
# Conditionally add PNG support
|
||||
|
||||
Reference in New Issue
Block a user