diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c21ea812..219d87a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,25 +87,31 @@ jobs: print("Patched cmake_install.cmake to handle missing dependency install scripts") EOF + - name: Clean old packages before CPack + shell: bash + run: | + echo "Cleaning old package files to ensure fresh generation" + rm -f build/*.deb build/*.tar.gz build/*.dmg build/*.zip build/*.exe build/packages/* + - name: Package artifacts (Linux) if: matrix.platform == 'linux' run: | cd build cpack -G DEB -G TGZ - echo "=== Contents of build directory ===" - ls -la + echo "=== Contents of packages directory ===" + ls -la packages/ 2>/dev/null || echo "No packages directory" echo "=== Package files created ===" - ls -la *.deb *.tar.gz 2>/dev/null || echo "No packages found in build/" + ls -la packages/*.deb packages/*.tar.gz 2>/dev/null || echo "No packages found" - name: Package artifacts (macOS) if: matrix.platform == 'macos' run: | cd build cpack -G DragNDrop - echo "=== Contents of build directory ===" - ls -la + echo "=== Contents of packages directory ===" + ls -la packages/ 2>/dev/null || echo "No packages directory" echo "=== Package files created ===" - ls -la *.dmg 2>/dev/null || echo "No packages found in build/" + ls -la packages/*.dmg 2>/dev/null || echo "No packages found" - name: Create notarized bundle (macOS) if: matrix.platform == 'macos' @@ -114,7 +120,8 @@ jobs: chmod +x ./scripts/create-macos-bundle.sh ./scripts/create-macos-bundle.sh ${{ env.VERSION }} yaze-${{ env.VERSION }}-bundle || true if [ -f "yaze-${{ env.VERSION }}-bundle.dmg" ]; then - mv yaze-${{ env.VERSION }}-bundle.dmg build/ + mkdir -p build/packages + mv yaze-${{ env.VERSION }}-bundle.dmg build/packages/ fi - name: Patch cmake_install.cmake (Windows) @@ -135,21 +142,21 @@ jobs: run: | cd build cpack -G NSIS -G ZIP - Write-Host "=== Contents of build directory ===" - Get-ChildItem + Write-Host "=== Contents of packages directory ===" + Get-ChildItem packages -ErrorAction SilentlyContinue Write-Host "=== Package files created ===" - Get-ChildItem *.exe, *.zip -ErrorAction SilentlyContinue + Get-ChildItem packages/*.exe, packages/*.zip -ErrorAction SilentlyContinue - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: yaze-${{ matrix.platform }}-${{ env.VERSION }} path: | - build/*.deb - build/*.tar.gz - build/*.dmg - build/*.exe - build/*.zip + build/packages/*.deb + build/packages/*.tar.gz + build/packages/*.dmg + build/packages/*.exe + build/packages/*.zip if-no-files-found: warn retention-days: 30 diff --git a/CMakeLists.txt b/CMakeLists.txt index ba153e2b..aaf48742 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,11 +15,11 @@ cmake_policy(SET CMP0077 NEW) # Enable Objective-C only on macOS where it's actually used if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - project(yaze VERSION 0.3.3 + project(yaze VERSION 0.3.8 DESCRIPTION "Yet Another Zelda3 Editor" LANGUAGES CXX C OBJC OBJCXX) else() - project(yaze VERSION 0.3.3 + project(yaze VERSION 0.3.8 DESCRIPTION "Yet Another Zelda3 Editor" LANGUAGES CXX C) endif() @@ -35,10 +35,12 @@ if(CCACHE_FOUND) set(CMAKE_C_COMPILER_LAUNCHER ccache) endif() -# Set project metadata -set(YAZE_VERSION_MAJOR 0) -set(YAZE_VERSION_MINOR 3) -set(YAZE_VERSION_PATCH 3) +# Version is defined in project() above - use those variables +# CMake automatically sets: yaze_VERSION, yaze_VERSION_MAJOR, yaze_VERSION_MINOR, yaze_VERSION_PATCH +# These YAZE_VERSION_* aliases are for compatibility with existing code +set(YAZE_VERSION_MAJOR ${yaze_VERSION_MAJOR}) +set(YAZE_VERSION_MINOR ${yaze_VERSION_MINOR}) +set(YAZE_VERSION_PATCH ${yaze_VERSION_PATCH}) # Suppress deprecation warnings from submodules set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Suppress deprecation warnings") diff --git a/cmake/packaging.cmake b/cmake/packaging.cmake index fbe62e0c..9408d704 100644 --- a/cmake/packaging.cmake +++ b/cmake/packaging.cmake @@ -141,23 +141,42 @@ set(CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation") set(CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "User and developer documentation") set(CPACK_COMPONENT_DOCUMENTATION_REQUIRED FALSE) +# Platform-specific install paths +# The asset paths must match what platform_paths.cc FindAsset() searches for +if(WIN32) + # Windows: flat structure (exe and assets/ at same level) + set(YAZE_INSTALL_BINDIR ".") + set(YAZE_INSTALL_DATADIR ".") + set(YAZE_INSTALL_DOCDIR ".") +elseif(APPLE) + # macOS: flat structure for DMG (app bundle handles its own resources) + set(YAZE_INSTALL_BINDIR ".") + set(YAZE_INSTALL_DATADIR ".") + set(YAZE_INSTALL_DOCDIR ".") +else() + # Linux: FHS structure - assets at share/yaze/assets (matches FindAsset search) + set(YAZE_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR}) + set(YAZE_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/yaze") + set(YAZE_INSTALL_DOCDIR "${CMAKE_INSTALL_DOCDIR}") +endif() + # Installation components if(APPLE) install(TARGETS yaze - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${YAZE_INSTALL_BINDIR} + BUNDLE DESTINATION ${YAZE_INSTALL_BINDIR} COMPONENT applications ) else() install(TARGETS yaze - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${YAZE_INSTALL_BINDIR} COMPONENT applications ) endif() # Install assets install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets/ - DESTINATION ${CMAKE_INSTALL_DATADIR}/yaze/assets + DESTINATION ${YAZE_INSTALL_DATADIR}/assets COMPONENT applications PATTERN "*.png" PATTERN "*.ttf" @@ -165,15 +184,15 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets/ ) # Install documentation -install(FILES +install(FILES ${CMAKE_SOURCE_DIR}/README.md ${CMAKE_SOURCE_DIR}/LICENSE - DESTINATION ${CMAKE_INSTALL_DOCDIR} + DESTINATION ${YAZE_INSTALL_DOCDIR} COMPONENT documentation ) install(DIRECTORY ${CMAKE_SOURCE_DIR}/docs/ - DESTINATION ${CMAKE_INSTALL_DOCDIR} + DESTINATION ${YAZE_INSTALL_DOCDIR} COMPONENT documentation PATTERN "*.md" PATTERN "*.html" diff --git a/cmake/packaging/cpack.cmake b/cmake/packaging/cpack.cmake index bdf5975f..938a2c1e 100644 --- a/cmake/packaging/cpack.cmake +++ b/cmake/packaging/cpack.cmake @@ -1,7 +1,7 @@ # CPack Configuration # Cross-platform packaging using CPack - -include(CPack) +# NOTE: include(CPack) MUST be called at the END of this file, +# after all CPACK_ variables and install() rules are defined. # Set package information set(CPACK_PACKAGE_NAME "yaze") @@ -36,23 +36,42 @@ set(CPACK_COMPONENT_YAZE_DESCRIPTION "Main YAZE application and libraries") # Install rules - these define what CPack packages include(GNUInstallDirs) +# Platform-specific install paths +# The asset paths must match what platform_paths.cc FindAsset() searches for +if(WIN32) + # Windows: flat structure (exe and assets/ at same level) + set(YAZE_INSTALL_BINDIR ".") + set(YAZE_INSTALL_DATADIR ".") + set(YAZE_INSTALL_DOCDIR ".") +elseif(APPLE) + # macOS: flat structure for DMG (app bundle handles its own resources) + set(YAZE_INSTALL_BINDIR ".") + set(YAZE_INSTALL_DATADIR ".") + set(YAZE_INSTALL_DOCDIR ".") +else() + # Linux: FHS structure - assets at share/yaze/assets (matches FindAsset search) + set(YAZE_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR}) + set(YAZE_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/yaze") + set(YAZE_INSTALL_DOCDIR "${CMAKE_INSTALL_DOCDIR}") +endif() + # Install main executable if(APPLE) install(TARGETS yaze - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${YAZE_INSTALL_BINDIR} BUNDLE DESTINATION . COMPONENT yaze ) else() install(TARGETS yaze - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${YAZE_INSTALL_BINDIR} COMPONENT yaze ) endif() # Install assets install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets/ - DESTINATION ${CMAKE_INSTALL_DATADIR}/yaze/assets + DESTINATION ${YAZE_INSTALL_DATADIR}/assets COMPONENT yaze PATTERN "*.png" PATTERN "*.ttf" @@ -63,7 +82,11 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets/ install(FILES ${CMAKE_SOURCE_DIR}/README.md ${CMAKE_SOURCE_DIR}/LICENSE - DESTINATION ${CMAKE_INSTALL_DOCDIR} + DESTINATION ${YAZE_INSTALL_DOCDIR} COMPONENT yaze ) +# IMPORTANT: include(CPack) must be called LAST, after all CPACK_ variables +# and install() rules are defined. This is a CPack requirement. +include(CPack) + diff --git a/incl/yaze.h b/incl/yaze.h index f5065234..f6cc7b21 100644 --- a/incl/yaze.h +++ b/incl/yaze.h @@ -9,7 +9,7 @@ * The Legend of Zelda: A Link to the Past. This API allows external * applications to interact with YAZE's functionality. * - * @version 0.3.3 + * @version 0.3.8 * @author YAZE Team */ @@ -23,16 +23,26 @@ extern "C" { #include "zelda.h" -/** +/** * @defgroup version Version Information * @{ + * + * Version information is generated from CMakeLists.txt project() version. + * When building with CMake, include yaze_config.h (from build directory) for: + * - YAZE_VERSION_MAJOR + * - YAZE_VERSION_MINOR + * - YAZE_VERSION_PATCH + * - YAZE_VERSION_STRING (e.g., "0.3.8") + * - YAZE_VERSION_NUMBER (e.g., 308) + * + * Single source of truth: project(yaze VERSION X.Y.Z) in CMakeLists.txt */ -/** Combined version as a string */ -#define YAZE_VERSION_STRING "0.3.3" - -/** Combined version as a number (major * 10000 + minor * 100 + patch) */ -#define YAZE_VERSION_NUMBER 303 +#ifndef YAZE_VERSION_STRING +/* Fallback if yaze_config.h not included - will be overridden by build */ +#define YAZE_VERSION_STRING "0.3.8" +#define YAZE_VERSION_NUMBER 308 +#endif /** @} */ diff --git a/src/app/app.cmake b/src/app/app.cmake index d43fc03e..5a70814a 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -18,8 +18,17 @@ endif() # Yaze Application Executable # ============================================================================== +# controller.cc is built here (not in yaze_app_core_lib) because it uses +# EditorManager, DockSpaceRenderer, and WidgetIdRegistry from yaze_editor/yaze_gui. +# Including it in yaze_app_core_lib would create a dependency cycle: +# yaze_agent -> yaze_app_core_lib -> yaze_editor -> yaze_agent +set(YAZE_APP_EXECUTABLE_SRC + app/main.cc + app/controller.cc +) + if (APPLE) - add_executable(yaze MACOSX_BUNDLE app/main.cc ${YAZE_RESOURCE_FILES}) + add_executable(yaze MACOSX_BUNDLE ${YAZE_APP_EXECUTABLE_SRC} ${YAZE_RESOURCE_FILES}) set(ICON_FILE "${CMAKE_SOURCE_DIR}/assets/yaze.icns") target_sources(yaze PRIVATE ${ICON_FILE}) @@ -34,7 +43,7 @@ if (APPLE) MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" ) else() - add_executable(yaze app/main.cc) + add_executable(yaze ${YAZE_APP_EXECUTABLE_SRC}) if(WIN32 OR UNIX) target_sources(yaze PRIVATE ${YAZE_RESOURCE_FILES}) endif() diff --git a/src/app/app_core.cmake b/src/app/app_core.cmake index fda5828f..d0eb37ae 100644 --- a/src/app/app_core.cmake +++ b/src/app/app_core.cmake @@ -13,7 +13,9 @@ set( YAZE_APP_CORE_SRC app/rom.cc - app/controller.cc + # Note: controller.cc is built directly into the yaze executable (not this library) + # because it depends on yaze_editor and yaze_gui, which would create a cycle: + # yaze_agent -> yaze_app_core_lib -> yaze_editor -> yaze_agent app/platform/window.cc ) @@ -86,10 +88,11 @@ target_link_libraries(yaze_app_core_lib PUBLIC yaze_core_lib # Foundational core library with project management yaze_util yaze_gfx + yaze_gui # Safe to include - yaze_gui doesn't link to yaze_agent yaze_zelda3 yaze_common - # Note: yaze_editor and yaze_gui are linked at executable level to avoid - # dependency cycle: yaze_agent -> yaze_app_core_lib -> yaze_editor -> yaze_agent + # Note: yaze_editor is linked at executable level to avoid dependency cycle: + # yaze_agent -> yaze_app_core_lib -> yaze_editor -> yaze_agent ImGui ${ABSL_TARGETS} ${YAZE_SDL2_TARGETS} diff --git a/src/app/emu/emu.cmake b/src/app/emu/emu.cmake index 43129dd1..69c6ff8d 100644 --- a/src/app/emu/emu.cmake +++ b/src/app/emu/emu.cmake @@ -5,7 +5,14 @@ if(YAZE_BUILD_EMU AND NOT YAZE_MINIMAL_BUILD) if(APPLE) - add_executable(yaze_emu MACOSX_BUNDLE app/emu/emu.cc app/platform/app_delegate.mm) + # Note: controller.cc is included here (not via library) because it depends on + # yaze_editor and yaze_gui. Including it in yaze_app_core_lib would create a cycle: + # yaze_agent -> yaze_app_core_lib -> yaze_editor -> yaze_agent + add_executable(yaze_emu MACOSX_BUNDLE + app/emu/emu.cc + app/platform/app_delegate.mm + app/controller.cc + ) target_link_libraries(yaze_emu PUBLIC "-framework Cocoa") else() add_executable(yaze_emu app/emu/emu.cc) diff --git a/src/util/platform_paths.cc b/src/util/platform_paths.cc index 156a7b8d..f71dd449 100644 --- a/src/util/platform_paths.cc +++ b/src/util/platform_paths.cc @@ -254,6 +254,17 @@ absl::StatusOr PlatformPaths::FindAsset( // Also check parent (for build/bin/yaze case) search_paths.push_back(cached_exe_dir.parent_path() / "assets" / relative_path); +#ifdef __APPLE__ + // macOS app bundle: exe is at yaze.app/Contents/MacOS/yaze + // Assets may be at yaze.app/Contents/Resources/assets/ (inside bundle) + // or at ../../../assets/ (same level as .app bundle in DMG) + auto contents_dir = cached_exe_dir.parent_path(); // Contents/ + auto bundle_dir = contents_dir.parent_path(); // yaze.app/ + auto bundle_parent = bundle_dir.parent_path(); // DMG root + search_paths.push_back(contents_dir / "Resources" / "assets" / + relative_path); + search_paths.push_back(bundle_parent / "assets" / relative_path); +#endif } catch (...) { // Skip if path construction fails } diff --git a/src/yaze_config.h.in b/src/yaze_config.h.in index 55c0bd61..073aa048 100644 --- a/src/yaze_config.h.in +++ b/src/yaze_config.h.in @@ -1,8 +1,17 @@ -// yaze config file +// yaze config file - auto-generated from CMakeLists.txt project() version +// Single source of truth for version: project(yaze VERSION X.Y.Z) in CMakeLists.txt + #define YAZE_VERSION_MAJOR @yaze_VERSION_MAJOR@ #define YAZE_VERSION_MINOR @yaze_VERSION_MINOR@ #define YAZE_VERSION_PATCH @yaze_VERSION_PATCH@ +// Combined version as a string (e.g., "0.3.7") +#define YAZE_VERSION_STRING "@yaze_VERSION_MAJOR@.@yaze_VERSION_MINOR@.@yaze_VERSION_PATCH@" + +// Combined version as a number (major * 10000 + minor * 100 + patch) +// e.g., 0.3.7 = 307 +#define YAZE_VERSION_NUMBER (@yaze_VERSION_MAJOR@ * 10000 + @yaze_VERSION_MINOR@ * 100 + @yaze_VERSION_PATCH@) + #ifdef __cplusplus #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS