Now super fast to compile project

This commit is contained in:
Ulysse Cura 2025-08-13 14:18:25 +02:00
parent 3cc5abfde3
commit c5222020fb
4 changed files with 29 additions and 11 deletions

3
.vscode/tasks.json vendored
View File

@ -6,6 +6,9 @@
"detail": "Build project", "detail": "Build project",
"type": "shell", "type": "shell",
"command": "make", "command": "make",
"args": [
"-j$(nproc)"
],
"group": "build", "group": "build",
"presentation": { "presentation": {
"echo": true, "echo": true,

View File

@ -2,23 +2,29 @@
BUILD_DIR = build BUILD_DIR = build
# Source files # Source files
SOURCES = \ SOURCES := \
src/main.cpp \ src/main.cpp \
src/game_data.cpp src/game_data.cpp
# Assets files # Assets files
ASSETS = \ ASSETS := \
assets/player-sheets/player_idle_sheet.png \ assets/player-sheets/player_idle_sheet.png \
assets/player-sheets/player_run_sheet.png assets/player-sheets/player_run_sheet.png
# Output target name # Output target name
OUTPUT = 2D_Engine_Casio_Tool OUTPUT := 2D_Engine_Casio_Tool
# Compiler and flags # Compiler and flags
CXX = g++ CXX = ccache g++
CXXFLAGS = -Wall -Wextra -std=c++17 -O2 -I. -no-pie CXXFLAGS = -Wall -Wextra -std=c++17 -O2 -I. -no-pie
LDFLAGS = -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 # Deduce objects
OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o) $(ASSETS:%=$(BUILD_DIR)/%.o) OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o) $(ASSETS:%=$(BUILD_DIR)/%.o)
@ -34,12 +40,11 @@ GREEN := \033[0;32m
YELLOW := \033[1;33m YELLOW := \033[1;33m
RESET := \033[0m RESET := \033[0m
# Total number of files to process # Current file nb to process
TOTAL_FILES := $(shell echo $$(($(words $(SOURCES) $(ASSETS))+1)))
CURRENT_FILE := 0 CURRENT_FILE := 0
# Default targets # Default targets
all: build_dir $(OUTPUT) end all: count_build build_dir end
# Create build directory # Create build directory
build_dir: build_dir:
@ -54,19 +59,26 @@ $(OUTPUT): $(OBJECTS)
$(BUILD_DIR)/%.o: %.cpp $(BUILD_DIR)/%.o: %.cpp
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1)))) $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_FILES))))) $(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)mkdir -p $(dir $@)
$(Q)$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@ $(Q)$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
# Convert .*.o from .* (png files for example) # Convert .*.o from .* (png files for example)
$(BUILD_DIR)/%.o: % $(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 # Source files dependencies
-include $(OBJECTS:.o=.d) -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 # Print ending message
end: end: $(OUTPUT)
@echo "Built target $(OUTPUT)" @echo "Built target $(OUTPUT)"
# Clean # Clean

View File

@ -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**. - 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). 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) [Git](https://git.planet-casio.com/Lephenixnoir/gint)
- Folder `src/nlohmann/json` contains code under **MIT license** : - Folder `src/nlohmann/json` contains code under **MIT license** :

3
assets/maps/map_0_0.json Normal file
View File

@ -0,0 +1,3 @@
{
}