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

@@ -164,6 +164,7 @@ jobs:
-DCMAKE_C_COMPILER=${{ matrix.cc }} \ -DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \ -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 \ -DCMAKE_POLICY_VERSION_MINIMUM=3.16 \
-DYAZE_USE_MODULAR_BUILD=ON \
-DYAZE_MINIMAL_BUILD=ON \ -DYAZE_MINIMAL_BUILD=ON \
-DYAZE_ENABLE_ROM_TESTS=OFF \ -DYAZE_ENABLE_ROM_TESTS=OFF \
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF \ -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF \
@@ -175,7 +176,7 @@ jobs:
if: runner.os == 'Windows' if: runner.os == 'Windows'
shell: cmd shell: cmd
run: | run: |
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_POLICY_VERSION_MINIMUM=3.16 -DYAZE_MINIMAL_BUILD=ON -DYAZE_ENABLE_ROM_TESTS=OFF -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF -DYAZE_ENABLE_UI_TESTS=OFF -Wno-dev -G "${{ matrix.cmake_generator }}" -A ${{ matrix.cmake_generator_platform }} cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_POLICY_VERSION_MINIMUM=3.16 -DYAZE_USE_MODULAR_BUILD=ON -DYAZE_MINIMAL_BUILD=ON -DYAZE_ENABLE_ROM_TESTS=OFF -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF -DYAZE_ENABLE_UI_TESTS=OFF -Wno-dev -G "${{ matrix.cmake_generator }}" -A ${{ matrix.cmake_generator_platform }}
# Build # Build
- name: Build - name: Build
@@ -353,6 +354,7 @@ jobs:
-DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \ -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
-DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \ -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address" \ -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address" \
-DYAZE_USE_MODULAR_BUILD=ON \
-DYAZE_MINIMAL_BUILD=ON \ -DYAZE_MINIMAL_BUILD=ON \
-DYAZE_ENABLE_ROM_TESTS=OFF \ -DYAZE_ENABLE_ROM_TESTS=OFF \
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF \ -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF \
@@ -397,6 +399,7 @@ jobs:
run: | run: |
cmake -B ${{ github.workspace }}/build \ cmake -B ${{ github.workspace }}/build \
-DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_BUILD_TYPE=Debug \
-DYAZE_USE_MODULAR_BUILD=ON \
-DCMAKE_CXX_FLAGS="--coverage" \ -DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_C_FLAGS="--coverage" \ -DCMAKE_C_FLAGS="--coverage" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage" \ -DCMAKE_EXE_LINKER_FLAGS="--coverage" \

View File

@@ -248,6 +248,7 @@ jobs:
-GNinja \ -GNinja \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 \ -DCMAKE_POLICY_VERSION_MINIMUM=3.16 \
-DYAZE_USE_MODULAR_BUILD=ON \
-DYAZE_BUILD_TESTS=ON \ -DYAZE_BUILD_TESTS=ON \
-DYAZE_BUILD_EMU=OFF \ -DYAZE_BUILD_EMU=OFF \
-DYAZE_BUILD_Z3ED=ON \ -DYAZE_BUILD_Z3ED=ON \
@@ -267,6 +268,7 @@ jobs:
-GNinja \ -GNinja \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 \ -DCMAKE_POLICY_VERSION_MINIMUM=3.16 \
-DYAZE_USE_MODULAR_BUILD=ON \
-DYAZE_BUILD_TESTS=ON \ -DYAZE_BUILD_TESTS=ON \
-DYAZE_BUILD_EMU=OFF \ -DYAZE_BUILD_EMU=OFF \
-DYAZE_BUILD_Z3ED=ON \ -DYAZE_BUILD_Z3ED=ON \
@@ -296,6 +298,7 @@ jobs:
'-A','${{ matrix.cmake_generator_platform }}', '-A','${{ matrix.cmake_generator_platform }}',
'-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}', '-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}',
'-DCMAKE_POLICY_VERSION_MINIMUM=3.16', '-DCMAKE_POLICY_VERSION_MINIMUM=3.16',
'-DYAZE_USE_MODULAR_BUILD=ON',
'-DYAZE_BUILD_TESTS=ON', '-DYAZE_BUILD_TESTS=ON',
'-DYAZE_BUILD_EMU=OFF', '-DYAZE_BUILD_EMU=OFF',
'-DYAZE_BUILD_Z3ED=ON', '-DYAZE_BUILD_Z3ED=ON',

View File

@@ -54,6 +54,7 @@ option(YAZE_ENABLE_ROM_TESTS "Enable tests that require ROM files" OFF)
option(YAZE_ENABLE_EXPERIMENTAL_TESTS "Enable experimental/unstable tests" ON) option(YAZE_ENABLE_EXPERIMENTAL_TESTS "Enable experimental/unstable tests" ON)
option(YAZE_ENABLE_UI_TESTS "Enable ImGui Test Engine UI testing" ON) option(YAZE_ENABLE_UI_TESTS "Enable ImGui Test Engine UI testing" ON)
option(YAZE_MINIMAL_BUILD "Minimal build for CI (disable optional features)" OFF) option(YAZE_MINIMAL_BUILD "Minimal build for CI (disable optional features)" OFF)
option(YAZE_USE_MODULAR_BUILD "Use modularized library build system for faster builds" OFF)
# Optional JSON support (required for Gemini and structured agent responses) # Optional JSON support (required for Gemini and structured agent responses)
option(YAZE_WITH_JSON "Enable JSON support for AI integrations" OFF) option(YAZE_WITH_JSON "Enable JSON support for AI integrations" OFF)

View File

@@ -87,6 +87,32 @@ if(YAZE_BUILD_APP OR YAZE_BUILD_Z3ED)
include(cli/agent.cmake) include(cli/agent.cmake)
endif() endif()
if(YAZE_USE_MODULAR_BUILD)
message(STATUS "Using modular build system")
if(YAZE_BUILD_LIB OR YAZE_BUILD_APP OR YAZE_BUILD_Z3ED)
include(app/gfx/gfx.cmake)
include(app/gui/gui.cmake)
include(app/zelda3/zelda3.cmake)
include(app/core/core.cmake)
include(app/editor/editor.cmake)
include(util/util.cmake)
include(app/gfx/gfx_library.cmake)
include(app/gui/gui_library.cmake)
include(app/zelda3/zelda3_library.cmake)
if(YAZE_BUILD_EMU AND NOT YAZE_WITH_GRPC)
include(app/emu/emu_library.cmake)
endif()
include(app/core/core_library.cmake)
include(app/editor/editor_library.cmake)
endif()
else()
message(STATUS "Using traditional monolithic build system")
endif()
if (YAZE_BUILD_APP) if (YAZE_BUILD_APP)
include(app/app.cmake) include(app/app.cmake)
endif() endif()
@@ -165,28 +191,115 @@ endif()
# Yaze Core Library (for testing and C API) # Yaze Core Library (for testing and C API)
if (YAZE_BUILD_LIB) if (YAZE_BUILD_LIB)
# Create core library for testing (includes editor and zelda3 components needed by tests) # Sources shared by the C API library
set(YAZE_CORE_SOURCES
app/rom.cc
${YAZE_APP_CORE_SRC}
${YAZE_APP_GFX_SRC}
${YAZE_APP_EDITOR_SRC}
${YAZE_APP_ZELDA3_SRC}
${YAZE_APP_EMU_SRC}
${YAZE_GUI_SRC}
${YAZE_UTIL_SRC}
# cli/service/gui_automation_client.cc # Moved to yaze_c
cli/service/testing/test_workflow_generator.cc
)
# Create full library for C API
set(YAZE_C_SOURCES set(YAZE_C_SOURCES
./yaze.cc ./yaze.cc
cli/service/gui/gui_automation_client.cc cli/service/gui/gui_automation_client.cc
) )
# Create the core library (static for testing) if(YAZE_USE_MODULAR_BUILD)
add_library(yaze_core STATIC ${YAZE_CORE_SOURCES}) # Aggregate modular libraries into an interface target for backward compatibility
if(NOT TARGET yaze_core)
add_library(yaze_core INTERFACE)
endif()
target_include_directories(
yaze_core INTERFACE
${CMAKE_SOURCE_DIR}/src/lib/
${CMAKE_SOURCE_DIR}/src/app/
${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/
${CMAKE_SOURCE_DIR}/src/
${CMAKE_SOURCE_DIR}/src/lib/imgui
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
)
target_link_libraries(
yaze_core INTERFACE
yaze_util
yaze_gfx
yaze_gui
yaze_zelda3
yaze_core_lib
yaze_editor
ImGui
)
if(TARGET yaze_agent)
target_link_libraries(yaze_core INTERFACE yaze_agent)
endif()
if(YAZE_BUILD_EMU AND NOT YAZE_WITH_GRPC AND TARGET yaze_emulator)
target_link_libraries(yaze_core INTERFACE yaze_emulator)
endif()
if(YAZE_ENABLE_UI_TESTS AND TARGET ImGuiTestEngine)
target_link_libraries(yaze_core INTERFACE ImGuiTestEngine)
endif()
if(YAZE_WITH_GRPC)
target_link_libraries(yaze_core INTERFACE
grpc++
grpc++_reflection
libprotobuf)
endif()
else()
# Create core library for testing (includes editor and zelda3 components needed by tests)
set(YAZE_CORE_SOURCES
app/rom.cc
${YAZE_APP_CORE_SRC}
${YAZE_APP_GFX_SRC}
${YAZE_APP_EDITOR_SRC}
${YAZE_APP_ZELDA3_SRC}
${YAZE_APP_EMU_SRC}
${YAZE_GUI_SRC}
${YAZE_UTIL_SRC}
# cli/service/gui_automation_client.cc # Moved to yaze_c
cli/service/testing/test_workflow_generator.cc
)
add_library(yaze_core STATIC ${YAZE_CORE_SOURCES})
target_include_directories(
yaze_core PUBLIC
${CMAKE_SOURCE_DIR}/src/lib/
${CMAKE_SOURCE_DIR}/src/app/
${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/
${CMAKE_SOURCE_DIR}/src/
${CMAKE_SOURCE_DIR}/src/lib/imgui
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(
yaze_core PUBLIC
asar-static
yaze_agent
${ABSL_TARGETS}
${SDL_TARGETS}
${CMAKE_DL_LIBS}
ImGui
)
if(YAZE_WITH_GRPC)
target_add_protobuf(yaze_core
${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto)
target_link_libraries(yaze_core PRIVATE
grpc++
grpc++_reflection
libprotobuf)
endif()
endif()
# Create the full C API library (static for CI, shared for release) # Create the full C API library (static for CI, shared for release)
if(YAZE_MINIMAL_BUILD) if(YAZE_MINIMAL_BUILD)
@@ -195,44 +308,6 @@ if (YAZE_BUILD_LIB)
add_library(yaze_c SHARED ${YAZE_C_SOURCES}) add_library(yaze_c SHARED ${YAZE_C_SOURCES})
endif() endif()
# Configure core library (for testing)
target_include_directories(
yaze_core PUBLIC
${CMAKE_SOURCE_DIR}/src/lib/
${CMAKE_SOURCE_DIR}/src/app/
${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/
${CMAKE_SOURCE_DIR}/src/
${CMAKE_SOURCE_DIR}/src/lib/imgui
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(
yaze_core PUBLIC
asar-static
yaze_agent
${ABSL_TARGETS}
${SDL_TARGETS}
${CMAKE_DL_LIBS}
ImGui
)
if(YAZE_WITH_GRPC)
target_add_protobuf(yaze_core
${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto)
target_link_libraries(yaze_core PRIVATE
grpc++
grpc++_reflection
libprotobuf)
endif()
# Configure full C API library
target_include_directories( target_include_directories(
yaze_c PUBLIC yaze_c PUBLIC
${CMAKE_SOURCE_DIR}/src/lib/ ${CMAKE_SOURCE_DIR}/src/lib/
@@ -247,17 +322,39 @@ if (YAZE_BUILD_LIB)
${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}
) )
# Conditionally add PNG include dirs if available
if(PNG_FOUND) if(PNG_FOUND)
target_include_directories(yaze_c PUBLIC ${PNG_INCLUDE_DIRS}) target_include_directories(yaze_c PUBLIC ${PNG_INCLUDE_DIRS})
target_include_directories(yaze_core PUBLIC ${PNG_INCLUDE_DIRS}) if(NOT YAZE_USE_MODULAR_BUILD)
target_include_directories(yaze_core PUBLIC ${PNG_INCLUDE_DIRS})
endif()
endif() endif()
target_link_libraries( if(YAZE_USE_MODULAR_BUILD)
yaze_c PRIVATE target_link_libraries(
yaze_core yaze_c PRIVATE
ImGui yaze_util
) yaze_gfx
yaze_gui
yaze_zelda3
yaze_core_lib
yaze_editor
ImGui
)
if(TARGET yaze_agent)
target_link_libraries(yaze_c PRIVATE yaze_agent)
endif()
if(YAZE_BUILD_EMU AND NOT YAZE_WITH_GRPC AND TARGET yaze_emulator)
target_link_libraries(yaze_c PRIVATE yaze_emulator)
endif()
else()
target_link_libraries(
yaze_c PRIVATE
yaze_core
ImGui
)
endif()
if(YAZE_WITH_GRPC) if(YAZE_WITH_GRPC)
target_add_protobuf(yaze_c target_add_protobuf(yaze_c
@@ -269,7 +366,6 @@ if (YAZE_BUILD_LIB)
libprotobuf) libprotobuf)
endif() endif()
# Conditionally link ImGui Test Engine and set definitions
if(YAZE_ENABLE_UI_TESTS AND TARGET ImGuiTestEngine) if(YAZE_ENABLE_UI_TESTS AND TARGET ImGuiTestEngine)
target_link_libraries(yaze_c PRIVATE ImGuiTestEngine) target_link_libraries(yaze_c PRIVATE ImGuiTestEngine)
target_compile_definitions(yaze_c PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=1) target_compile_definitions(yaze_c PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=1)
@@ -277,10 +373,11 @@ if (YAZE_BUILD_LIB)
target_compile_definitions(yaze_c PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=0) target_compile_definitions(yaze_c PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=0)
endif() endif()
# Conditionally link PNG if available
if(PNG_FOUND) if(PNG_FOUND)
target_link_libraries(yaze_c PRIVATE ${PNG_LIBRARIES}) target_link_libraries(yaze_c PRIVATE ${PNG_LIBRARIES})
target_link_libraries(yaze_core PRIVATE ${PNG_LIBRARIES}) if(NOT YAZE_USE_MODULAR_BUILD)
target_link_libraries(yaze_core PRIVATE ${PNG_LIBRARIES})
endif()
endif() endif()
if (YAZE_INSTALL_LIB) if (YAZE_INSTALL_LIB)

View File

@@ -98,7 +98,26 @@ else()
target_compile_definitions(yaze PRIVATE YAZE_ENABLE_NFD=0) target_compile_definitions(yaze PRIVATE YAZE_ENABLE_NFD=0)
endif() 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 # Enable policy framework in main yaze target
target_compile_definitions(yaze PRIVATE YAZE_ENABLE_POLICY_FRAMEWORK=1) 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) ${CMAKE_SOURCE_DIR}/third_party/json/include)
target_compile_definitions(yaze PRIVATE YAZE_WITH_JSON) target_compile_definitions(yaze PRIVATE YAZE_WITH_JSON)
# Generate C++ code from .proto using the helper function from cmake/grpc.cmake if(NOT YAZE_USE_MODULAR_BUILD)
target_add_protobuf(yaze # Generate C++ code from .proto using the helper function from cmake/grpc.cmake
${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto) target_add_protobuf(yaze
${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto)
# Add service implementation sources # Add service implementation sources
target_sources(yaze PRIVATE 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.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.h ${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.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.h ${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.cc
${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.h ${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.cc
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.h ${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.cc
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.h) ${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.h)
endif()
# Link gRPC libraries # Link gRPC libraries
target_link_libraries(yaze PRIVATE 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/modules/asset_browser.h"
#include "app/gui/style.h" #include "app/gui/style.h"
#include "app/rom.h" #include "app/rom.h"
#include "gfx/performance_profiler.h" #include "app/gfx/performance_profiler.h"
#include "imgui/imgui.h" #include "imgui/imgui.h"
#include "imgui/misc/cpp/imgui_stdlib.h" #include "imgui/misc/cpp/imgui_stdlib.h"
#include "imgui_memory_editor.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 #ifndef YAZE_GUI_CANVAS_H
#define YAZE_GUI_CANVAS_H #define YAZE_GUI_CANVAS_H
#include "gfx/tilemap.h" #include "app/gfx/tilemap.h"
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#include <cstdint> #include <cstdint>

View File

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

View File

@@ -9,7 +9,7 @@
#include "app/gfx/bitmap.h" #include "app/gfx/bitmap.h"
#include "app/gfx/snes_palette.h" #include "app/gfx/snes_palette.h"
#include "app/gui/icons.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 "canvas_usage_tracker.h"
#include "imgui/imgui.h" #include "imgui/imgui.h"

View File

@@ -7,7 +7,7 @@
#include "app/gfx/bitmap.h" #include "app/gfx/bitmap.h"
#include "app/gfx/snes_palette.h" #include "app/gfx/snes_palette.h"
#include "app/gfx/bpp_format_manager.h" #include "app/gfx/bpp_format_manager.h"
#include "gui/canvas_utils.h" #include "app/gui/canvas_utils.h"
#include "imgui/imgui.h" #include "imgui/imgui.h"
namespace yaze { 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 <unordered_set>
#include <vector> #include <vector>
#include "imgui.h" #include "imgui/imgui.h"
class TextEditor { class TextEditor {
public: public:

View File

@@ -5,9 +5,9 @@
#include "app/core/platform/file_dialog.h" #include "app/core/platform/file_dialog.h"
#include "app/gui/theme_manager.h" #include "app/gui/theme_manager.h"
#include "app/gui/background_renderer.h" #include "app/gui/background_renderer.h"
#include "core/platform/font_loader.h" #include "app/core/platform/font_loader.h"
#include "gui/color.h" #include "app/gui/color.h"
#include "gui/icons.h" #include "app/gui/icons.h"
#include "imgui/imgui.h" #include "imgui/imgui.h"
#include "imgui/imgui_internal.h" #include "imgui/imgui_internal.h"
#include "util/log.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")

View File

@@ -1,3 +1,69 @@
include(FetchContent)
function(_yaze_ensure_yaml_cpp _out_target)
if(TARGET yaml-cpp::yaml-cpp)
set(${_out_target} yaml-cpp::yaml-cpp PARENT_SCOPE)
return()
endif()
if(TARGET yaml-cpp)
set(${_out_target} yaml-cpp PARENT_SCOPE)
return()
endif()
find_package(yaml-cpp CONFIG QUIET)
if(TARGET yaml-cpp::yaml-cpp)
set(${_out_target} yaml-cpp::yaml-cpp PARENT_SCOPE)
return()
elseif(TARGET yaml-cpp)
set(${_out_target} yaml-cpp PARENT_SCOPE)
return()
endif()
message(STATUS "yaml-cpp not found via package config, fetching from source")
FetchContent_Declare(yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG 0.8.0
)
FetchContent_GetProperties(yaml-cpp)
if(NOT yaml-cpp_POPULATED)
FetchContent_Populate(yaml-cpp)
set(_yaml_cpp_cmakelists "${yaml-cpp_SOURCE_DIR}/CMakeLists.txt")
if(EXISTS "${_yaml_cpp_cmakelists}")
file(READ "${_yaml_cpp_cmakelists}" _yaml_cpp_cmake_contents)
if(_yaml_cpp_cmake_contents MATCHES "cmake_minimum_required\\(VERSION 3\\.4\\)")
string(REPLACE "cmake_minimum_required(VERSION 3.4)"
"cmake_minimum_required(VERSION 3.5)"
_yaml_cpp_cmake_contents "${_yaml_cpp_cmake_contents}")
file(WRITE "${_yaml_cpp_cmakelists}" "${_yaml_cpp_cmake_contents}")
endif()
endif()
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "Disable yaml-cpp tests" FORCE)
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "Disable yaml-cpp contrib" FORCE)
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Disable yaml-cpp tools" FORCE)
set(YAML_CPP_INSTALL OFF CACHE BOOL "Disable yaml-cpp install" FORCE)
set(YAML_CPP_FORMAT_SOURCE OFF CACHE BOOL "Disable yaml-cpp format target" FORCE)
add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR} EXCLUDE_FROM_ALL)
if(NOT TARGET yaml-cpp)
message(FATAL_ERROR "yaml-cpp target was not created after fetching")
endif()
# Ensure the fetched target exposes its public headers
target_include_directories(yaml-cpp PUBLIC ${yaml-cpp_SOURCE_DIR}/include)
endif()
set(${_out_target} yaml-cpp PARENT_SCOPE)
endfunction()
_yaze_ensure_yaml_cpp(YAZE_YAML_CPP_TARGET)
set(YAZE_AGENT_SOURCES set(YAZE_AGENT_SOURCES
cli/handlers/agent/tool_commands.cc cli/handlers/agent/tool_commands.cc
cli/service/agent/conversational_agent_service.cc cli/service/agent/conversational_agent_service.cc
@@ -20,13 +86,14 @@ endif()
add_library(yaze_agent STATIC ${YAZE_AGENT_SOURCES}) add_library(yaze_agent STATIC ${YAZE_AGENT_SOURCES})
target_link_libraries(yaze_agent set(_yaze_agent_link_targets
PUBLIC yaze_common
yaze_common ${ABSL_TARGETS}
${ABSL_TARGETS} ${YAZE_YAML_CPP_TARGET}
yaml-cpp
) )
target_link_libraries(yaze_agent PUBLIC ${_yaze_agent_link_targets})
target_include_directories(yaze_agent target_include_directories(yaze_agent
PUBLIC PUBLIC
${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src
@@ -36,6 +103,13 @@ target_include_directories(yaze_agent
${CMAKE_SOURCE_DIR}/src/lib ${CMAKE_SOURCE_DIR}/src/lib
) )
if(YAZE_YAML_CPP_TARGET)
get_target_property(_yaze_yaml_include_dirs ${YAZE_YAML_CPP_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
if(_yaze_yaml_include_dirs)
target_include_directories(yaze_agent PUBLIC ${_yaze_yaml_include_dirs})
endif()
endif()
if(SDL2_INCLUDE_DIR) if(SDL2_INCLUDE_DIR)
target_include_directories(yaze_agent PUBLIC ${SDL2_INCLUDE_DIR}) target_include_directories(yaze_agent PUBLIC ${SDL2_INCLUDE_DIR})
endif() endif()

View File

@@ -118,15 +118,31 @@ target_include_directories(
${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}
) )
target_link_libraries( if(YAZE_USE_MODULAR_BUILD)
z3ed PRIVATE target_link_libraries(
yaze_core z3ed PRIVATE
ftxui::component yaze_util
ftxui::screen yaze_gfx
ftxui::dom yaze_zelda3
absl::flags yaze_core_lib
absl::flags_parse yaze_agent
) ftxui::component
ftxui::screen
ftxui::dom
absl::flags
absl::flags_parse
)
else()
target_link_libraries(
z3ed PRIVATE
yaze_core
ftxui::component
ftxui::screen
ftxui::dom
absl::flags
absl::flags_parse
)
endif()
# ============================================================================ # ============================================================================
# Optional gRPC Support for CLI Agent Test Command # Optional gRPC Support for CLI Agent Test Command

47
src/util/util.cmake Normal file
View File

@@ -0,0 +1,47 @@
# ==============================================================================
# Yaze Utility Library
# ==============================================================================
# This library contains low-level utilities used throughout the codebase:
# - BPS patch handling
# - Command-line flag parsing
# - Hexadecimal utilities
#
# This library has no dependencies on GUI, graphics, or game-specific code,
# making it the foundation of the dependency hierarchy.
# ==============================================================================
set(YAZE_UTIL_SRC
util/bps.cc
util/flag.cc
util/hex.cc
)
add_library(yaze_util STATIC ${YAZE_UTIL_SRC})
target_include_directories(yaze_util PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/incl
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_util PUBLIC
yaze_common
${ABSL_TARGETS}
)
set_target_properties(yaze_util 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_util PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_util PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_util PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_util library configured")

View File

@@ -253,7 +253,26 @@ endif()
# Link core library for essential functionality (BPS, ASAR, etc.) # Link core library for essential functionality (BPS, ASAR, etc.)
if(YAZE_BUILD_LIB) if(YAZE_BUILD_LIB)
target_link_libraries(yaze_test yaze_core) if(YAZE_USE_MODULAR_BUILD)
target_link_libraries(yaze_test
yaze_util
yaze_gfx
yaze_gui
yaze_zelda3
yaze_core_lib
yaze_editor
)
if(TARGET yaze_agent)
target_link_libraries(yaze_test yaze_agent)
endif()
if(YAZE_BUILD_EMU AND NOT YAZE_WITH_GRPC AND TARGET yaze_emulator)
target_link_libraries(yaze_test yaze_emulator)
endif()
else()
target_link_libraries(yaze_test yaze_core)
endif()
endif() endif()
# Conditionally link ImGuiTestEngine only when UI tests are enabled # Conditionally link ImGuiTestEngine only when UI tests are enabled