binari i recursos a build/, targets en kebab
This commit is contained in:
@@ -300,11 +300,6 @@ elseif(UNIX AND NOT APPLE)
|
|||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD)
|
target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Especificar la ubicación del ejecutable (en desktop; a wasm queda a build/wasm/)
|
|
||||||
if(NOT EMSCRIPTEN)
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- 5. STATIC ANALYSIS TARGETS ---
|
# --- 5. STATIC ANALYSIS TARGETS ---
|
||||||
|
|
||||||
# Buscar herramientas de análisis estático
|
# Buscar herramientas de análisis estático
|
||||||
@@ -408,7 +403,7 @@ if(NOT EMSCRIPTEN)
|
|||||||
|
|
||||||
# Regeneració automàtica de resources.pack en cada build si canvia data/.
|
# Regeneració automàtica de resources.pack en cada build si canvia data/.
|
||||||
file(GLOB_RECURSE DATA_FILES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/data/*")
|
file(GLOB_RECURSE DATA_FILES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/data/*")
|
||||||
set(RESOURCE_PACK "${CMAKE_SOURCE_DIR}/resources.pack")
|
set(RESOURCE_PACK "${CMAKE_BINARY_DIR}/resources.pack")
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${RESOURCE_PACK}
|
OUTPUT ${RESOURCE_PACK}
|
||||||
@@ -423,4 +418,24 @@ if(NOT EMSCRIPTEN)
|
|||||||
|
|
||||||
add_custom_target(resource_pack ALL DEPENDS ${RESOURCE_PACK})
|
add_custom_target(resource_pack ALL DEPENDS ${RESOURCE_PACK})
|
||||||
add_dependencies(${PROJECT_NAME} resource_pack)
|
add_dependencies(${PROJECT_NAME} resource_pack)
|
||||||
|
|
||||||
|
# --- CÒPIA DE gamecontrollerdb.txt AL COSTAT DEL BINARI ---
|
||||||
|
# SDL_AddGamepadMappingsFromFile només llegeix del filesystem real (no del
|
||||||
|
# pack), així que el fitxer ha de viure al directori del binari. Es copia
|
||||||
|
# només si existeix per no fallar la build d'algú que encara no ha fet
|
||||||
|
# `make controllerdb`.
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt")
|
||||||
|
set(CONTROLLER_DB "${CMAKE_BINARY_DIR}/gamecontrollerdb.txt")
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CONTROLLER_DB}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt"
|
||||||
|
"${CONTROLLER_DB}"
|
||||||
|
DEPENDS "${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt"
|
||||||
|
COMMENT "Copiant gamecontrollerdb.txt → build/"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
add_custom_target(controller_db ALL DEPENDS ${CONTROLLER_DB})
|
||||||
|
add_dependencies(${PROJECT_NAME} controller_db)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
77
Makefile
77
Makefile
@@ -3,13 +3,13 @@
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
||||||
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source)
|
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source)
|
||||||
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
BUILDDIR := build
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# TARGET NAMES
|
# TARGET NAMES
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
TARGET_NAME := jaildoctors_dilemma
|
TARGET_NAME := jaildoctors_dilemma
|
||||||
TARGET_FILE := $(DIR_BIN)$(TARGET_NAME)
|
TARGET_FILE := $(BUILDDIR)/$(TARGET_NAME)
|
||||||
APP_NAME := JailDoctor's Dilemma
|
APP_NAME := JailDoctor's Dilemma
|
||||||
DIST_DIR := dist
|
DIST_DIR := dist
|
||||||
RELEASE_FOLDER := dist/_tmp
|
RELEASE_FOLDER := dist/_tmp
|
||||||
@@ -63,7 +63,7 @@ endif
|
|||||||
# WINDOWS-SPECIFIC VARIABLES
|
# WINDOWS-SPECIFIC VARIABLES
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
WIN_TARGET_FILE := $(DIR_BIN)$(APP_NAME)
|
WIN_TARGET_FILE := $(BUILDDIR)/$(APP_NAME)
|
||||||
WIN_RELEASE_FILE := $(RELEASE_FOLDER)/$(APP_NAME)
|
WIN_RELEASE_FILE := $(RELEASE_FOLDER)/$(APP_NAME)
|
||||||
WIN_RELEASE_FILE_PS := $(subst ','',$(WIN_RELEASE_FILE))
|
WIN_RELEASE_FILE_PS := $(subst ','',$(WIN_RELEASE_FILE))
|
||||||
else
|
else
|
||||||
@@ -134,24 +134,35 @@ debug:
|
|||||||
@cmake $(CMAKE_GEN) -S . -B build -DCMAKE_BUILD_TYPE=Debug -DGIT_HASH=$(GIT_HASH)
|
@cmake $(CMAKE_GEN) -S . -B build -DCMAKE_BUILD_TYPE=Debug -DGIT_HASH=$(GIT_HASH)
|
||||||
@cmake --build build
|
@cmake --build build
|
||||||
|
|
||||||
|
run: all
|
||||||
|
@./$(TARGET_FILE)
|
||||||
|
|
||||||
|
run-debug: debug
|
||||||
|
@./$(TARGET_FILE)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -rf $(BUILDDIR)
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# RELEASE AUTOMÁTICO (detecta SO)
|
# RELEASE AUTOMÁTICO (detecta SO)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
release:
|
release:
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
@"$(MAKE)" _windows_release
|
@"$(MAKE)" _windows-release
|
||||||
else
|
else
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
@$(MAKE) _macos_release
|
@$(MAKE) _macos-release
|
||||||
else
|
else
|
||||||
@$(MAKE) _linux_release
|
@$(MAKE) _linux-release
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# REGLAS PARA COMPILACIÓN DE SHADERS (multiplataforma via cmake)
|
# REGLAS PARA COMPILACIÓN DE SHADERS (multiplataforma via cmake)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
compile_shaders:
|
compile-shaders:
|
||||||
ifdef GLSLC
|
ifdef GLSLC
|
||||||
@cmake -D GLSLC=$(GLSLC) -D SHADERS_DIR=$(SHADERS_DIR) -D HEADERS_DIR=$(HEADERS_DIR) -P $(SHADER_CMAKE)
|
@cmake -D GLSLC=$(GLSLC) -D SHADERS_DIR=$(SHADERS_DIR) -D HEADERS_DIR=$(HEADERS_DIR) -P $(SHADER_CMAKE)
|
||||||
else
|
else
|
||||||
@@ -164,12 +175,12 @@ endif
|
|||||||
pack:
|
pack:
|
||||||
@cmake $(CMAKE_GEN) -S . -B build -DCMAKE_BUILD_TYPE=Release -DGIT_HASH=$(GIT_HASH)
|
@cmake $(CMAKE_GEN) -S . -B build -DCMAKE_BUILD_TYPE=Release -DGIT_HASH=$(GIT_HASH)
|
||||||
@cmake --build build --target pack_resources
|
@cmake --build build --target pack_resources
|
||||||
@./build/pack_resources data resources.pack
|
@./build/pack_resources data build/resources.pack
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# COMPILACIÓN PARA WINDOWS (RELEASE)
|
# COMPILACIÓN PARA WINDOWS (RELEASE)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
_windows_release:
|
_windows-release:
|
||||||
@echo off
|
@echo off
|
||||||
@echo Creando release para Windows - Version: $(VERSION)
|
@echo Creando release para Windows - Version: $(VERSION)
|
||||||
|
|
||||||
@@ -183,7 +194,7 @@ _windows_release:
|
|||||||
@powershell -Command "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 ficheros
|
# Copia ficheros
|
||||||
@powershell -Command "Copy-Item -Path 'resources.pack' -Destination '$(RELEASE_FOLDER)'"
|
@powershell -Command "Copy-Item -Path 'build/resources.pack' -Destination '$(RELEASE_FOLDER)'"
|
||||||
@powershell -Command "Copy-Item 'LICENSE' -Destination '$(RELEASE_FOLDER)'"
|
@powershell -Command "Copy-Item 'LICENSE' -Destination '$(RELEASE_FOLDER)'"
|
||||||
@powershell -Command "Copy-Item 'README.md' -Destination '$(RELEASE_FOLDER)'"
|
@powershell -Command "Copy-Item 'README.md' -Destination '$(RELEASE_FOLDER)'"
|
||||||
@powershell -Command "Copy-Item 'gamecontrollerdb.txt' -Destination '$(RELEASE_FOLDER)'"
|
@powershell -Command "Copy-Item 'gamecontrollerdb.txt' -Destination '$(RELEASE_FOLDER)'"
|
||||||
@@ -202,7 +213,7 @@ _windows_release:
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# COMPILACIÓN PARA MACOS (RELEASE)
|
# COMPILACIÓN PARA MACOS (RELEASE)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
_macos_release:
|
_macos-release:
|
||||||
@echo "Creando release para macOS - Version: $(VERSION)"
|
@echo "Creando release para macOS - Version: $(VERSION)"
|
||||||
|
|
||||||
# Verifica dependencias necesarias (create-dmg). Si falta, intenta instalarla
|
# Verifica dependencias necesarias (create-dmg). Si falta, intenta instalarla
|
||||||
@@ -265,7 +276,7 @@ _macos_release:
|
|||||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
|
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
|
||||||
-DMACOS_BUNDLE=ON -DGIT_HASH=$(GIT_HASH) \
|
-DMACOS_BUNDLE=ON -DGIT_HASH=$(GIT_HASH) \
|
||||||
&& cmake --build build/intel; then \
|
&& cmake --build build/intel; then \
|
||||||
cp resources.pack "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"; \
|
cp build/resources.pack "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"; \
|
||||||
cp "$(TARGET_FILE)" "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)"; \
|
cp "$(TARGET_FILE)" "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)"; \
|
||||||
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"; \
|
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"; \
|
||||||
echo "Creando DMG Intel con iconos de 96x96..."; \
|
echo "Creando DMG Intel con iconos de 96x96..."; \
|
||||||
@@ -300,7 +311,7 @@ _macos_release:
|
|||||||
@echo "============================================"
|
@echo "============================================"
|
||||||
@cmake -S . -B build/arm -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DMACOS_BUNDLE=ON -DGIT_HASH=$(GIT_HASH)
|
@cmake -S . -B build/arm -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DMACOS_BUNDLE=ON -DGIT_HASH=$(GIT_HASH)
|
||||||
@cmake --build build/arm
|
@cmake --build build/arm
|
||||||
cp resources.pack "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
cp build/resources.pack "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||||
cp "$(TARGET_FILE)" "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)"
|
cp "$(TARGET_FILE)" "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)"
|
||||||
|
|
||||||
# Firma la aplicación
|
# Firma la aplicación
|
||||||
@@ -332,7 +343,7 @@ _macos_release:
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# COMPILACIÓN PARA LINUX (RELEASE)
|
# COMPILACIÓN PARA LINUX (RELEASE)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
_linux_release:
|
_linux-release:
|
||||||
@echo "Creando release para Linux - Version: $(VERSION)"
|
@echo "Creando release para Linux - Version: $(VERSION)"
|
||||||
|
|
||||||
# Compila con cmake (genera shaders, resources.pack y ejecutable)
|
# Compila con cmake (genera shaders, resources.pack y ejecutable)
|
||||||
@@ -344,7 +355,7 @@ _linux_release:
|
|||||||
$(MKDIR) "$(RELEASE_FOLDER)"
|
$(MKDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Copia ficheros
|
# Copia ficheros
|
||||||
cp resources.pack "$(RELEASE_FOLDER)"
|
cp build/resources.pack "$(RELEASE_FOLDER)"
|
||||||
cp LICENSE "$(RELEASE_FOLDER)"
|
cp LICENSE "$(RELEASE_FOLDER)"
|
||||||
cp README.md "$(RELEASE_FOLDER)"
|
cp README.md "$(RELEASE_FOLDER)"
|
||||||
cp gamecontrollerdb.txt "$(RELEASE_FOLDER)"
|
cp gamecontrollerdb.txt "$(RELEASE_FOLDER)"
|
||||||
@@ -382,20 +393,20 @@ wasm:
|
|||||||
@echo "Deployed to maverick"
|
@echo "Deployed to maverick"
|
||||||
|
|
||||||
# Versió Debug del build wasm: arrenca directament a la GAME (sense logo/loading/title)
|
# Versió Debug del build wasm: arrenca directament a la GAME (sense logo/loading/title)
|
||||||
# i activa l'editor i la consola. Sortida a dist/wasm_debug/.
|
# i activa l'editor i la consola. Sortida a dist/wasm-debug/.
|
||||||
wasm_debug:
|
wasm-debug:
|
||||||
@echo "Compilando WebAssembly Debug - Version: $(VERSION)"
|
@echo "Compilando WebAssembly Debug - Version: $(VERSION)"
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v $(DIR_ROOT):/src \
|
-v $(DIR_ROOT):/src \
|
||||||
-w /src \
|
-w /src \
|
||||||
emscripten/emsdk:latest \
|
emscripten/emsdk:latest \
|
||||||
bash -c "emcmake cmake -S . -B build/wasm_debug -DCMAKE_BUILD_TYPE=Debug -DGIT_HASH=$(GIT_HASH) && cmake --build build/wasm_debug"
|
bash -c "emcmake cmake -S . -B build/wasm-debug -DCMAKE_BUILD_TYPE=Debug -DGIT_HASH=$(GIT_HASH) && cmake --build build/wasm-debug"
|
||||||
$(MKDIR) "$(DIST_DIR)/wasm_debug"
|
$(MKDIR) "$(DIST_DIR)/wasm-debug"
|
||||||
cp build/wasm_debug/$(TARGET_NAME).html $(DIST_DIR)/wasm_debug/
|
cp build/wasm-debug/$(TARGET_NAME).html $(DIST_DIR)/wasm-debug/
|
||||||
cp build/wasm_debug/$(TARGET_NAME).js $(DIST_DIR)/wasm_debug/
|
cp build/wasm-debug/$(TARGET_NAME).js $(DIST_DIR)/wasm-debug/
|
||||||
cp build/wasm_debug/$(TARGET_NAME).wasm $(DIST_DIR)/wasm_debug/
|
cp build/wasm-debug/$(TARGET_NAME).wasm $(DIST_DIR)/wasm-debug/
|
||||||
cp build/wasm_debug/$(TARGET_NAME).data $(DIST_DIR)/wasm_debug/
|
cp build/wasm-debug/$(TARGET_NAME).data $(DIST_DIR)/wasm-debug/
|
||||||
@echo "Output: $(DIST_DIR)/wasm_debug/"
|
@echo "Output: $(DIST_DIR)/wasm-debug/"
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -433,7 +444,7 @@ controllerdb:
|
|||||||
# REGLAS ESPECIALES
|
# REGLAS ESPECIALES
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Regla para mostrar la versión actual
|
# Regla para mostrar la versión actual
|
||||||
show_version:
|
show-version:
|
||||||
@echo "Version actual: $(VERSION)"
|
@echo "Version actual: $(VERSION)"
|
||||||
|
|
||||||
# Regla de ayuda
|
# Regla de ayuda
|
||||||
@@ -445,14 +456,18 @@ help:
|
|||||||
@echo " make - Compilar con cmake (Release)"
|
@echo " make - Compilar con cmake (Release)"
|
||||||
@echo " make debug - Compilar con cmake (Debug)"
|
@echo " make debug - Compilar con cmake (Debug)"
|
||||||
@echo ""
|
@echo ""
|
||||||
|
@echo " Ejecucion:"
|
||||||
|
@echo " make run - Compilar (Release) y ejecutar"
|
||||||
|
@echo " make run-debug - Compilar (Debug) y ejecutar"
|
||||||
|
@echo ""
|
||||||
@echo " Release:"
|
@echo " Release:"
|
||||||
@echo " make release - Crear release (detecta SO automaticamente)"
|
@echo " make release - Crear release (detecta SO automaticamente)"
|
||||||
@echo " make wasm - Crear release per a WebAssembly (requereix Docker)"
|
@echo " make wasm - Crear release per a WebAssembly (requereix Docker)"
|
||||||
@echo " make wasm_debug - Crear build Debug per a WebAssembly (entra directe a la GAME)"
|
@echo " make wasm-debug - Crear build Debug per a WebAssembly (entra directe a la GAME)"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo " Herramientas:"
|
@echo " Herramientas:"
|
||||||
@echo " make compile_shaders - Compilar shaders SPIR-V"
|
@echo " make compile-shaders - Compilar shaders SPIR-V"
|
||||||
@echo " make pack - Empaquetar recursos a resources.pack"
|
@echo " make pack - Empaquetar recursos a $(BUILDDIR)/resources.pack"
|
||||||
@echo " make controllerdb - Descargar gamecontrollerdb.txt actualizado"
|
@echo " make controllerdb - Descargar gamecontrollerdb.txt actualizado"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo " Calidad de codigo:"
|
@echo " Calidad de codigo:"
|
||||||
@@ -463,7 +478,9 @@ help:
|
|||||||
@echo " make cppcheck - Analisis estatico con cppcheck"
|
@echo " make cppcheck - Analisis estatico con cppcheck"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo " Otros:"
|
@echo " Otros:"
|
||||||
@echo " make show_version - Mostrar version actual ($(VERSION))"
|
@echo " make clean - Borrar carpeta $(BUILDDIR)/"
|
||||||
|
@echo " make rebuild - clean + all"
|
||||||
|
@echo " make show-version - Mostrar version actual ($(VERSION))"
|
||||||
@echo " make help - Mostrar esta ayuda"
|
@echo " make help - Mostrar esta ayuda"
|
||||||
|
|
||||||
.PHONY: all debug release _windows_release _macos_release _linux_release wasm wasm_debug compile_shaders pack controllerdb format format-check tidy tidy-fix cppcheck show_version help
|
.PHONY: all debug run run-debug clean rebuild release _windows-release _macos-release _linux-release wasm wasm-debug compile-shaders pack controllerdb format format-check tidy tidy-fix cppcheck show-version help
|
||||||
|
|||||||
Reference in New Issue
Block a user