corregit makefile per a windows

This commit is contained in:
2026-03-30 09:41:28 +02:00
parent e13a28f69a
commit 98f01a6dde

View File

@@ -36,7 +36,11 @@ PACK_INCLUDES := -Isource
SHADER_SCRIPT := $(DIR_ROOT)tools/shaders/compile_spirv.sh SHADER_SCRIPT := $(DIR_ROOT)tools/shaders/compile_spirv.sh
SHADER_VERT_H := $(DIR_ROOT)source/core/rendering/sdl3gpu/postfx_vert_spv.h SHADER_VERT_H := $(DIR_ROOT)source/core/rendering/sdl3gpu/postfx_vert_spv.h
SHADER_FRAG_H := $(DIR_ROOT)source/core/rendering/sdl3gpu/postfx_frag_spv.h SHADER_FRAG_H := $(DIR_ROOT)source/core/rendering/sdl3gpu/postfx_frag_spv.h
ifeq ($(OS),Windows_NT)
GLSLC := $(shell where glslc 2>NUL)
else
GLSLC := $(shell command -v glslc 2>/dev/null) GLSLC := $(shell command -v glslc 2>/dev/null)
endif
# ============================================================================== # ==============================================================================
# VERSION (extracted from defines.hpp) # VERSION (extracted from defines.hpp)
@@ -47,6 +51,14 @@ else
VERSION := v$(shell grep 'constexpr const char\* VERSION' source/utils/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/') VERSION := v$(shell grep 'constexpr const char\* VERSION' source/utils/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/')
endif endif
# ==============================================================================
# SHELL (Windows usa cmd.exe para que las recetas con powershell funcionen igual
# desde cualquier terminal: PowerShell, cmd o git-bash)
# ==============================================================================
ifeq ($(OS),Windows_NT)
SHELL := cmd.exe
endif
# ============================================================================== # ==============================================================================
# WINDOWS-SPECIFIC VARIABLES # WINDOWS-SPECIFIC VARIABLES
# ============================================================================== # ==============================================================================
@@ -174,9 +186,16 @@ endif
# ============================================================================== # ==============================================================================
compile_shaders: compile_shaders:
ifdef GLSLC ifdef GLSLC
ifeq ($(OS),Windows_NT)
@powershell -Command "if ((Test-Path '$(SHADER_VERT_H)') -and (Test-Path '$(SHADER_FRAG_H)')) { Write-Host 'Shaders SPIR-V precompilados OK' } else { Write-Host 'Compilando shaders SPIR-V...'; bash '$(SHADER_SCRIPT)'; Write-Host 'Shaders compilados' }"
else
@echo "Compilando shaders SPIR-V..." @echo "Compilando shaders SPIR-V..."
@$(SHADER_SCRIPT) @$(SHADER_SCRIPT)
@echo "✓ Shaders compilados" @echo "✓ Shaders compilados"
endif
else
ifeq ($(OS),Windows_NT)
@powershell -Command "if ((Test-Path '$(SHADER_VERT_H)') -and (Test-Path '$(SHADER_FRAG_H)')) { Write-Host 'glslc no encontrado - usando headers SPIR-V precompilados' } else { Write-Host 'ERROR: glslc no encontrado y headers SPIR-V no existen.'; Write-Host ' Instala glslc o ejecuta: tools/shaders/compile_spirv.sh'; exit 1 }"
else else
@if [ -f "$(SHADER_VERT_H)" ] && [ -f "$(SHADER_FRAG_H)" ]; then \ @if [ -f "$(SHADER_VERT_H)" ] && [ -f "$(SHADER_FRAG_H)" ]; then \
echo "⚠ glslc no encontrado - usando headers SPIR-V precompilados"; \ echo "⚠ glslc no encontrado - usando headers SPIR-V precompilados"; \
@@ -187,6 +206,7 @@ else
exit 1; \ exit 1; \
fi fi
endif endif
endif
# ============================================================================== # ==============================================================================
# REGLAS PARA HERRAMIENTA DE EMPAQUETADO Y RESOURCES.PACK # REGLAS PARA HERRAMIENTA DE EMPAQUETADO Y RESOURCES.PACK
@@ -216,8 +236,8 @@ windows:
strip -s -R .comment -R .gnu.version "$(WIN_TARGET_FILE).exe" --strip-unneeded strip -s -R .comment -R .gnu.version "$(WIN_TARGET_FILE).exe" --strip-unneeded
windows_release: windows_release:
@$(MAKE) compile_shaders @"$(MAKE)" compile_shaders
@$(MAKE) resources.pack @"$(MAKE)" resources.pack
@echo off @echo off
@echo Creando release para Windows - Version: $(VERSION) @echo Creando release para Windows - Version: $(VERSION)
@@ -226,18 +246,18 @@ windows_release:
@powershell -Command "$$GIT_HASH = (git rev-parse --short=7 HEAD 2>$$null); if (-not $$GIT_HASH) { $$GIT_HASH = 'unknown' }; (Get-Content source/version.h.in) -replace '@GIT_HASH@', $$GIT_HASH | Set-Content source/version.h" @powershell -Command "$$GIT_HASH = (git rev-parse --short=7 HEAD 2>$$null); if (-not $$GIT_HASH) { $$GIT_HASH = 'unknown' }; (Get-Content source/version.h.in) -replace '@GIT_HASH@', $$GIT_HASH | Set-Content source/version.h"
# Crea carpeta de distribución y carpeta temporal 'RELEASE_FOLDER' # Crea carpeta de distribución y carpeta temporal 'RELEASE_FOLDER'
powershell if (-not (Test-Path "$(DIST_DIR)")) {New-Item "$(DIST_DIR)" -ItemType Directory} @powershell -Command "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 -Command "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 '$(RELEASE_FOLDER)')) {New-Item '$(RELEASE_FOLDER)' -ItemType Directory}"
# Copia el archivo 'resources.pack' # Copia el archivo 'resources.pack'
powershell Copy-Item -Path "resources.pack" -Destination "$(RELEASE_FOLDER)" @powershell -Command "Copy-Item -Path 'resources.pack' -Destination '$(RELEASE_FOLDER)'"
# Copia los ficheros que están en la raíz del proyecto # Copia los ficheros que están en la raíz del proyecto
powershell Copy-Item "LICENSE" -Destination "$(RELEASE_FOLDER)" @powershell -Command "Copy-Item 'LICENSE' -Destination '$(RELEASE_FOLDER)'"
powershell Copy-Item "README.md" -Destination "$(RELEASE_FOLDER)" @powershell -Command "Copy-Item 'README.md' -Destination '$(RELEASE_FOLDER)'"
powershell Copy-Item "gamecontrollerdb.txt" -Destination "$(RELEASE_FOLDER)" @powershell -Command "Copy-Item 'gamecontrollerdb.txt' -Destination '$(RELEASE_FOLDER)'"
powershell Copy-Item "release\windows\dll\*.dll" -Destination "$(RELEASE_FOLDER)" @powershell -Command "Copy-Item 'release\windows\dll\*.dll' -Destination '$(RELEASE_FOLDER)'"
# Compila (con icono) # Compila (con icono)
windres release/windows/jdd.rc -O coff -o $(RESOURCE_FILE) windres release/windows/jdd.rc -O coff -o $(RESOURCE_FILE)
@@ -245,12 +265,12 @@ windows_release:
strip -s -R .comment -R .gnu.version "$(WIN_RELEASE_FILE).exe" --strip-unneeded strip -s -R .comment -R .gnu.version "$(WIN_RELEASE_FILE).exe" --strip-unneeded
# Crea el fichero .zip # Crea el fichero .zip
powershell if (Test-Path "$(WINDOWS_RELEASE)") {Remove-Item "$(WINDOWS_RELEASE)"} @powershell -Command "if (Test-Path '$(WINDOWS_RELEASE)') {Remove-Item '$(WINDOWS_RELEASE)'}"
powershell Compress-Archive -Path "$(RELEASE_FOLDER)"/* -DestinationPath "$(WINDOWS_RELEASE)" @powershell -Command "Compress-Archive -Path '$(RELEASE_FOLDER)/*' -DestinationPath '$(WINDOWS_RELEASE)'"
@echo Release creado: $(WINDOWS_RELEASE) @echo Release creado: $(WINDOWS_RELEASE)
# Elimina la carpeta temporal 'RELEASE_FOLDER' # Elimina la carpeta temporal 'RELEASE_FOLDER'
powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force} @powershell -Command "if (Test-Path '$(RELEASE_FOLDER)') {Remove-Item '$(RELEASE_FOLDER)' -Recurse -Force}"
# ============================================================================== # ==============================================================================
# COMPILACIÓN PARA MACOS # COMPILACIÓN PARA MACOS