feat: Implement modular build system for Yaze

- Added option to enable modular build with `YAZE_USE_MODULAR_BUILD`.
- Updated CMake configuration to support modular libraries for core, editor, graphics, GUI, and emulator functionalities.
- Refactored existing libraries to separate concerns and improve build times.
- Introduced new utility library `yaze_util` for low-level utilities.
- Adjusted CI and release workflows to accommodate the new build system.
- Updated various source files to reflect new include paths and modular structure.
- Enhanced YAML configuration handling in the agent component.
This commit is contained in:
scawful
2025-10-03 18:32:51 -04:00
parent 60e9ea69ac
commit c3eaace72c
22 changed files with 752 additions and 112 deletions

View File

@@ -98,7 +98,26 @@ else()
target_compile_definitions(yaze PRIVATE YAZE_ENABLE_NFD=0)
endif()
target_link_libraries(yaze PRIVATE yaze_core)
if(YAZE_USE_MODULAR_BUILD)
target_link_libraries(yaze PRIVATE
yaze_util
yaze_gfx
yaze_gui
yaze_zelda3
yaze_core_lib
yaze_editor
)
if(TARGET yaze_agent)
target_link_libraries(yaze PRIVATE yaze_agent)
endif()
if(YAZE_BUILD_EMU AND NOT YAZE_WITH_GRPC AND TARGET yaze_emulator)
target_link_libraries(yaze PRIVATE yaze_emulator)
endif()
else()
target_link_libraries(yaze PRIVATE yaze_core)
endif()
# Enable policy framework in main yaze target
target_compile_definitions(yaze PRIVATE YAZE_ENABLE_POLICY_FRAMEWORK=1)
@@ -224,22 +243,24 @@ if(YAZE_WITH_GRPC)
${CMAKE_SOURCE_DIR}/third_party/json/include)
target_compile_definitions(yaze PRIVATE YAZE_WITH_JSON)
# Generate C++ code from .proto using the helper function from cmake/grpc.cmake
target_add_protobuf(yaze
${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto)
# Add service implementation sources
target_sources(yaze PRIVATE
${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.h
${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.h
${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.h
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.cc
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.h
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.cc
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.h)
if(NOT YAZE_USE_MODULAR_BUILD)
# Generate C++ code from .proto using the helper function from cmake/grpc.cmake
target_add_protobuf(yaze
${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto)
# Add service implementation sources
target_sources(yaze PRIVATE
${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.h
${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.h
${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.h
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.cc
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.h
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.cc
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.h)
endif()
# Link gRPC libraries
target_link_libraries(yaze PRIVATE

View File

@@ -0,0 +1,92 @@
# ==============================================================================
# Yaze Core Library
# ==============================================================================
# This library contains core application functionality:
# - ROM management
# - Project management
# - Controller/Window management
# - Asar wrapper for assembly
# - Platform-specific utilities (file dialogs, fonts, clipboard)
# - Widget state capture for testing
# - Emulator interface
#
# Dependencies: yaze_util, yaze_gfx, asar, SDL2
# ==============================================================================
add_library(yaze_core_lib STATIC
app/rom.cc
${YAZE_APP_CORE_SRC}
)
target_include_directories(yaze_core_lib PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/app
${CMAKE_SOURCE_DIR}/src/lib
${CMAKE_SOURCE_DIR}/src/lib/imgui
${CMAKE_SOURCE_DIR}/src/lib/asar/src
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c
${CMAKE_SOURCE_DIR}/incl
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_core_lib PUBLIC
yaze_util
yaze_gfx
yaze_common
asar-static
${ABSL_TARGETS}
${SDL_TARGETS}
${CMAKE_DL_LIBS}
)
target_sources(yaze_core_lib PRIVATE
${CMAKE_SOURCE_DIR}/src/cli/service/testing/test_workflow_generator.cc
)
if(YAZE_WITH_GRPC)
target_add_protobuf(yaze_core_lib
${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto)
target_sources(yaze_core_lib PRIVATE
${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.h
${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.h
${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.h
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.cc
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.h
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.cc
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.h
)
target_link_libraries(yaze_core_lib PUBLIC
grpc++
grpc++_reflection
libprotobuf
)
endif()
# Platform-specific libraries
if(APPLE)
target_link_libraries(yaze_core_lib PUBLIC ${COCOA_LIBRARY})
endif()
set_target_properties(yaze_core_lib PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
# Platform-specific compile definitions
if(UNIX AND NOT APPLE)
target_compile_definitions(yaze_core_lib PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_core_lib PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_core_lib PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_core_lib library configured")

View File

@@ -0,0 +1,73 @@
# ==============================================================================
# Yaze Editor Library
# ==============================================================================
# This library contains all editor functionality:
# - Editor manager and coordination
# - Dungeon editor (room selector, object editor, renderer)
# - Overworld editor (map, tile16, entities)
# - Sprite editor
# - Music editor
# - Message editor
# - Assembly editor
# - Graphics/palette editors
# - System editors (settings, commands, extensions)
# - Testing infrastructure
#
# Dependencies: yaze_core_lib, yaze_gfx, yaze_gui, yaze_zelda3, ImGui
# ==============================================================================
add_library(yaze_editor STATIC ${YAZE_APP_EDITOR_SRC})
target_include_directories(yaze_editor PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/lib
${CMAKE_SOURCE_DIR}/src/lib/imgui
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
${CMAKE_SOURCE_DIR}/incl
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_editor PUBLIC
yaze_core_lib
yaze_gfx
yaze_gui
yaze_zelda3
yaze_util
yaze_common
ImGui
)
# Conditionally link ImGui Test Engine
if(YAZE_ENABLE_UI_TESTS AND TARGET ImGuiTestEngine)
target_link_libraries(yaze_editor PUBLIC ImGuiTestEngine)
target_compile_definitions(yaze_editor PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=1)
else()
target_compile_definitions(yaze_editor PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=0)
endif()
# Conditionally link gRPC if enabled
if(YAZE_WITH_GRPC)
target_link_libraries(yaze_editor PRIVATE
grpc++
grpc++_reflection
libprotobuf
)
endif()
set_target_properties(yaze_editor PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
# Platform-specific compile definitions
if(UNIX AND NOT APPLE)
target_compile_definitions(yaze_editor PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_editor PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_editor PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_editor library configured")

View File

@@ -20,7 +20,7 @@
#include "app/gui/modules/asset_browser.h"
#include "app/gui/style.h"
#include "app/rom.h"
#include "gfx/performance_profiler.h"
#include "app/gfx/performance_profiler.h"
#include "imgui/imgui.h"
#include "imgui/misc/cpp/imgui_stdlib.h"
#include "imgui_memory_editor.h"

View File

@@ -0,0 +1,47 @@
# ==============================================================================
# Yaze Emulator Library
# ==============================================================================
# This library contains SNES emulation functionality:
# - CPU (65C816) implementation
# - PPU (Picture Processing Unit) for graphics
# - APU (Audio Processing Unit) with SPC700 and DSP
# - DMA controller
# - Memory management
#
# Dependencies: yaze_util, SDL2
# ==============================================================================
add_library(yaze_emulator STATIC ${YAZE_APP_EMU_SRC})
target_include_directories(yaze_emulator PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/app
${CMAKE_SOURCE_DIR}/src/lib
${CMAKE_SOURCE_DIR}/incl
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_emulator PUBLIC
yaze_util
yaze_common
${ABSL_TARGETS}
${SDL_TARGETS}
)
set_target_properties(yaze_emulator PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
# Platform-specific compile definitions
if(UNIX AND NOT APPLE)
target_compile_definitions(yaze_emulator PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_emulator PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_emulator PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_emulator library configured")

View File

@@ -0,0 +1,53 @@
# ==============================================================================
# Yaze Graphics Library
# ==============================================================================
# This library contains all graphics-related functionality:
# - Bitmap manipulation
# - SNES tile/palette handling
# - Compression/decompression
# - Arena memory management
# - Atlas rendering
# - Performance profiling
#
# Dependencies: yaze_util, SDL2, Abseil
# ==============================================================================
add_library(yaze_gfx STATIC ${YAZE_APP_GFX_SRC})
target_include_directories(yaze_gfx PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/lib
${CMAKE_SOURCE_DIR}/incl
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_gfx PUBLIC
yaze_util
yaze_common
${ABSL_TARGETS}
${SDL_TARGETS}
)
# Conditionally add PNG support
if(PNG_FOUND)
target_include_directories(yaze_gfx PUBLIC ${PNG_INCLUDE_DIRS})
target_link_libraries(yaze_gfx PUBLIC ${PNG_LIBRARIES})
endif()
set_target_properties(yaze_gfx PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
# Platform-specific compile definitions
if(UNIX AND NOT APPLE)
target_compile_definitions(yaze_gfx PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_gfx PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_gfx PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_gfx library configured")

View File

@@ -1,7 +1,7 @@
#ifndef YAZE_GUI_CANVAS_H
#define YAZE_GUI_CANVAS_H
#include "gfx/tilemap.h"
#include "app/gfx/tilemap.h"
#define IMGUI_DEFINE_MATH_OPERATORS
#include <cstdint>

View File

@@ -9,7 +9,7 @@
#include "app/gui/enhanced_palette_editor.h"
#include "app/gui/bpp_format_ui.h"
#include "app/gui/icons.h"
#include "gui/canvas/canvas_modals.h"
#include "app/gui/canvas/canvas_modals.h"
#include "imgui/imgui.h"
namespace yaze {

View File

@@ -9,7 +9,7 @@
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_palette.h"
#include "app/gui/icons.h"
#include "gui/canvas/canvas_modals.h"
#include "app/gui/canvas/canvas_modals.h"
#include "canvas_usage_tracker.h"
#include "imgui/imgui.h"

View File

@@ -7,7 +7,7 @@
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_palette.h"
#include "app/gfx/bpp_format_manager.h"
#include "gui/canvas_utils.h"
#include "app/gui/canvas_utils.h"
#include "imgui/imgui.h"
namespace yaze {

View File

@@ -0,0 +1,49 @@
# ==============================================================================
# Yaze GUI Library
# ==============================================================================
# This library contains all GUI-related functionality:
# - Canvas system
# - ImGui widgets and utilities
# - Input handling
# - Theme management
# - Color utilities
# - Background rendering
#
# Dependencies: yaze_gfx, yaze_util, ImGui, SDL2
# ==============================================================================
add_library(yaze_gui STATIC ${YAZE_GUI_SRC})
target_include_directories(yaze_gui PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/lib
${CMAKE_SOURCE_DIR}/src/lib/imgui
${CMAKE_SOURCE_DIR}/incl
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_gui PUBLIC
yaze_gfx
yaze_util
yaze_common
ImGui
${SDL_TARGETS}
)
set_target_properties(yaze_gui PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
# Platform-specific compile definitions
if(UNIX AND NOT APPLE)
target_compile_definitions(yaze_gui PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_gui PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_gui PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_gui library configured")

View File

@@ -12,7 +12,7 @@
#include <unordered_set>
#include <vector>
#include "imgui.h"
#include "imgui/imgui.h"
class TextEditor {
public:

View File

@@ -5,9 +5,9 @@
#include "app/core/platform/file_dialog.h"
#include "app/gui/theme_manager.h"
#include "app/gui/background_renderer.h"
#include "core/platform/font_loader.h"
#include "gui/color.h"
#include "gui/icons.h"
#include "app/core/platform/font_loader.h"
#include "app/gui/color.h"
#include "app/gui/icons.h"
#include "imgui/imgui.h"
#include "imgui/imgui_internal.h"
#include "util/log.h"

View File

@@ -0,0 +1,45 @@
# ==============================================================================
# Yaze Zelda3 Library
# ==============================================================================
# This library contains all Zelda3-specific game logic:
# - Overworld system (maps, tiles, sprites)
# - Dungeon system (rooms, objects, sprites)
# - Screen modules (title, inventory, dungeon map)
# - Sprite management
# - Music/tracker system
#
# Dependencies: yaze_gfx, yaze_util
# ==============================================================================
add_library(yaze_zelda3 STATIC ${YAZE_APP_ZELDA3_SRC})
target_include_directories(yaze_zelda3 PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/lib
${CMAKE_SOURCE_DIR}/incl
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_zelda3 PUBLIC
yaze_gfx
yaze_util
yaze_common
${ABSL_TARGETS}
)
set_target_properties(yaze_zelda3 PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
# Platform-specific compile definitions
if(UNIX AND NOT APPLE)
target_compile_definitions(yaze_zelda3 PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_zelda3 PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_zelda3 PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_zelda3 library configured")