diff --git a/CLAUDE.md b/CLAUDE.md index 1a53109..0e54d9b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,17 +16,15 @@ cmake -B build -DCMAKE_BUILD_TYPE=Debug # configure cmake --build build # build ``` -### Makefile (direct compilation, platform-specific targets) +### Makefile (delegates to CMake) ```bash -make linux # build for Linux -make linux_debug # debug build with -DDEBUG -DVERBOSE +make # build Release via cmake +make debug # build Debug via cmake +make release # create release package (auto-detects OS) make linux_release # release tar.gz with resources.pack -make windows # build for Windows (cross-compile or native) -make windows_debug # Windows debug build -make macos # build for macOS (arm64) -make raspi # build for Raspberry Pi -make anbernic # build for Anbernic (no shaders, arcade mode) -make no_audio # build without audio system +make windows_release # release zip for Windows +make macos_release # release dmg for macOS (Intel + Apple Silicon) +make raspi_release # release tar.gz for Raspberry Pi ``` ### Tools & Resources diff --git a/Makefile b/Makefile index 363aefb..50fcee2 100644 --- a/Makefile +++ b/Makefile @@ -1,234 +1,168 @@ -# Directorios +# ============================================================================== +# DIRECTORIES +# ============================================================================== DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST))) -DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source) -DIR_BIN := $(addsuffix /, $(DIR_ROOT)) -DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build) DIR_TOOLS := $(addsuffix /, $(DIR_ROOT)tools) -# Variables +# ============================================================================== +# TARGET NAMES +# ============================================================================== TARGET_NAME := coffee_crisis_arcade_edition -TARGET_FILE := $(DIR_BIN)$(TARGET_NAME) +TARGET_FILE := $(DIR_ROOT)$(TARGET_NAME) APP_NAME := Coffee Crisis Arcade Edition DIST_DIR := dist RELEASE_FOLDER := dist/_tmp RELEASE_FILE := $(RELEASE_FOLDER)/$(TARGET_NAME) RESOURCE_FILE := release/windows/coffee.res -# Variables para herramienta de empaquetado -ifeq ($(OS),Windows_NT) - PACK_TOOL := $(DIR_TOOLS)pack_resources/pack_resources.exe - PACK_CXX := $(CXX) -else - PACK_TOOL := $(DIR_TOOLS)pack_resources/pack_resources - PACK_CXX := $(CXX) -endif -PACK_SOURCES := $(DIR_TOOLS)pack_resources/pack_resources.cpp $(DIR_SOURCES)resource_pack.cpp -PACK_INCLUDES := -I$(DIR_ROOT) -I$(DIR_BUILD) +# ============================================================================== +# TOOLS +# ============================================================================== +DIR_PACK_TOOL := $(DIR_TOOLS)pack_resources +SHADER_SCRIPT := $(DIR_ROOT)tools/shaders/compile_spirv.sh -# Versión automática basada en la fecha actual (específica por SO) +# ============================================================================== +# VERSION (fecha actual) +# ============================================================================== ifeq ($(OS),Windows_NT) VERSION := $(shell powershell -Command "Get-Date -Format 'yyyy-MM-dd'") else VERSION := $(shell date +%Y-%m-%d) endif -# Variables específicas para Windows (usando APP_NAME) +# ============================================================================== +# SHELL (Windows usa cmd.exe) +# ============================================================================== ifeq ($(OS),Windows_NT) - WIN_TARGET_FILE := $(DIR_BIN)$(APP_NAME) + SHELL := cmd.exe +endif + +# ============================================================================== +# WINDOWS-SPECIFIC VARIABLES +# ============================================================================== +ifeq ($(OS),Windows_NT) + WIN_TARGET_FILE := $(DIR_ROOT)$(APP_NAME) WIN_RELEASE_FILE := $(RELEASE_FOLDER)/$(APP_NAME) else WIN_TARGET_FILE := $(TARGET_FILE) WIN_RELEASE_FILE := $(RELEASE_FILE) endif -# Nombres para los ficheros de lanzamiento +# ============================================================================== +# RELEASE NAMES +# ============================================================================== WINDOWS_RELEASE := $(DIST_DIR)/$(TARGET_NAME)-$(VERSION)-win32-x64.zip MACOS_INTEL_RELEASE := $(DIST_DIR)/$(TARGET_NAME)-$(VERSION)-macos-intel.dmg MACOS_APPLE_SILICON_RELEASE := $(DIST_DIR)/$(TARGET_NAME)-$(VERSION)-macos-apple-silicon.dmg LINUX_RELEASE := $(DIST_DIR)/$(TARGET_NAME)-$(VERSION)-linux.tar.gz RASPI_RELEASE := $(DIST_DIR)/$(TARGET_NAME)-$(VERSION)-raspberry.tar.gz -# Lista completa de archivos fuente (basada en CMakeLists.txt) -APP_SOURCES := \ - source/asset.cpp \ - source/audio.cpp \ - source/director.cpp \ - source/global_events.cpp \ - source/global_inputs.cpp \ - source/input.cpp \ - source/lang.cpp \ - source/main.cpp \ - source/param.cpp \ - source/resource.cpp \ - source/resource_helper.cpp \ - source/resource_loader.cpp \ - source/resource_pack.cpp \ - source/screen.cpp \ - source/text.cpp \ - source/writer.cpp \ - source/ui/menu_option.cpp \ - source/ui/menu_renderer.cpp \ - source/ui/notifier.cpp \ - source/ui/service_menu.cpp \ - source/ui/ui_message.cpp \ - source/ui/window_message.cpp \ - source/balloon_formations.cpp \ - source/balloon_manager.cpp \ - source/balloon.cpp \ - source/bullet.cpp \ - source/bullet_manager.cpp \ - source/enter_name.cpp \ - source/explosions.cpp \ - source/game_logo.cpp \ - source/item.cpp \ - source/manage_hiscore_table.cpp \ - source/player.cpp \ - source/scoreboard.cpp \ - source/tabe.cpp \ - source/sections/credits.cpp \ - source/sections/game.cpp \ - source/sections/hiscore_table.cpp \ - source/sections/instructions.cpp \ - source/sections/intro.cpp \ - source/sections/logo.cpp \ - source/sections/title.cpp \ - source/animated_sprite.cpp \ - source/background.cpp \ - source/card_sprite.cpp \ - source/fade.cpp \ - source/moving_sprite.cpp \ - source/path_sprite.cpp \ - source/smart_sprite.cpp \ - source/sprite.cpp \ - source/texture.cpp \ - source/tiled_bg.cpp \ - source/color.cpp \ - source/demo.cpp \ - source/define_buttons.cpp \ - source/difficulty.cpp \ - source/input_types.cpp \ - source/mouse.cpp \ - source/options.cpp \ - source/shutdown.cpp \ - source/stage.cpp \ - source/system_utils.cpp \ - source/utils.cpp \ - source/external/jail_audio.cpp \ - source/external/gif.cpp \ - source/rendering/sdl3gpu/sdl3gpu_shader.cpp - -# Includes -INCLUDES := -Isource -Isource/external -Isource/rendering -Isource/rendering/sdl3gpu -I$(DIR_BUILD) - -# Variables según el sistema operativo +# ============================================================================== +# PLATAFORMA +# ============================================================================== ifeq ($(OS),Windows_NT) FixPath = $(subst /,\\,$1) - CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -static-libgcc -Wl,-Bstatic -lpthread -Wl,-Bdynamic -Wl,-subsystem,windows -DWINDOWS_BUILD - CXXFLAGS_DEBUG := -std=c++20 -Wall -g -D_DEBUG -DWINDOWS_BUILD - LDFLAGS := -lmingw32 -lws2_32 -lSDL3 RM := del /Q MKDIR := mkdir else FixPath = $1 - CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections - CXXFLAGS_DEBUG := -std=c++20 -Wall -g -D_DEBUG - LDFLAGS := -lSDL3 RMFILE := rm -f RMDIR := rm -rdf MKDIR := mkdir -p UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Linux) - CXXFLAGS += -DLINUX_BUILD - endif - ifeq ($(UNAME_S),Darwin) - CXXFLAGS += -DMACOS_BUILD - CXXFLAGS_DEBUG += -DMACOS_BUILD - # Configurar arquitectura (por defecto arm64, como en CMake) - CXXFLAGS += -arch arm64 - CXXFLAGS_DEBUG += -arch arm64 - endif endif -# Reglas para herramienta de empaquetado y resources.pack -$(PACK_TOOL): FORCE - @echo "Compilando herramienta de empaquetado..." - $(PACK_CXX) -std=c++20 -Wall -Os $(PACK_INCLUDES) $(PACK_SOURCES) -o $(PACK_TOOL) - @echo "✓ Herramienta de empaquetado lista: $(PACK_TOOL)" +# ============================================================================== +# COMPILACIÓN CON CMAKE +# ============================================================================== +all: + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build -pack_tool: $(PACK_TOOL) +debug: + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug + @cmake --build build -resources.pack: $(PACK_TOOL) - @echo "Generando resources.pack desde directorio data/..." - $(PACK_TOOL) data resources.pack - @echo "✓ resources.pack generado exitosamente" +# ============================================================================== +# RELEASE AUTOMÁTICO (detecta SO) +# ============================================================================== +release: +ifeq ($(OS),Windows_NT) + @"$(MAKE)" windows_release +else +ifeq ($(UNAME_S),Darwin) + @$(MAKE) macos_release +else + @$(MAKE) linux_release +endif +endif -# Reglas para compilación -windows: - @echo off - @echo Compilando para Windows con nombre: "$(APP_NAME).exe" - windres release/windows/coffee.rc -O coff -o $(RESOURCE_FILE) - $(CXX) $(APP_SOURCES) $(RESOURCE_FILE) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_TARGET_FILE).exe" - strip -s -R .comment -R .gnu.version "$(WIN_TARGET_FILE).exe" --strip-unneeded +# ============================================================================== +# REGLAS PARA HERRAMIENTA DE EMPAQUETADO Y RESOURCES.PACK +# ============================================================================== +pack_tool: + @$(MAKE) -C $(DIR_PACK_TOOL) -windows_rec: - @echo off - @echo Compilando version de grabacion para Windows: "$(APP_NAME)_rec.exe" - $(CXX) $(APP_SOURCES) $(INCLUDES) -DRECORDING $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_TARGET_FILE)_rec.exe" +resources.pack: pack_tool + @$(MAKE) -C $(DIR_PACK_TOOL) pack -windows_debug: - @echo off - @echo Compilando version debug para Windows: "$(APP_NAME)_debug.exe" - $(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(WIN_TARGET_FILE)_debug.exe" +# ============================================================================== +# COMPILACIÓN DE SHADERS +# ============================================================================== +spirv: + @echo "Compilando shaders SPIR-V..." + $(SHADER_SCRIPT) +# ============================================================================== +# COMPILACIÓN PARA WINDOWS (RELEASE) +# ============================================================================== windows_release: - @$(MAKE) pack_tool @$(MAKE) resources.pack @echo off @echo Creando release para Windows - Version: $(VERSION) +# Compila con cmake + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build + # Crea carpeta de distribución y carpeta temporal 'RELEASE_FOLDER' - powershell if (-not (Test-Path "$(DIST_DIR)")) {New-Item "$(DIST_DIR)" -ItemType Directory} - powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force} - powershell if (-not (Test-Path "$(RELEASE_FOLDER)")) {New-Item "$(RELEASE_FOLDER)" -ItemType Directory} + @powershell -Command "if (-not (Test-Path '$(DIST_DIR)')) {New-Item '$(DIST_DIR)' -ItemType Directory}" + @powershell -Command "if (Test-Path '$(RELEASE_FOLDER)') {Remove-Item '$(RELEASE_FOLDER)' -Recurse -Force}" + @powershell -Command "if (-not (Test-Path '$(RELEASE_FOLDER)')) {New-Item '$(RELEASE_FOLDER)' -ItemType Directory}" # Copia la carpeta 'config' y el archivo 'resources.pack' - powershell Copy-Item -Path "config" -Destination "$(RELEASE_FOLDER)" -recurse -Force - powershell Copy-Item -Path "resources.pack" -Destination "$(RELEASE_FOLDER)" + @powershell -Command "Copy-Item -Path 'config' -Destination '$(RELEASE_FOLDER)' -recurse -Force" + @powershell -Command "Copy-Item -Path 'resources.pack' -Destination '$(RELEASE_FOLDER)'" # Copia los ficheros que estan en la raíz del proyecto - powershell Copy-Item "LICENSE" -Destination "$(RELEASE_FOLDER)" - powershell Copy-Item "README.md" -Destination "$(RELEASE_FOLDER)" - powershell Copy-Item "release\windows\dll\*.dll" -Destination "$(RELEASE_FOLDER)" - -# Compila - windres release/windows/coffee.rc -O coff -o $(RESOURCE_FILE) - $(CXX) $(APP_SOURCES) $(RESOURCE_FILE) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_RELEASE_FILE).exe" + @powershell -Command "Copy-Item 'LICENSE' -Destination '$(RELEASE_FOLDER)'" + @powershell -Command "Copy-Item 'README.md' -Destination '$(RELEASE_FOLDER)'" + @powershell -Command "Copy-Item 'release\windows\dll\*.dll' -Destination '$(RELEASE_FOLDER)'" + @powershell -Command "Copy-Item -Path '$(TARGET_FILE)' -Destination '\"$(WIN_RELEASE_FILE).exe\"'" strip -s -R .comment -R .gnu.version "$(WIN_RELEASE_FILE).exe" --strip-unneeded # Crea el fichero .zip - powershell if (Test-Path "$(WINDOWS_RELEASE)") {Remove-Item "$(WINDOWS_RELEASE)"} - powershell Compress-Archive -Path "$(RELEASE_FOLDER)"/* -DestinationPath "$(WINDOWS_RELEASE)" + @powershell -Command "if (Test-Path '$(WINDOWS_RELEASE)') {Remove-Item '$(WINDOWS_RELEASE)'}" + @powershell -Command "Compress-Archive -Path '$(RELEASE_FOLDER)/*' -DestinationPath '$(WINDOWS_RELEASE)'" @echo Release creado: $(WINDOWS_RELEASE) # Elimina la carpeta temporal 'RELEASE_FOLDER' - powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force} - -macos: - @echo "Compilando para macOS: $(TARGET_NAME)" - $(CXX) $(APP_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)" - -macos_debug: - @echo "Compilando version debug para macOS: $(TARGET_NAME)_debug" - $(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug" + @powershell -Command "if (Test-Path '$(RELEASE_FOLDER)') {Remove-Item '$(RELEASE_FOLDER)' -Recurse -Force}" +# ============================================================================== +# COMPILACIÓN PARA MACOS (RELEASE) +# ============================================================================== macos_release: - @$(MAKE) pack_tool @$(MAKE) resources.pack @echo "Creando release para macOS - Version: $(VERSION)" # Verificar e instalar create-dmg si es necesario @which create-dmg > /dev/null || (echo "Instalando create-dmg..." && brew install create-dmg) +# Compila la versión para procesadores Intel con cmake + @cmake -S . -B build/intel -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 + @cmake --build build/intel + # Elimina datos de compilaciones anteriores $(RMDIR) "$(RELEASE_FOLDER)" $(RMFILE) tmp.dmg @@ -251,9 +185,8 @@ macos_release: cp LICENSE "$(RELEASE_FOLDER)" cp README.md "$(RELEASE_FOLDER)" -# Compila la versión para procesadores Intel -ifdef ENABLE_MACOS_X86_64 - $(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DMACOS_BUILD -DRELEASE_BUILD -std=c++20 -Wall -Os -Wno-deprecated -framework SDL3 -F release/macos/frameworks/SDL3.xcframework/macos-arm64_x86_64 -ffunction-sections -fdata-sections -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.15 +# Copia el ejecutable Intel al bundle + cp "$(TARGET_FILE)" "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" # Firma la aplicación codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app" @@ -274,10 +207,11 @@ ifdef ENABLE_MACOS_X86_64 "$(MACOS_INTEL_RELEASE)" \ "$(RELEASE_FOLDER)" || true @echo "Release Intel creado: $(MACOS_INTEL_RELEASE)" -endif -# Compila la versión para procesadores Apple Silicon - $(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DMACOS_BUILD -DRELEASE_BUILD -DSDL_DISABLE_IMMINTRIN_H -std=c++20 -Wall -Os -Wno-deprecated -framework SDL3 -F release/macos/frameworks/SDL3.xcframework/macos-arm64_x86_64 -ffunction-sections -fdata-sections -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11 +# Compila la versión para procesadores Apple Silicon con cmake + @cmake -S . -B build/arm -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 + @cmake --build build/arm + cp "$(TARGET_FILE)" "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" # Firma la aplicación codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app" @@ -301,22 +235,22 @@ endif # Elimina las carpetas temporales $(RMDIR) "$(RELEASE_FOLDER)" + $(RMDIR) build/intel + $(RMDIR) build/arm $(RMFILE) "$(DIST_DIR)"/rw.* -linux: - @echo "Compilando para Linux: $(TARGET_NAME)" - $(CXX) $(APP_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)" - strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded - -linux_debug: - @echo "Compilando version debug para Linux: $(TARGET_NAME)_debug" - $(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug" - +# ============================================================================== +# COMPILACIÓN PARA LINUX (RELEASE) +# ============================================================================== linux_release: - @$(MAKE) pack_tool @$(MAKE) resources.pack @echo "Creando release para Linux - Version: $(VERSION)" -# Elimina carpetas previas y recrea (crea dist/ si no existe) + +# Compila con cmake + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build + +# Elimina carpeta temporal previa y la recrea (crea dist/ si no existe) $(RMDIR) "$(RELEASE_FOLDER)" $(MKDIR) "$(RELEASE_FOLDER)" @@ -325,9 +259,7 @@ linux_release: cp resources.pack "$(RELEASE_FOLDER)" cp LICENSE "$(RELEASE_FOLDER)" cp README.md "$(RELEASE_FOLDER)" - -# Compila - $(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE)" + cp "$(TARGET_FILE)" "$(RELEASE_FILE)" strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded # Empaqueta ficheros @@ -338,10 +270,17 @@ linux_release: # Elimina la carpeta temporal $(RMDIR) "$(RELEASE_FOLDER)" +# ============================================================================== +# COMPILACIÓN PARA LINUX (RELEASE CON INTEGRACIÓN DESKTOP) +# ============================================================================== linux_release_desktop: - @$(MAKE) pack_tool @$(MAKE) resources.pack @echo "Creando release con integracion desktop para Linux - Version: $(VERSION)" + +# Compila con cmake + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build + # Elimina carpetas previas y recrea (crea dist/ si no existe) $(RMDIR) "$(RELEASE_FOLDER)" @@ -358,8 +297,8 @@ linux_release_desktop: cp LICENSE "$(RELEASE_FOLDER)/$(TARGET_NAME)/" cp README.md "$(RELEASE_FOLDER)/$(TARGET_NAME)/" -# Compila el ejecutable - $(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(TARGET_NAME)/bin/$(TARGET_NAME)" +# Copia el ejecutable + cp "$(TARGET_FILE)" "$(RELEASE_FOLDER)/$(TARGET_NAME)/bin/$(TARGET_NAME)" strip -s -R .comment -R .gnu.version "$(RELEASE_FOLDER)/$(TARGET_NAME)/bin/$(TARGET_NAME)" --strip-unneeded # Crea el archivo .desktop @@ -433,19 +372,17 @@ linux_release_desktop: # Elimina la carpeta temporal $(RMDIR) "$(RELEASE_FOLDER)" -raspi: - @echo "Compilando para Raspberry Pi: $(TARGET_NAME)" - $(CXX) $(APP_SOURCES) $(INCLUDES) -DVERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(TARGET_FILE) - strip -s -R .comment -R .gnu.version $(TARGET_FILE) --strip-unneeded - -raspi_debug: - @echo "Compilando version debug para Raspberry Pi: $(TARGET_NAME)_debug" - $(CXX) $(APP_SOURCES) $(INCLUDES) -DVERBOSE -DDEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug" - +# ============================================================================== +# COMPILACIÓN PARA RASPBERRY PI (RELEASE) +# ============================================================================== raspi_release: - @$(MAKE) pack_tool @$(MAKE) resources.pack @echo "Creando release para Raspberry Pi - Version: $(VERSION)" + +# Compila con cmake + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build + # Elimina carpetas previas y recrea (crea dist/ si no existe) $(RMDIR) "$(RELEASE_FOLDER)" $(MKDIR) "$(RELEASE_FOLDER)" @@ -455,9 +392,7 @@ raspi_release: cp resources.pack "$(RELEASE_FOLDER)" cp LICENSE "$(RELEASE_FOLDER)" cp README.md "$(RELEASE_FOLDER)" - -# Compila - $(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD -DVERBOSE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE)" + cp "$(TARGET_FILE)" "$(RELEASE_FILE)" strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded # Empaqueta ficheros @@ -468,59 +403,60 @@ raspi_release: # Elimina la carpeta temporal $(RMDIR) "$(RELEASE_FOLDER)" -anbernic: - @$(MAKE) pack_tool - @$(MAKE) resources.pack - @echo "Compilando para Anbernic: $(TARGET_NAME)" -# Elimina carpetas previas - $(RMDIR) "$(RELEASE_FOLDER)"_anbernic +# ============================================================================== +# CODE QUALITY (delegados a cmake) +# ============================================================================== +format: + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build --target format -# Crea la carpeta temporal para realizar el lanzamiento - $(MKDIR) "$(RELEASE_FOLDER)"_anbernic +format-check: + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build --target format-check -# Copia ficheros - cp -R config "$(RELEASE_FOLDER)"_anbernic - cp resources.pack "$(RELEASE_FOLDER)"_anbernic +tidy: + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build --target tidy -# Compila - $(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD -DANBERNIC -DNO_SHADERS -DARCADE -DVERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(RELEASE_FOLDER)_anbernic/$(TARGET_NAME) +tidy-fix: + @cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + @cmake --build build --target tidy-fix -# Opción para deshabilitar audio (equivalente a la opción DISABLE_AUDIO de CMake) -no_audio: - @echo "Compilando sin audio: $(TARGET_NAME)_no_audio" - $(CXX) $(filter-out source/external/jail_audio.cpp,$(APP_SOURCES)) $(INCLUDES) -DNO_AUDIO $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_no_audio" - -# Regla para mostrar la versión actual +# ============================================================================== +# REGLAS ESPECIALES +# ============================================================================== show_version: @echo "Version actual: $(VERSION)" -# Regla de ayuda help: @echo "Makefile para Coffee Crisis Arcade Edition" @echo "Comandos disponibles:" - @echo " windows - Compilar para Windows" - @echo " windows_debug - Compilar debug para Windows" - @echo " windows_release - Crear release completo para Windows" - @echo " linux - Compilar para Linux" - @echo " linux_debug - Compilar debug para Linux" - @echo " linux_release - Crear release basico para Linux" - @echo " linux_release_desktop - Crear release con integracion desktop para Linux" - @echo " macos - Compilar para macOS" - @echo " macos_debug - Compilar debug para macOS" - @echo " macos_release - Crear release completo para macOS" - @echo " raspi - Compilar para Raspberry Pi" - @echo " raspi_release - Crear release completo para Raspberry Pi" - @echo " anbernic - Compilar para Anbernic" - @echo " no_audio - Compilar sin sistema de audio" - @echo " pack_tool - Compilar herramienta de empaquetado" - @echo " resources.pack - Generar pack de recursos desde data/" - @echo " show_version - Mostrar version actual ($(VERSION))" - @echo " help - Mostrar esta ayuda" + @echo "" + @echo " Compilacion:" + @echo " make - Compilar con cmake (Release)" + @echo " make debug - Compilar con cmake (Debug)" + @echo "" + @echo " Release:" + @echo " make release - Crear release (detecta SO automaticamente)" + @echo " make windows_release - Crear release para Windows" + @echo " make linux_release - Crear release basico para Linux" + @echo " make linux_release_desktop - Crear release con integracion desktop para Linux" + @echo " make macos_release - Crear release para macOS" + @echo " make raspi_release - Crear release para Raspberry Pi" + @echo "" + @echo " Herramientas:" + @echo " make spirv - Compilar shaders SPIR-V" + @echo " make pack_tool - Compilar herramienta de empaquetado" + @echo " make resources.pack - Generar pack de recursos desde data/" + @echo "" + @echo " Calidad de codigo:" + @echo " make format - Formatear codigo con clang-format" + @echo " make format-check - Verificar formato sin modificar" + @echo " make tidy - Analisis estatico con clang-tidy" + @echo " make tidy-fix - Analisis estatico con auto-fix" + @echo "" + @echo " Otros:" + @echo " make show_version - Mostrar version actual ($(VERSION))" + @echo " make help - Mostrar esta ayuda" -spirv: - @echo "Compilando shaders SPIR-V..." - tools/shaders/compile_spirv.sh - -.PHONY: windows windows_rec windows_debug windows_release macos macos_debug macos_release linux linux_debug linux_release linux_release_desktop raspi raspi_debug raspi_release anbernic no_audio show_version help pack_tool resources.pack spirv - -FORCE: \ No newline at end of file +.PHONY: all debug release windows_release macos_release linux_release linux_release_desktop raspi_release pack_tool resources.pack spirv format format-check tidy tidy-fix show_version help diff --git a/tools/pack_resources/Makefile b/tools/pack_resources/Makefile index 3a2add0..70ffca5 100644 --- a/tools/pack_resources/Makefile +++ b/tools/pack_resources/Makefile @@ -3,7 +3,7 @@ # Variables CXX := g++ -CXXFLAGS := -std=c++20 -Wall -Os -I../../ +CXXFLAGS := -std=c++20 -Wall -Os SOURCES := pack_resources.cpp ../../source/resource_pack.cpp TARGET := pack_resources CLEAN_FILES := pack_resources *.pack *.o @@ -21,7 +21,7 @@ else endif # Reglas principales -.PHONY: all pack_tool clean help test_pack +.PHONY: all pack_tool pack clean help test_pack # Compilar herramienta de empaquetado all: pack_tool @@ -37,6 +37,14 @@ clean: $(CLEAN_CMD) $(call FixPath,$(CLEAN_FILES)) @echo "✓ Archivos limpiados" +# Crear pack de recursos final (invocado desde Makefile raíz) +pack: pack_tool +ifeq ($(OS),Windows_NT) + .\$(TARGET) ..\..\data ..\..\resources.pack +else + ./$(TARGET) ../../data ../../resources.pack +endif + # Crear pack de recursos de prueba test_pack: pack_tool @echo "Creando pack de recursos de prueba..." diff --git a/tools/pack_resources/pack_resources.cpp b/tools/pack_resources/pack_resources.cpp index 8c82aca..f830def 100644 --- a/tools/pack_resources/pack_resources.cpp +++ b/tools/pack_resources/pack_resources.cpp @@ -1,5 +1,5 @@ -#include "../source/resource_pack.hpp" -#include "../build/version.h" // Para Version::APP_NAME +#include "../../source/resource_pack.hpp" +#include "../../build/version.h" // Para Version::APP_NAME #include #include