corregit make release de windows
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
.vscode/
|
||||
.claude/
|
||||
.cache/
|
||||
build/
|
||||
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json"
|
||||
}
|
||||
@@ -140,13 +140,30 @@ if(NOT APPLE)
|
||||
set(ALL_SHADER_HEADERS "${SHADER_VERT_H}" "${SHADER_FRAG_H}" "${SHADER_CRTPI_H}" "${SHADER_UPSCALE_H}" "${SHADER_DOWNSCALE_H}")
|
||||
|
||||
if(GLSLC_EXE)
|
||||
add_custom_command(
|
||||
OUTPUT ${ALL_SHADER_HEADERS}
|
||||
COMMAND "${CMAKE_SOURCE_DIR}/tools/shaders/compile_spirv.sh"
|
||||
DEPENDS ${ALL_SHADER_SOURCES}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
COMMENT "Compilando shaders SPIR-V..."
|
||||
)
|
||||
set(COMPILE_SHADER_SCRIPT "${CMAKE_SOURCE_DIR}/tools/shaders/compile_shader.cmake")
|
||||
|
||||
macro(add_shader SRC_FILE OUT_H VAR_NAME)
|
||||
cmake_parse_arguments(S "" "STAGE" "" ${ARGN})
|
||||
add_custom_command(
|
||||
OUTPUT "${OUT_H}"
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-DGLSLC=${GLSLC_EXE}"
|
||||
"-DSRC=${SRC_FILE}"
|
||||
"-DOUT_H=${OUT_H}"
|
||||
"-DVAR=${VAR_NAME}"
|
||||
"-DSTAGE=${S_STAGE}"
|
||||
-P "${COMPILE_SHADER_SCRIPT}"
|
||||
DEPENDS "${SRC_FILE}" "${COMPILE_SHADER_SCRIPT}"
|
||||
COMMENT "Compilando shader: ${VAR_NAME}"
|
||||
)
|
||||
endmacro()
|
||||
|
||||
add_shader("${SHADER_VERT_SRC}" "${SHADER_VERT_H}" "postfx_vert_spv")
|
||||
add_shader("${SHADER_FRAG_SRC}" "${SHADER_FRAG_H}" "postfx_frag_spv")
|
||||
add_shader("${SHADER_CRTPI_SRC}" "${SHADER_CRTPI_H}" "crtpi_frag_spv" STAGE fragment)
|
||||
add_shader("${SHADER_UPSCALE_SRC}" "${SHADER_UPSCALE_H}" "upscale_frag_spv")
|
||||
add_shader("${SHADER_DOWNSCALE_SRC}" "${SHADER_DOWNSCALE_H}" "downscale_frag_spv")
|
||||
|
||||
add_custom_target(shaders DEPENDS ${ALL_SHADER_HEADERS})
|
||||
message(STATUS "glslc encontrado: shaders se compilarán automáticamente")
|
||||
else()
|
||||
|
||||
8
Makefile
8
Makefile
@@ -8,7 +8,11 @@ DIR_TOOLS := $(addsuffix /, $(DIR_ROOT)tools)
|
||||
# TARGET NAMES
|
||||
# ==============================================================================
|
||||
TARGET_NAME := coffee_crisis_arcade_edition
|
||||
TARGET_FILE := $(DIR_ROOT)$(TARGET_NAME)
|
||||
ifeq ($(OS),Windows_NT)
|
||||
TARGET_FILE := $(DIR_ROOT)$(TARGET_NAME).exe
|
||||
else
|
||||
TARGET_FILE := $(DIR_ROOT)$(TARGET_NAME)
|
||||
endif
|
||||
APP_NAME := Coffee Crisis Arcade Edition
|
||||
DIST_DIR := dist
|
||||
RELEASE_FOLDER := dist/_tmp
|
||||
@@ -138,7 +142,7 @@ windows_release:
|
||||
@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\"'"
|
||||
@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
|
||||
|
||||
57
tools/shaders/compile_shader.cmake
Normal file
57
tools/shaders/compile_shader.cmake
Normal file
@@ -0,0 +1,57 @@
|
||||
# compile_shader.cmake
|
||||
# Compila un shader GLSL a header C++ embebible con datos SPIR-V.
|
||||
# Funciona en Windows, Linux y macOS sin bash ni herramientas Unix.
|
||||
#
|
||||
# Variables requeridas (pasar con -D al invocar cmake -P):
|
||||
# GLSLC - ruta al ejecutable glslc
|
||||
# SRC - archivo fuente GLSL
|
||||
# OUT_H - archivo header de salida
|
||||
# VAR - nombre base de la variable C++ (e.g. "postfx_vert_spv")
|
||||
# STAGE - (opcional) stage explícito para glslc (e.g. "fragment")
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
get_filename_component(SRC_NAME "${SRC}" NAME_WE)
|
||||
get_filename_component(OUT_DIR "${OUT_H}" DIRECTORY)
|
||||
set(OUT_SPV "${OUT_DIR}/${SRC_NAME}.spv")
|
||||
|
||||
# Compilar GLSL → SPIR-V
|
||||
if(DEFINED STAGE AND NOT STAGE STREQUAL "")
|
||||
execute_process(
|
||||
COMMAND "${GLSLC}" "-fshader-stage=${STAGE}" "${SRC}" -o "${OUT_SPV}"
|
||||
RESULT_VARIABLE RESULT
|
||||
ERROR_VARIABLE ERROR_MSG
|
||||
)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND "${GLSLC}" "${SRC}" -o "${OUT_SPV}"
|
||||
RESULT_VARIABLE RESULT
|
||||
ERROR_VARIABLE ERROR_MSG
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "glslc falló compilando ${SRC}:\n${ERROR_MSG}")
|
||||
endif()
|
||||
|
||||
# Leer binario SPIR-V como cadena hexadecimal
|
||||
file(READ "${OUT_SPV}" SPV_HEX HEX)
|
||||
file(REMOVE "${OUT_SPV}")
|
||||
|
||||
string(LENGTH "${SPV_HEX}" HEX_LEN)
|
||||
math(EXPR BYTE_COUNT "${HEX_LEN} / 2")
|
||||
|
||||
# Convertir a array C++ con formato " 0xXX,\n" por byte
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])" " 0x\\1,\n" SPV_BYTES "${SPV_HEX}")
|
||||
# Eliminar la última coma y sustituir por el "}" de cierre
|
||||
string(REGEX REPLACE ",\n$" "}" SPV_BYTES "${SPV_BYTES}")
|
||||
|
||||
# Escribir el header
|
||||
file(WRITE "${OUT_H}"
|
||||
"#pragma once\n"
|
||||
"#include <cstddef>\n"
|
||||
"#include <cstdint>\n"
|
||||
"static const uint8_t k${VAR}[] = {\n"
|
||||
"${SPV_BYTES};\n"
|
||||
"static const size_t k${VAR}_size = ${BYTE_COUNT};\n"
|
||||
)
|
||||
Reference in New Issue
Block a user