Update CMake configuration and CI/CD workflows

- Upgraded CMake minimum version requirement to 3.16 and updated project version to 0.3.0.
- Introduced new CMake presets for build configurations, including default, debug, and release options.
- Added CI/CD workflows for continuous integration and release management, enhancing automated testing and deployment processes.
- Integrated Asar assembler support with new wrapper classes and CLI commands for patching ROMs.
- Implemented comprehensive tests for Asar integration, ensuring robust functionality and error handling.
- Enhanced packaging configuration for cross-platform support, including Windows, macOS, and Linux.
- Updated documentation and added test assets for improved clarity and usability.
This commit is contained in:
scawful
2025-09-25 08:59:59 -04:00
parent a01200dd29
commit 6bdcfe95ec
37 changed files with 4406 additions and 135 deletions

View File

@@ -1,39 +1,94 @@
# Asar Assembler for 65816 SNES Assembly
add_subdirectory(src/lib/asar/src)
# Modern Asar 65816 Assembler Integration
# Improved cross-platform support for macOS, Linux, and Windows
set(ASAR_GEN_EXE OFF)
set(ASAR_GEN_DLL ON)
set(ASAR_GEN_LIB ON)
set(ASAR_GEN_EXE_TEST OFF)
set(ASAR_GEN_DLL_TEST OFF)
set(ASAR_STATIC_SRC_DIR "${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar")
# Configure Asar build options
set(ASAR_GEN_EXE OFF CACHE BOOL "Build Asar standalone executable")
set(ASAR_GEN_DLL ON CACHE BOOL "Build Asar shared library")
set(ASAR_GEN_LIB ON CACHE BOOL "Build Asar static library")
set(ASAR_GEN_EXE_TEST OFF CACHE BOOL "Build Asar executable tests")
set(ASAR_GEN_DLL_TEST OFF CACHE BOOL "Build Asar DLL tests")
get_target_property(ASAR_INCLUDE_DIR asar-static INCLUDE_DIRECTORIES)
list(APPEND ASAR_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/src/lib/asar/src")
target_include_directories(asar-static PRIVATE ${ASAR_INCLUDE_DIR})
# Set Asar source directory
set(ASAR_SRC_DIR "${CMAKE_SOURCE_DIR}/src/lib/asar/src")
set(ASAR_STATIC_SRC
"${ASAR_STATIC_SRC_DIR}/interface-lib.cpp"
"${ASAR_STATIC_SRC_DIR}/addr2line.cpp"
"${ASAR_STATIC_SRC_DIR}/arch-65816.cpp"
"${ASAR_STATIC_SRC_DIR}/arch-spc700.cpp"
"${ASAR_STATIC_SRC_DIR}/arch-superfx.cpp"
"${ASAR_STATIC_SRC_DIR}/assembleblock.cpp"
"${ASAR_STATIC_SRC_DIR}/crc32.cpp"
"${ASAR_STATIC_SRC_DIR}/libcon.cpp"
"${ASAR_STATIC_SRC_DIR}/libsmw.cpp"
"${ASAR_STATIC_SRC_DIR}/libstr.cpp"
"${ASAR_STATIC_SRC_DIR}/macro.cpp"
"${ASAR_STATIC_SRC_DIR}/main.cpp"
"${ASAR_STATIC_SRC_DIR}/asar_math.cpp"
"${ASAR_STATIC_SRC_DIR}/virtualfile.cpp"
"${ASAR_STATIC_SRC_DIR}/warnings.cpp"
"${ASAR_STATIC_SRC_DIR}/errors.cpp"
"${ASAR_STATIC_SRC_DIR}/platform/file-helpers.cpp"
)
# Add Asar as subdirectory
add_subdirectory(${ASAR_SRC_DIR} EXCLUDE_FROM_ALL)
if(WIN32 OR MINGW)
list(APPEND ASAR_STATIC_SRC "${ASAR_STATIC_SRC_DIR}/platform/windows/file-helpers-win32.cpp")
# Create modern CMake target for Asar integration
if(TARGET asar-static)
# Ensure asar-static is available and properly configured
set_target_properties(asar-static PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
)
# Set platform-specific definitions for Asar
if(WIN32)
target_compile_definitions(asar-static PRIVATE
windows
strncasecmp=_strnicmp
strcasecmp=_stricmp
_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_WARNINGS
)
elseif(UNIX AND NOT APPLE)
target_compile_definitions(asar-static PRIVATE
linux
stricmp=strcasecmp
)
elseif(APPLE)
target_compile_definitions(asar-static PRIVATE
MACOS
stricmp=strcasecmp
)
endif()
# Add include directories
target_include_directories(asar-static PUBLIC
$<BUILD_INTERFACE:${ASAR_SRC_DIR}>
$<BUILD_INTERFACE:${ASAR_SRC_DIR}/asar>
$<BUILD_INTERFACE:${ASAR_SRC_DIR}/asar-dll-bindings/c>
)
# Create alias for easier linking
add_library(yaze::asar ALIAS asar-static)
# Export Asar variables for use in other parts of the build
set(ASAR_FOUND TRUE CACHE BOOL "Asar library found")
set(ASAR_LIBRARIES asar-static CACHE STRING "Asar library target")
set(ASAR_INCLUDE_DIRS
"${ASAR_SRC_DIR}"
"${ASAR_SRC_DIR}/asar"
"${ASAR_SRC_DIR}/asar-dll-bindings/c"
CACHE STRING "Asar include directories"
)
message(STATUS "Asar 65816 assembler integration configured successfully")
else()
list(APPEND ASAR_STATIC_SRC "${ASAR_STATIC_SRC_DIR}/platform/linux/file-helpers-linux.cpp")
endif()
message(WARNING "Failed to configure Asar static library target")
set(ASAR_FOUND FALSE CACHE BOOL "Asar library found")
endif()
# Function to add Asar patching capabilities to a target
function(yaze_add_asar_support target_name)
if(ASAR_FOUND)
target_link_libraries(${target_name} PRIVATE yaze::asar)
target_include_directories(${target_name} PRIVATE ${ASAR_INCLUDE_DIRS})
target_compile_definitions(${target_name} PRIVATE YAZE_ENABLE_ASAR=1)
else()
message(WARNING "Asar not available for target ${target_name}")
endif()
endfunction()
# Create function for ROM patching utilities
function(yaze_create_asar_patch_tool tool_name patch_file rom_file)
if(ASAR_FOUND)
add_custom_target(${tool_name}
COMMAND ${CMAKE_COMMAND} -E echo "Patching ROM with Asar..."
COMMAND $<TARGET_FILE:asar-standalone> ${patch_file} ${rom_file}
DEPENDS asar-standalone
COMMENT "Applying Asar patch ${patch_file} to ${rom_file}"
)
endif()
endfunction()

200
cmake/packaging.cmake Normal file
View File

@@ -0,0 +1,200 @@
# Modern packaging configuration for Yaze
# Supports Windows (NSIS), macOS (DMG), and Linux (DEB/RPM)
include(InstallRequiredSystemLibraries)
# Basic package information
set(CPACK_PACKAGE_NAME "yaze")
set(CPACK_PACKAGE_VENDOR "scawful")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Yet Another Zelda3 Editor")
set(CPACK_PACKAGE_DESCRIPTION "A comprehensive editor for The Legend of Zelda: A Link to the Past ROM hacking")
set(CPACK_PACKAGE_VERSION_MAJOR ${YAZE_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${YAZE_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${YAZE_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION "${YAZE_VERSION_MAJOR}.${YAZE_VERSION_MINOR}.${YAZE_VERSION_PATCH}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Yaze")
set(CPACK_PACKAGE_CONTACT "scawful@github.com")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/scawful/yaze")
# Resource files
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
# Package icon
if(EXISTS "${CMAKE_SOURCE_DIR}/assets/yaze.png")
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/assets/yaze.png")
endif()
# Platform-specific configuration
if(WIN32)
# Windows NSIS installer configuration
set(CPACK_GENERATOR "NSIS;ZIP")
set(CPACK_NSIS_DISPLAY_NAME "Yaze - Zelda3 Editor")
set(CPACK_NSIS_PACKAGE_NAME "Yaze")
set(CPACK_NSIS_CONTACT "scawful@github.com")
set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/scawful/yaze")
set(CPACK_NSIS_HELP_LINK "https://github.com/scawful/yaze/issues")
set(CPACK_NSIS_MENU_LINKS
"bin/yaze.exe" "Yaze Editor"
"https://github.com/scawful/yaze" "Yaze Homepage"
)
set(CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Yaze.lnk' '$INSTDIR\\\\bin\\\\yaze.exe'"
"CreateShortCut '$DESKTOP\\\\Yaze.lnk' '$INSTDIR\\\\bin\\\\yaze.exe'"
)
set(CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete '$SMPROGRAMS\\\\$START_MENU\\\\Yaze.lnk'"
"Delete '$DESKTOP\\\\Yaze.lnk'"
)
# Windows architecture detection
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CPACK_PACKAGE_FILE_NAME "yaze-${CPACK_PACKAGE_VERSION}-win64")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
else()
set(CPACK_PACKAGE_FILE_NAME "yaze-${CPACK_PACKAGE_VERSION}-win32")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
endif()
elseif(APPLE)
# macOS DMG configuration
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_VOLUME_NAME "Yaze ${CPACK_PACKAGE_VERSION}")
set(CPACK_DMG_FORMAT "UDZO")
set(CPACK_PACKAGE_FILE_NAME "yaze-${CPACK_PACKAGE_VERSION}-macos")
# macOS app bundle configuration
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/assets/dmg_background.png")
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/dmg_setup.scpt")
elseif(UNIX)
# Linux DEB/RPM configuration
set(CPACK_GENERATOR "DEB;RPM;TGZ")
# DEB package configuration
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "scawful <scawful@github.com>")
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DEPENDS
"libsdl2-2.0-0, libpng16-16, libgl1-mesa-glx, libabsl20210324")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "git")
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "asar")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
# RPM package configuration
set(CPACK_RPM_PACKAGE_SUMMARY "Zelda3 ROM Editor")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_GROUP "Amusements/Games")
set(CPACK_RPM_PACKAGE_REQUIRES
"SDL2 >= 2.0.0, libpng >= 1.6.0, mesa-libGL, abseil-cpp")
set(CPACK_RPM_PACKAGE_SUGGESTS "asar")
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
# Architecture detection
execute_process(
COMMAND uname -m
OUTPUT_VARIABLE CPACK_SYSTEM_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CPACK_PACKAGE_FILE_NAME "yaze-${CPACK_PACKAGE_VERSION}-linux-${CPACK_SYSTEM_ARCH}")
endif()
# Component configuration for advanced packaging
set(CPACK_COMPONENTS_ALL applications libraries headers documentation)
set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Yaze Application")
set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "Main Yaze editor application")
set(CPACK_COMPONENT_APPLICATIONS_REQUIRED TRUE)
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Development Libraries")
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Yaze development libraries")
set(CPACK_COMPONENT_LIBRARIES_REQUIRED FALSE)
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Development Headers")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION "Header files for Yaze development")
set(CPACK_COMPONENT_HEADERS_REQUIRED FALSE)
set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
set(CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation")
set(CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "User and developer documentation")
set(CPACK_COMPONENT_DOCUMENTATION_REQUIRED FALSE)
# Installation components
if(APPLE)
install(TARGETS yaze
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT applications
)
else()
install(TARGETS yaze
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT applications
)
endif()
# Install assets
install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets/
DESTINATION ${CMAKE_INSTALL_DATADIR}/yaze/assets
COMPONENT applications
PATTERN "*.png"
PATTERN "*.ttf"
PATTERN "*.asm"
PATTERN "*.zeml"
)
# Install documentation
install(FILES
${CMAKE_SOURCE_DIR}/README.md
${CMAKE_SOURCE_DIR}/LICENSE
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT documentation
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/docs/
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT documentation
PATTERN "*.md"
PATTERN "*.html"
)
# Install headers and libraries if building library components
if(YAZE_INSTALL_LIB)
install(TARGETS yaze_c
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT libraries
)
install(FILES ${CMAKE_SOURCE_DIR}/incl/yaze.h ${CMAKE_SOURCE_DIR}/incl/zelda.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/yaze
COMPONENT headers
)
endif()
# Desktop integration for Linux
if(UNIX AND NOT APPLE)
# Desktop file
configure_file(
${CMAKE_SOURCE_DIR}/cmake/yaze.desktop.in
${CMAKE_BINARY_DIR}/yaze.desktop
@ONLY
)
install(FILES ${CMAKE_BINARY_DIR}/yaze.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
COMPONENT applications
)
# Icon
if(EXISTS "${CMAKE_SOURCE_DIR}/assets/yaze.png")
install(FILES ${CMAKE_SOURCE_DIR}/assets/yaze.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/pixmaps
RENAME yaze.png
COMPONENT applications
)
endif()
endif()
# Include CPack
include(CPack)

13
cmake/yaze.desktop.in Normal file
View File

@@ -0,0 +1,13 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Yaze
Comment=Yet Another Zelda3 Editor
Comment[en]=ROM editor for The Legend of Zelda: A Link to the Past
Exec=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/yaze
Icon=yaze
Terminal=false
Categories=Game;Development;
Keywords=zelda;snes;rom;editor;hacking;
StartupNotify=true
MimeType=application/x-snes-rom;application/x-sfc;application/x-smc;