Simplifica Makefile a 3 targets delegats a CMake amb release a dist/
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -36,7 +36,7 @@ third_party/**/CMakeFiles/
|
||||
third_party/**/CMakeCache.txt
|
||||
|
||||
# Release artifacts
|
||||
shadertoy_release/
|
||||
dist/
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.dmg
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(shadertoy VERSION 1.00)
|
||||
|
||||
# Establecer estándar de C++
|
||||
# Estàndard de C++
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Establece la política CMP0072 para indicar cómo se debe seleccionar la implementación de OpenGL.
|
||||
# En este caso, se elige la opción "GLVND", que utiliza bibliotecas modernas y modulares (libOpenGL, libGLX),
|
||||
# en lugar de la biblioteca OpenGL clásica (libGL). Esto mejora la compatibilidad con drivers recientes
|
||||
# y evita ambigüedades cuando se encuentran múltiples implementaciones de OpenGL en el sistema.
|
||||
# Política CMP0072: usar GLVND (libOpenGL/libGLX) en lloc de la libGL clàssica.
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
|
||||
# Opció per a empaquetat de bundle macOS (.app). El Makefile la passa amb -DMACOS_BUNDLE=ON.
|
||||
option(MACOS_BUNDLE "Build for macOS .app bundle (rpath into ../Frameworks)" OFF)
|
||||
|
||||
# --- LISTA EXPLÍCITA DE FUENTES ---
|
||||
set(APP_SOURCES
|
||||
source/main.cpp
|
||||
@@ -29,15 +29,17 @@ set(EXTERNAL_SOURCES
|
||||
source/external/stb_vorbis_impl.cpp
|
||||
)
|
||||
|
||||
# Configuración de SDL3
|
||||
# Configuració de SDL3
|
||||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
||||
message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
|
||||
message(STATUS "SDL3 trobat: ${SDL3_INCLUDE_DIRS}")
|
||||
|
||||
# --- COMPILACIÓN DE SHADERS (Vulkan SPIR-V) ---
|
||||
# --- COMPILACIÓ DE SHADERS (Vulkan SPIR-V) ---
|
||||
# Es fa a cada build: compile_shaders.cmake fa check de timestamps, no
|
||||
# recompila el que ja està al dia.
|
||||
find_program(GLSLC_EXE NAMES glslc)
|
||||
if(GLSLC_EXE)
|
||||
message(STATUS "glslc encontrado: ${GLSLC_EXE}")
|
||||
add_custom_target(compile_shaders
|
||||
message(STATUS "glslc trobat: ${GLSLC_EXE}")
|
||||
add_custom_target(compile_shaders ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D GLSLC=${GLSLC_EXE}
|
||||
-D SHADERS_DIR=${CMAKE_SOURCE_DIR}/data/shaders
|
||||
@@ -45,7 +47,19 @@ if(GLSLC_EXE)
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Compiling .vk.glsl shaders to SPIR-V")
|
||||
else()
|
||||
message(STATUS "glslc no encontrado — el target compile_shaders no estará disponible")
|
||||
message(STATUS "glslc no trobat — el target compile_shaders no estarà disponible")
|
||||
endif()
|
||||
|
||||
# --- RECURSO DE WINDOWS (icona) ---
|
||||
# A Windows compilem release/windows/shadertoy.rc amb windres via CMake.
|
||||
# El .rc fa referència a icon.ico per nom; afegim --include-dir perquè el
|
||||
# trobi a release/icons/.
|
||||
if(WIN32)
|
||||
enable_language(RC)
|
||||
set(WIN_RC_FILE ${CMAKE_SOURCE_DIR}/release/windows/shadertoy.rc)
|
||||
set_source_files_properties(${WIN_RC_FILE} PROPERTIES
|
||||
COMPILE_FLAGS "--include-dir=${CMAKE_SOURCE_DIR}/release/icons")
|
||||
list(APPEND APP_SOURCES ${WIN_RC_FILE})
|
||||
endif()
|
||||
|
||||
# --- AÑADIR EJECUTABLE ---
|
||||
@@ -58,41 +72,49 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/source/external"
|
||||
)
|
||||
|
||||
# Enlazar la librería SDL3
|
||||
# Enllaçar la llibreria SDL3
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3)
|
||||
|
||||
|
||||
# --- CONFIGURACIÓN PLATAFORMAS Y COMPILADOR ---
|
||||
# Configuración de flags de compilación
|
||||
# --- CONFIGURACIÓ PLATAFORMES I COMPILADOR ---
|
||||
# Flags de compilació
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>)
|
||||
|
||||
# Definir _DEBUG en modo Debug
|
||||
# Definir _DEBUG en mode Debug
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:DEBUG>:_DEBUG>)
|
||||
|
||||
|
||||
# Configuración específica para cada plataforma
|
||||
# Configuració específica per a cada plataforma
|
||||
if(WIN32)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE WINDOWS_BUILD)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ws2_32 mingw32 opengl32)
|
||||
elseif(APPLE)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUILD)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-deprecated)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||
if(NOT CMAKE_OSX_ARCHITECTURES)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||
endif()
|
||||
if(MACOS_BUNDLE)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUNDLE)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE
|
||||
-rpath @executable_path/../Frameworks/
|
||||
)
|
||||
endif()
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD)
|
||||
endif()
|
||||
|
||||
# Configuración común para OpenGL
|
||||
# Configuració comuna per a OpenGL
|
||||
if(NOT WIN32)
|
||||
find_package(OpenGL REQUIRED)
|
||||
if(OPENGL_FOUND)
|
||||
message(STATUS "OpenGL encontrado: ${OPENGL_LIBRARIES}")
|
||||
message(STATUS "OpenGL trobat: ${OPENGL_LIBRARIES}")
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${OPENGL_LIBRARIES})
|
||||
else()
|
||||
message(FATAL_ERROR "OpenGL no encontrado")
|
||||
message(FATAL_ERROR "OpenGL no trobat")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Especificar la ubicación del ejecutable en la raíz del proyecto
|
||||
# El binari surt a l'arrel del projecte (com fins ara).
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
413
Makefile
413
Makefile
@@ -1,264 +1,189 @@
|
||||
# Directorios
|
||||
DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
||||
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source)
|
||||
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
||||
DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build)
|
||||
# ==============================================================================
|
||||
# Makefile per a Shadertoy
|
||||
#
|
||||
# Tres targets:
|
||||
# make → Release (cmake)
|
||||
# make debug → Debug (cmake)
|
||||
# make release → Release + empaquetat per a distribució a dist/
|
||||
#
|
||||
# El SO es detecta automàticament. La compilació sempre passa per CMake.
|
||||
# ==============================================================================
|
||||
|
||||
# Variables
|
||||
TARGET_NAME := shadertoy
|
||||
TARGET_FILE := $(DIR_BIN)$(TARGET_NAME)
|
||||
APP_NAME := Shadertoy
|
||||
RELEASE_FOLDER := shadertoy_release
|
||||
RESOURCE_FILE := release/windows/shadertoy.res
|
||||
PROJECT := shadertoy
|
||||
APP_NAME := Shadertoy
|
||||
DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
||||
BUILDDIR := build
|
||||
DIST_DIR := dist
|
||||
RELEASE_FOLDER := $(DIST_DIR)/_tmp
|
||||
|
||||
# Versión automática basada en la fecha actual (formato YYYY.MM.DD para que
|
||||
# CFBundleShortVersionString del bundle macOS sea conforme a la spec de Apple).
|
||||
# ==============================================================================
|
||||
# DETECCIÓ DE PLATAFORMA + GENERADOR CMAKE + JOBS
|
||||
# ==============================================================================
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# MSYS2/Git Bash usa /dev/null, cmd.exe pur usa NUL.
|
||||
ifneq ($(MSYSTEM),)
|
||||
NULDEV := /dev/null
|
||||
else
|
||||
NULDEV := NUL
|
||||
endif
|
||||
JOBS ?= $(NUMBER_OF_PROCESSORS)
|
||||
HAS_NINJA := $(shell ninja --version 2>$(NULDEV))
|
||||
ifneq ($(HAS_NINJA),)
|
||||
CMAKE_GEN := -G "Ninja"
|
||||
else
|
||||
CMAKE_GEN := -G "MinGW Makefiles"
|
||||
endif
|
||||
UNAME_S := Windows
|
||||
SHELL := cmd.exe
|
||||
else
|
||||
NULDEV := /dev/null
|
||||
JOBS ?= $(shell nproc 2>/dev/null || echo 4)
|
||||
CMAKE_GEN :=
|
||||
UNAME_S := $(shell uname -s)
|
||||
endif
|
||||
|
||||
# ==============================================================================
|
||||
# VERSIÓ (data, format YYYY.MM.DD)
|
||||
# ==============================================================================
|
||||
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)
|
||||
# ==============================================================================
|
||||
# NOMS DELS ARTEFACTES DE RELEASE
|
||||
# ==============================================================================
|
||||
WINDOWS_RELEASE := $(DIST_DIR)/$(PROJECT)-$(VERSION)-win32-x64.zip
|
||||
MACOS_APPLE_SILICON_RELEASE := $(DIST_DIR)/$(PROJECT)-$(VERSION)-macos-apple-silicon.dmg
|
||||
LINUX_RELEASE := $(DIST_DIR)/$(PROJECT)-$(VERSION)-linux.tar.gz
|
||||
|
||||
.PHONY: all debug release clean help _windows_release _macos_release _linux_release
|
||||
|
||||
# ==============================================================================
|
||||
# COMPILACIÓ (delegada a CMake)
|
||||
# ==============================================================================
|
||||
all:
|
||||
@cmake $(CMAKE_GEN) -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release
|
||||
@cmake --build $(BUILDDIR) -j$(JOBS)
|
||||
|
||||
debug:
|
||||
@cmake $(CMAKE_GEN) -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Debug
|
||||
@cmake --build $(BUILDDIR) -j$(JOBS)
|
||||
|
||||
# ==============================================================================
|
||||
# RELEASE (auto-dispatch per SO)
|
||||
# ==============================================================================
|
||||
release:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
WIN_TARGET_FILE := $(DIR_BIN)$(APP_NAME)
|
||||
WIN_RELEASE_FILE := $(RELEASE_FOLDER)/$(APP_NAME)
|
||||
@"$(MAKE)" _windows_release
|
||||
else
|
||||
WIN_TARGET_FILE := $(TARGET_FILE)
|
||||
WIN_RELEASE_FILE := $(RELEASE_FOLDER)/$(TARGET_NAME)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
@$(MAKE) _macos_release
|
||||
else
|
||||
@$(MAKE) _linux_release
|
||||
endif
|
||||
endif
|
||||
|
||||
# Nombres para los ficheros de lanzamiento
|
||||
WINDOWS_RELEASE := $(TARGET_NAME)-$(VERSION)-win32-x64.zip
|
||||
MACOS_APPLE_SILICON_RELEASE := $(TARGET_NAME)-$(VERSION)-macos-apple-silicon.dmg
|
||||
LINUX_RELEASE := $(TARGET_NAME)-$(VERSION)-linux.tar.gz
|
||||
clean:
|
||||
@rm -rf $(BUILDDIR) $(DIST_DIR)
|
||||
|
||||
# Lista completa de archivos fuente
|
||||
APP_SOURCES := \
|
||||
source/main.cpp \
|
||||
source/rendering/shader_backend.cpp \
|
||||
source/rendering/opengl_shader_backend.cpp \
|
||||
source/rendering/sdl3gpu/sdl3gpu_shader_backend.cpp \
|
||||
source/audio/jail_audio.cpp \
|
||||
source/external/glad/src/glad.c \
|
||||
source/external/stb_vorbis_impl.cpp
|
||||
# ==============================================================================
|
||||
# RELEASE LINUX
|
||||
# ==============================================================================
|
||||
_linux_release:
|
||||
@echo "Creant release per a Linux - Versió: $(VERSION)"
|
||||
@cmake $(CMAKE_GEN) -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release
|
||||
@cmake --build $(BUILDDIR) -j$(JOBS)
|
||||
@mkdir -p $(DIST_DIR)
|
||||
@rm -rf $(RELEASE_FOLDER)
|
||||
@mkdir -p $(RELEASE_FOLDER)
|
||||
@cp -R data $(RELEASE_FOLDER)/
|
||||
@cp LICENSE $(RELEASE_FOLDER)/
|
||||
@cp README.md $(RELEASE_FOLDER)/
|
||||
@cp $(PROJECT) $(RELEASE_FOLDER)/
|
||||
@strip -s -R .comment -R .gnu.version $(RELEASE_FOLDER)/$(PROJECT) --strip-unneeded
|
||||
@rm -f $(LINUX_RELEASE)
|
||||
@tar -czf $(LINUX_RELEASE) -C $(RELEASE_FOLDER) .
|
||||
@echo "Release creat: $(LINUX_RELEASE)"
|
||||
@rm -rf $(RELEASE_FOLDER)
|
||||
|
||||
# Includes
|
||||
INCLUDES := -Isource -Isource/external/glad/include -Isource/external
|
||||
|
||||
# Variables según el sistema operativo
|
||||
ifeq ($(OS),Windows_NT)
|
||||
FixPath = $(subst /,\\,$1)
|
||||
CXXFLAGS := -std=c++17 -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++17 -Wall -g -D_DEBUG -DWINDOWS_BUILD
|
||||
LDFLAGS := -lmingw32 -lws2_32 -lSDL3 -lopengl32
|
||||
RM := del /Q
|
||||
MKDIR := mkdir
|
||||
else
|
||||
FixPath = $1
|
||||
CXXFLAGS := -std=c++17 -Wall -Os -ffunction-sections -fdata-sections
|
||||
CXXFLAGS_DEBUG := -std=c++17 -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
|
||||
LDFLAGS += -lGL
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
CXXFLAGS += -Wno-deprecated -DMACOS_BUILD
|
||||
CXXFLAGS_DEBUG += -Wno-deprecated -DMACOS_BUILD
|
||||
LDFLAGS += -framework OpenGL
|
||||
# Configurar arquitectura (por defecto arm64, como en CMake)
|
||||
CXXFLAGS += -arch arm64
|
||||
CXXFLAGS_DEBUG += -arch arm64
|
||||
endif
|
||||
endif
|
||||
|
||||
# Reglas para compilación
|
||||
windows:
|
||||
@echo off
|
||||
@echo Compilando para Windows con nombre: "$(APP_NAME).exe"
|
||||
windres release/windows/shadertoy.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
|
||||
|
||||
windows_debug:
|
||||
@echo off
|
||||
@echo Compilando version debug para Windows: "$(APP_NAME)_debug.exe"
|
||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(WIN_TARGET_FILE)_debug.exe"
|
||||
|
||||
windows_release:
|
||||
@echo off
|
||||
@echo Creando release para Windows - Version: $(VERSION)
|
||||
|
||||
# Crea carpeta temporal 'RELEASE_FOLDER'
|
||||
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}
|
||||
|
||||
# Copia la carpeta 'data' (que ahora contiene shaders y music)
|
||||
powershell Copy-Item -Path "data" -Destination "$(RELEASE_FOLDER)" -recurse -Force
|
||||
|
||||
# Copia los ficheros que están 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 el recurso de icono
|
||||
@windres release/windows/shadertoy.rc -O coff -o $(RESOURCE_FILE)
|
||||
|
||||
# Compila
|
||||
$(CXX) $(APP_SOURCES) $(RESOURCE_FILE) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(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)"
|
||||
@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 $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||
|
||||
macos_release:
|
||||
@echo "Creando release para macOS - Version: $(VERSION)"
|
||||
|
||||
# Verifica dependencias necesarias (create-dmg). Si falta, intenta instalarla
|
||||
# con brew; si brew tampoco está, indica el comando exacto al usuario.
|
||||
# ==============================================================================
|
||||
# RELEASE MACOS (Apple Silicon, .dmg amb .app bundle)
|
||||
# ==============================================================================
|
||||
_macos_release:
|
||||
@echo "Creant release per a macOS - Versió: $(VERSION)"
|
||||
@command -v create-dmg >/dev/null 2>&1 || { \
|
||||
echo ""; \
|
||||
echo "============================================"; \
|
||||
echo " Falta la dependencia: create-dmg"; \
|
||||
echo "============================================"; \
|
||||
if command -v brew >/dev/null 2>&1; then \
|
||||
echo " Instalando con: brew install create-dmg"; \
|
||||
brew install create-dmg || { \
|
||||
echo ""; \
|
||||
echo " ERROR: 'brew install create-dmg' ha fallado."; \
|
||||
echo " Ejecuta el comando manualmente y vuelve a probar."; \
|
||||
exit 1; \
|
||||
}; \
|
||||
else \
|
||||
echo " Homebrew no está instalado."; \
|
||||
echo " Instálalo desde https://brew.sh y luego ejecuta:"; \
|
||||
echo " brew install create-dmg"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo "Falta create-dmg. Instal·la amb: brew install create-dmg"; \
|
||||
exit 1; \
|
||||
}
|
||||
|
||||
# Elimina datos de compilaciones anteriores
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
$(RMFILE) tmp.dmg
|
||||
$(RMFILE) "$(MACOS_APPLE_SILICON_RELEASE)"
|
||||
|
||||
# Crea la carpeta temporal para hacer el trabajo y las carpetas obligatorias para crear una app de macos
|
||||
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks"
|
||||
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS"
|
||||
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||
|
||||
# Copia carpetas y ficheros
|
||||
cp -R data "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||
cp -R release/macos/frameworks/SDL3.xcframework "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks"
|
||||
cp release/icons/icon.icns "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||
cp release/macos/Info.plist "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents"
|
||||
cp LICENSE "$(RELEASE_FOLDER)"
|
||||
cp README.md "$(RELEASE_FOLDER)"
|
||||
|
||||
# Actualiza versión en Info.plist
|
||||
@echo "Actualizando Info.plist con versión $(VERSION)..."
|
||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release -DMACOS_BUNDLE=ON -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
|
||||
@cmake --build $(BUILDDIR) -j$(JOBS)
|
||||
@mkdir -p $(DIST_DIR)
|
||||
@rm -rf $(RELEASE_FOLDER)
|
||||
@rm -f tmp.dmg "$(MACOS_APPLE_SILICON_RELEASE)" $(DIST_DIR)/rw.*
|
||||
@mkdir -p "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks"
|
||||
@mkdir -p "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS"
|
||||
@mkdir -p "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||
@cp -R data "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources/"
|
||||
@cp -R release/macos/frameworks/SDL3.xcframework/macos-arm64_x86_64/SDL3.framework "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks/"
|
||||
@cp release/icons/icon.icns "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources/"
|
||||
@cp release/macos/Info.plist "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/"
|
||||
@cp $(PROJECT) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(PROJECT)"
|
||||
@cp LICENSE "$(RELEASE_FOLDER)/"
|
||||
@cp README.md "$(RELEASE_FOLDER)/"
|
||||
@RAW_VERSION=$$(echo "$(VERSION)" | sed 's/^v//'); \
|
||||
sed -i '' '/<key>CFBundleShortVersionString<\/key>/{n;s|<string>.*</string>|<string>'"$$RAW_VERSION"'</string>|;}' "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Info.plist"; \
|
||||
sed -i '' '/<key>CFBundleVersion<\/key>/{n;s|<string>.*</string>|<string>'"$$RAW_VERSION"'</string>|;}' "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Info.plist"
|
||||
sed -i '' '/<key>CFBundleShortVersionString<\/key>/{n;s|<string>.*</string>|<string>'"$$RAW_VERSION"'</string>|;}' "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Info.plist"; \
|
||||
sed -i '' '/<key>CFBundleVersion<\/key>/{n;s|<string>.*</string>|<string>'"$$RAW_VERSION"'</string>|;}' "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Info.plist"
|
||||
@codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
||||
@create-dmg \
|
||||
--volname "$(APP_NAME)" \
|
||||
--window-pos 200 120 \
|
||||
--window-size 720 300 \
|
||||
--icon-size 96 \
|
||||
--text-size 12 \
|
||||
--icon "$(APP_NAME).app" 278 102 \
|
||||
--icon "LICENSE" 441 102 \
|
||||
--icon "README.md" 604 102 \
|
||||
--app-drop-link 115 102 \
|
||||
--hide-extension "$(APP_NAME).app" \
|
||||
"$(MACOS_APPLE_SILICON_RELEASE)" \
|
||||
"$(RELEASE_FOLDER)" || true
|
||||
@echo "Release creat: $(MACOS_APPLE_SILICON_RELEASE)"
|
||||
@rm -rf $(RELEASE_FOLDER)
|
||||
@rm -f $(DIST_DIR)/rw.*
|
||||
|
||||
# Compila la versión para procesadores Apple Silicon
|
||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
||||
# ==============================================================================
|
||||
# RELEASE WINDOWS (.zip amb DLLs)
|
||||
# ==============================================================================
|
||||
_windows_release:
|
||||
@echo off
|
||||
@echo Creant release per a Windows - Versió: $(VERSION)
|
||||
@cmake $(CMAKE_GEN) -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release
|
||||
@cmake --build $(BUILDDIR) -j$(JOBS)
|
||||
@powershell -Command "if (-not (Test-Path '$(DIST_DIR)')) {New-Item '$(DIST_DIR)' -ItemType Directory | Out-Null}"
|
||||
@powershell -Command "if (Test-Path '$(RELEASE_FOLDER)') {Remove-Item '$(RELEASE_FOLDER)' -Recurse -Force}"
|
||||
@powershell -Command "New-Item '$(RELEASE_FOLDER)' -ItemType Directory | Out-Null"
|
||||
@powershell -Command "Copy-Item -Path 'data' -Destination '$(RELEASE_FOLDER)' -Recurse"
|
||||
@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 '$(PROJECT).exe' -Destination '$(RELEASE_FOLDER)/$(APP_NAME).exe'"
|
||||
@strip -s -R .comment -R .gnu.version "$(RELEASE_FOLDER)/$(APP_NAME).exe" --strip-unneeded
|
||||
@powershell -Command "if (Test-Path '$(WINDOWS_RELEASE)') {Remove-Item '$(WINDOWS_RELEASE)'}"
|
||||
@powershell -Command "Compress-Archive -Path '$(RELEASE_FOLDER)/*' -DestinationPath '$(WINDOWS_RELEASE)'"
|
||||
@echo Release creat: $(WINDOWS_RELEASE)
|
||||
@powershell -Command "Remove-Item '$(RELEASE_FOLDER)' -Recurse -Force"
|
||||
|
||||
# Firma la aplicación
|
||||
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
||||
|
||||
# Empaqueta el .dmg de la versión Apple Silicon con create-dmg
|
||||
@echo "Creando DMG Apple Silicon con iconos de 96x96..."
|
||||
create-dmg \
|
||||
--volname "$(APP_NAME)" \
|
||||
--window-pos 200 120 \
|
||||
--window-size 720 300 \
|
||||
--icon-size 96 \
|
||||
--text-size 12 \
|
||||
--icon "$(APP_NAME).app" 278 102 \
|
||||
--icon "LICENSE" 441 102 \
|
||||
--icon "README.md" 604 102 \
|
||||
--app-drop-link 115 102 \
|
||||
--hide-extension "$(APP_NAME).app" \
|
||||
"$(MACOS_APPLE_SILICON_RELEASE)" \
|
||||
"$(RELEASE_FOLDER)" || true
|
||||
@echo "Release Apple Silicon creado: $(MACOS_APPLE_SILICON_RELEASE)"
|
||||
|
||||
# Elimina las carpetas temporales
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
|
||||
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 $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||
|
||||
linux_release:
|
||||
@echo "Creando release para Linux - Version: $(VERSION)"
|
||||
# Elimina carpetas previas
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
|
||||
# Crea la carpeta temporal para realizar el lanzamiento
|
||||
$(MKDIR) "$(RELEASE_FOLDER)"
|
||||
|
||||
# Copia ficheros
|
||||
cp -R data "$(RELEASE_FOLDER)"
|
||||
cp LICENSE "$(RELEASE_FOLDER)"
|
||||
cp README.md "$(RELEASE_FOLDER)"
|
||||
|
||||
# Compila
|
||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(TARGET_NAME)"
|
||||
strip -s -R .comment -R .gnu.version "$(RELEASE_FOLDER)/$(TARGET_NAME)" --strip-unneeded
|
||||
|
||||
# Empaqueta ficheros
|
||||
$(RMFILE) "$(LINUX_RELEASE)"
|
||||
tar -czvf "$(LINUX_RELEASE)" -C "$(RELEASE_FOLDER)" .
|
||||
@echo "Release creado: $(LINUX_RELEASE)"
|
||||
|
||||
# Elimina la carpeta temporal
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
|
||||
# Regla para mostrar la versión actual
|
||||
show_version:
|
||||
@echo "Version actual: $(VERSION)"
|
||||
|
||||
# Regla de ayuda
|
||||
# ==============================================================================
|
||||
# AJUDA
|
||||
# ==============================================================================
|
||||
help:
|
||||
@echo "Makefile para Shadertoy"
|
||||
@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 completo para Linux"
|
||||
@echo " macos - Compilar para macOS"
|
||||
@echo " macos_debug - Compilar debug para macOS"
|
||||
@echo " macos_release - Crear release completo para macOS"
|
||||
@echo " show_version - Mostrar version actual ($(VERSION))"
|
||||
@echo " help - Mostrar esta ayuda"
|
||||
|
||||
.PHONY: windows windows_debug windows_release macos macos_debug macos_release linux linux_debug linux_release show_version help
|
||||
|
||||
FORCE:
|
||||
@echo "Makefile per a $(PROJECT)"
|
||||
@echo ""
|
||||
@echo " make Compilar Release (cmake)"
|
||||
@echo " make debug Compilar Debug (cmake)"
|
||||
@echo " make release Compilar + empaquetar per a distribució a $(DIST_DIR)/"
|
||||
@echo " make clean Esborrar $(BUILDDIR)/ i $(DIST_DIR)/"
|
||||
@echo ""
|
||||
@echo " Versió actual: $(VERSION)"
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user