From c5222020fbc2114cebb33fe5ffeacbc06a88a3b3 Mon Sep 17 00:00:00 2001 From: Ulysse Cura Date: Wed, 13 Aug 2025 14:18:25 +0200 Subject: [PATCH] Now super fast to compile project --- .vscode/tasks.json | 3 +++ Makefile | 32 ++++++++++++++++++++++---------- README.md | 2 +- assets/maps/map_0_0.json | 3 +++ 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 assets/maps/map_0_0.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ece755c..a0c33ac 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,6 +6,9 @@ "detail": "Build project", "type": "shell", "command": "make", + "args": [ + "-j$(nproc)" + ], "group": "build", "presentation": { "echo": true, diff --git a/Makefile b/Makefile index 1de891d..ab46220 100644 --- a/Makefile +++ b/Makefile @@ -2,23 +2,29 @@ BUILD_DIR = build # Source files -SOURCES = \ +SOURCES := \ src/main.cpp \ src/game_data.cpp # Assets files -ASSETS = \ +ASSETS := \ assets/player-sheets/player_idle_sheet.png \ assets/player-sheets/player_run_sheet.png # Output target name -OUTPUT = 2D_Engine_Casio_Tool +OUTPUT := 2D_Engine_Casio_Tool # Compiler and flags -CXX = g++ +CXX = ccache g++ CXXFLAGS = -Wall -Wextra -std=c++17 -O2 -I. -no-pie LDFLAGS = -no-pie +# Converter flags +FXCONVFLAGS = --cg --toolchain= --arch=x86-64 --outputtarget=elf64-x86-64 + +# Change output location +OUTPUT := $(BUILD_DIR)/$(OUTPUT) + # Deduce objects OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o) $(ASSETS:%=$(BUILD_DIR)/%.o) @@ -34,12 +40,11 @@ GREEN := \033[0;32m YELLOW := \033[1;33m RESET := \033[0m -# Total number of files to process -TOTAL_FILES := $(shell echo $$(($(words $(SOURCES) $(ASSETS))+1))) +# Current file nb to process CURRENT_FILE := 0 # Default targets -all: build_dir $(OUTPUT) end +all: count_build build_dir end # Create build directory build_dir: @@ -54,19 +59,26 @@ $(OUTPUT): $(OBJECTS) $(BUILD_DIR)/%.o: %.cpp $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1)))) $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_FILES))))) - @echo "[$(PERCENTAGE)%] $(GREEN)Building $@$(RESET)" + @echo "[$(PERCENTAGE)%] $(GREEN)Building CXX object $@$(RESET)" $(Q)mkdir -p $(dir $@) $(Q)$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@ # Convert .*.o from .* (png files for example) $(BUILD_DIR)/%.o: % - fxconv --cg --toolchain= --arch=x86-64 --outputtarget=elf64-x86-64 $< -o $@ + $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1)))) + $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_FILES))))) + @echo "[$(PERCENTAGE)%] $(GREEN)Building FXCONV object $@$(RESET)" + $(Q)fxconv $(FXCONVFLAGS) $< -o $@ + $(Q)objcopy --add-section .note.GNU-stack=/dev/null $@ # Source files dependencies -include $(OBJECTS:.o=.d) +count_build: + $(eval export TOTAL_FILES := $(shell echo $$(($$(make -n $(OBJECTS) 2>/dev/null | grep -c "Building") + 1)))) + # Print ending message -end: +end: $(OUTPUT) @echo "Built target $(OUTPUT)" # Clean diff --git a/README.md b/README.md index b29e466..b16c1e3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This tool is used to make game data for the 2D_Engine_Casio [Gitea](https://gite - This program is open-source : you can redistribute and/or modify it under the term of the **GNU GPLv3**. Copyright (C) 2025 Ulysse Cura. See [LICENSE](LICENSE) or [gnu.org/licenses/gpl-3.0.html](https://www.gnu.org/licenses/gpl-3.0.html). -- Files from the gint project is used in directory [gint/](gint/). +- Files from the gint project are used but not modified in directory [gint/](gint/). [Git](https://git.planet-casio.com/Lephenixnoir/gint) - Folder `src/nlohmann/json` contains code under **MIT license** : diff --git a/assets/maps/map_0_0.json b/assets/maps/map_0_0.json new file mode 100644 index 0000000..544b7b4 --- /dev/null +++ b/assets/maps/map_0_0.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file