refactor(build): improve auto-discovery of GUI library sources in build_cleaner.py
- Enhanced the discover_cmake_libraries function to identify decomposed libraries and handle special cases for source variables. - Updated gui_library.cmake to utilize auto-maintenance markers, streamlining the management of source lists for GUI components. - Commented out hardcoded CMake source blocks, allowing for dynamic discovery of source files. Benefits: - Simplifies the maintenance of GUI library sources by automating updates and reducing manual configuration. - Improves clarity and efficiency in the build process for GUI components.
This commit is contained in:
@@ -159,6 +159,10 @@ def discover_cmake_libraries() -> List[CMakeSourceBlock]:
|
|||||||
# If a prefix has multiple variables, treat it as a decomposed library
|
# If a prefix has multiple variables, treat it as a decomposed library
|
||||||
decomposed_prefixes = {p for p, vars in prefix_groups.items() if len(vars) >= 2}
|
decomposed_prefixes = {p for p, vars in prefix_groups.items() if len(vars) >= 2}
|
||||||
|
|
||||||
|
# Check if this looks like a decomposed library (multiple *_SRC vars)
|
||||||
|
# even if some don't follow the PREFIX_SUBDIR_SRC pattern
|
||||||
|
is_likely_decomposed = len(variables) >= 2 and any(p in decomposed_prefixes for p in prefix_groups)
|
||||||
|
|
||||||
for var_name in variables:
|
for var_name in variables:
|
||||||
# Try to extract subdirectory from variable name
|
# Try to extract subdirectory from variable name
|
||||||
subdir_match = re.match(r'([A-Z]+)_([A-Z_]+)_(?:SRC|SOURCES|SOURCE)$', var_name)
|
subdir_match = re.match(r'([A-Z]+)_([A-Z_]+)_(?:SRC|SOURCES|SOURCE)$', var_name)
|
||||||
@@ -179,6 +183,22 @@ def discover_cmake_libraries() -> List[CMakeSourceBlock]:
|
|||||||
))
|
))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Handle special cases: CANVAS_SRC, etc. (no prefix, just subdirectory name)
|
||||||
|
# Pattern: SUBDIR_SRC where SUBDIR is a lowercase directory name
|
||||||
|
simple_match = re.match(r'([A-Z]+)_(?:SRC|SOURCES|SOURCE)$', var_name)
|
||||||
|
if simple_match and is_likely_decomposed:
|
||||||
|
subdir_part = simple_match.group(1)
|
||||||
|
subdir = subdir_part.lower()
|
||||||
|
target_dir = cmake_dir / subdir
|
||||||
|
|
||||||
|
if target_dir.exists() and target_dir.is_dir():
|
||||||
|
blocks.append(CMakeSourceBlock(
|
||||||
|
variable=var_name,
|
||||||
|
cmake_path=cmake_file,
|
||||||
|
directories=(DirectorySpec(target_dir, recursive=True),),
|
||||||
|
))
|
||||||
|
continue
|
||||||
|
|
||||||
# Fallback: scan entire cmake directory
|
# Fallback: scan entire cmake directory
|
||||||
blocks.append(CMakeSourceBlock(
|
blocks.append(CMakeSourceBlock(
|
||||||
variable=var_name,
|
variable=var_name,
|
||||||
@@ -259,31 +279,32 @@ STATIC_CONFIG: Sequence[CMakeSourceBlock] = (
|
|||||||
# cmake_path=SOURCE_ROOT / "app/gfx/gfx_library.cmake",
|
# cmake_path=SOURCE_ROOT / "app/gfx/gfx_library.cmake",
|
||||||
# directories=(DirectorySpec(SOURCE_ROOT / "app/gfx/debug"),),
|
# directories=(DirectorySpec(SOURCE_ROOT / "app/gfx/debug"),),
|
||||||
# ),
|
# ),
|
||||||
CMakeSourceBlock(
|
# Note: GUI library variables commented out - now auto-discovered via markers
|
||||||
variable="GUI_CORE_SRC",
|
# CMakeSourceBlock(
|
||||||
cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
# variable="GUI_CORE_SRC",
|
||||||
directories=(DirectorySpec(SOURCE_ROOT / "app/gui/core"),),
|
# cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
||||||
),
|
# directories=(DirectorySpec(SOURCE_ROOT / "app/gui/core"),),
|
||||||
CMakeSourceBlock(
|
# ),
|
||||||
variable="CANVAS_SRC",
|
# CMakeSourceBlock(
|
||||||
cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
# variable="CANVAS_SRC",
|
||||||
directories=(DirectorySpec(SOURCE_ROOT / "app/gui/canvas"),),
|
# cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
||||||
),
|
# directories=(DirectorySpec(SOURCE_ROOT / "app/gui/canvas"),),
|
||||||
CMakeSourceBlock(
|
# ),
|
||||||
variable="GUI_WIDGETS_SRC",
|
# CMakeSourceBlock(
|
||||||
cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
# variable="GUI_WIDGETS_SRC",
|
||||||
directories=(DirectorySpec(SOURCE_ROOT / "app/gui/widgets"),),
|
# cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
||||||
),
|
# directories=(DirectorySpec(SOURCE_ROOT / "app/gui/widgets"),),
|
||||||
CMakeSourceBlock(
|
# ),
|
||||||
variable="GUI_AUTOMATION_SRC",
|
# CMakeSourceBlock(
|
||||||
cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
# variable="GUI_AUTOMATION_SRC",
|
||||||
directories=(DirectorySpec(SOURCE_ROOT / "app/gui/automation"),),
|
# cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
||||||
),
|
# directories=(DirectorySpec(SOURCE_ROOT / "app/gui/automation"),),
|
||||||
CMakeSourceBlock(
|
# ),
|
||||||
variable="GUI_APP_SRC",
|
# CMakeSourceBlock(
|
||||||
cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
# variable="GUI_APP_SRC",
|
||||||
directories=(DirectorySpec(SOURCE_ROOT / "app/gui/app"),),
|
# cmake_path=SOURCE_ROOT / "app/gui/gui_library.cmake",
|
||||||
),
|
# directories=(DirectorySpec(SOURCE_ROOT / "app/gui/app"),),
|
||||||
|
# ),
|
||||||
CMakeSourceBlock(
|
CMakeSourceBlock(
|
||||||
variable="YAZE_AGENT_SOURCES",
|
variable="YAZE_AGENT_SOURCES",
|
||||||
cmake_path=SOURCE_ROOT / "cli/agent.cmake",
|
cmake_path=SOURCE_ROOT / "cli/agent.cmake",
|
||||||
|
|||||||
@@ -7,7 +7,12 @@
|
|||||||
# compatibility.
|
# compatibility.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# 1. Define Source Groups for each sub-library
|
# ==============================================================================
|
||||||
|
# SOURCE LISTS (auto-maintained by build_cleaner.py)
|
||||||
|
# Paths are relative to src/ directory
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# build_cleaner:auto-maintain
|
||||||
set(GUI_CORE_SRC
|
set(GUI_CORE_SRC
|
||||||
app/gui/core/background_renderer.cc
|
app/gui/core/background_renderer.cc
|
||||||
app/gui/core/color.cc
|
app/gui/core/color.cc
|
||||||
@@ -18,6 +23,7 @@ set(GUI_CORE_SRC
|
|||||||
app/gui/core/ui_helpers.cc
|
app/gui/core/ui_helpers.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# build_cleaner:auto-maintain
|
||||||
set(CANVAS_SRC
|
set(CANVAS_SRC
|
||||||
app/gui/canvas/bpp_format_ui.cc
|
app/gui/canvas/bpp_format_ui.cc
|
||||||
app/gui/canvas/canvas.cc
|
app/gui/canvas/canvas.cc
|
||||||
@@ -30,6 +36,7 @@ set(CANVAS_SRC
|
|||||||
app/gui/canvas/canvas_utils.cc
|
app/gui/canvas/canvas_utils.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# build_cleaner:auto-maintain
|
||||||
set(GUI_WIDGETS_SRC
|
set(GUI_WIDGETS_SRC
|
||||||
app/gui/widgets/asset_browser.cc
|
app/gui/widgets/asset_browser.cc
|
||||||
app/gui/widgets/dungeon_object_emulator_preview.cc
|
app/gui/widgets/dungeon_object_emulator_preview.cc
|
||||||
@@ -39,6 +46,7 @@ set(GUI_WIDGETS_SRC
|
|||||||
app/gui/widgets/tile_selector_widget.cc
|
app/gui/widgets/tile_selector_widget.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# build_cleaner:auto-maintain
|
||||||
set(GUI_AUTOMATION_SRC
|
set(GUI_AUTOMATION_SRC
|
||||||
app/gui/automation/widget_auto_register.cc
|
app/gui/automation/widget_auto_register.cc
|
||||||
app/gui/automation/widget_id_registry.cc
|
app/gui/automation/widget_id_registry.cc
|
||||||
@@ -46,6 +54,7 @@ set(GUI_AUTOMATION_SRC
|
|||||||
app/gui/automation/widget_state_capture.cc
|
app/gui/automation/widget_state_capture.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# build_cleaner:auto-maintain
|
||||||
set(GUI_APP_SRC
|
set(GUI_APP_SRC
|
||||||
app/gui/app/agent_chat_widget.cc
|
app/gui/app/agent_chat_widget.cc
|
||||||
app/gui/app/collaboration_panel.cc
|
app/gui/app/collaboration_panel.cc
|
||||||
@@ -53,6 +62,11 @@ set(GUI_APP_SRC
|
|||||||
app/gui/app/editor_layout.cc
|
app/gui/app/editor_layout.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# LIBRARY DEFINITIONS AND LINK STRUCTURE (manually configured)
|
||||||
|
# DO NOT AUTO-MAINTAIN
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
# 2. Create Static Libraries and Establish Link Dependencies
|
# 2. Create Static Libraries and Establish Link Dependencies
|
||||||
add_library(yaze_gui_core STATIC ${GUI_CORE_SRC})
|
add_library(yaze_gui_core STATIC ${GUI_CORE_SRC})
|
||||||
add_library(yaze_canvas STATIC ${CANVAS_SRC})
|
add_library(yaze_canvas STATIC ${CANVAS_SRC})
|
||||||
|
|||||||
Reference in New Issue
Block a user