From 314cca64340c97e64ca408a97720c71ada76dac9 Mon Sep 17 00:00:00 2001 From: Ulysse Cura Date: Mon, 4 May 2026 21:40:05 +0200 Subject: [PATCH] Building is functionnal for all. --- Makefile | 5 ++--- assets/Makefile | 33 ++++++++++++++++++++++++++------- src/Makefile | 4 ++-- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 699783a..2bc60f8 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ BUILD_DIR = build SOURCE_OUTPUT := 2D_Engine # Assets output -ASSETS_OUTPUT := game.data +ASSET_OUTPUT := game.data # Verbosity Q := @ @@ -21,8 +21,7 @@ YELLOW := \033[33m RESET := \033[m # Default targets -#all: build_core build_src compress_assets -all: build_core build_src +all: build_core build_src compress_assets # Sub Makefiles SOURCE_DIR = src diff --git a/assets/Makefile b/assets/Makefile index a9fcb63..f48290a 100644 --- a/assets/Makefile +++ b/assets/Makefile @@ -12,14 +12,33 @@ ASSETS := \ # Deduce assets lz4 ASSETS_COMPRESSED = $(ASSETS:%=$(BUILD_DIR)/%.lz4) +# Current file nb to process +CURRENT_ASSET_FILE := 0 + +# Build asset target +compress_assets: asset_setup count_assets_compress $(BUILD_DIR)/$(ASSET_OUTPUT) assets_end + +# Asset compressing message +asset_setup: + @echo "Compressing Assets (3/3)" + $(Q)mkdir -p $(dir $(ASSETS_COMPRESSED)) + +# Count nb of assets to compress +count_assets_compress: + $(eval export TOTAL_ASSETS_FILES := $(shell echo $$(($$(make -n $(ASSETS_COMPRESSED) 2>/dev/null | grep -c "Compressing") + 1)))) + # Compress assets into tar file -$(BUILD_DIR)/$(ASSETS_OUTPUT): $(ASSETS_COMPRESSED) - @echo "[100%] $(YELLOW)Compressing $(ASSETS_OUTPUT)$(RESET)" - $(Q)tar -cvf $@ $() +$(BUILD_DIR)/$(ASSET_OUTPUT): $(ASSETS_COMPRESSED) + @echo -e "[100%] $(YELLOW)Compressing $(ASSET_OUTPUT)$(RESET)" + $(Q)tar -cf $@ $(ASSETS_COMPRESSED) # Compress individual assets $(BUILD_DIR)/%.lz4: % - $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1)))) - $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_FILES))))) - @echo "[$(PERCENTAGE)%] $(GREEN)Compressing asset $@$(RESET)" - $(Q)lz4 $< $@ + $(eval CURRENT_ASSET_FILE := $(shell echo $$(($(CURRENT_ASSET_FILE) + 1)))) + $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_ASSET_FILE) * 100 / $(TOTAL_ASSETS_FILES))))) + @echo -e "[$(PERCENTAGE)%] $(GREEN)Compressing asset $@$(RESET)" + $(Q)lz4 --favor-decSpeed -fqtz $< $@ + +# Print ending message +assets_end: $(BUILD_DIR)/$(SOURCE_OUTPUT) + @echo "Compressed target $(ASSET_OUTPUT)" diff --git a/src/Makefile b/src/Makefile index 0b4b9ec..952b193 100644 --- a/src/Makefile +++ b/src/Makefile @@ -23,12 +23,12 @@ CURRENT_SRC_FILE := 0 # Build src target build_src: src_setup count_src_build $(BUILD_DIR)/$(SOURCE_OUTPUT) src_end -# Source build directories and +# Source build directories src_setup: @echo "Building Source (2/3)" $(Q)mkdir -p $(dir $(SOURCE_OBJECTS)) -# Count +# Count nb of files to build count_src_build: $(eval export TOTAL_SRC_FILES := $(shell echo $$(($$(make -n $(SOURCE_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))