From d3ce988aafdca1f040e0a9137d86d9b5c190f34b Mon Sep 17 00:00:00 2001 From: Ulysse Cura Date: Wed, 6 May 2026 20:42:09 +0200 Subject: [PATCH] Changed Makefile structure and assets are compressed correctly now. --- Makefile | 2 +- assets/Makefile | 42 +++++++++++++----------------------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 58cff27..2bc60f8 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ all: build_core build_src compress_assets # Sub Makefiles SOURCE_DIR = src -CORE_DIR = core +CORE_DIR = core/src ASSETS_DIR = assets include $(CORE_DIR)/Makefile diff --git a/assets/Makefile b/assets/Makefile index f48290a..cc3562a 100644 --- a/assets/Makefile +++ b/assets/Makefile @@ -1,43 +1,27 @@ # Assets files ASSETS := \ - assets/tileset/tileset.png \ - assets/player_sheets/player_idle_sheet.png \ - assets/player_sheets/player_run_sheet.png \ - assets/player_sheets/player_death_sheet.png \ - assets/enemy_sheets/enemy_idle_sheet.png \ - assets/enemy_sheets/enemy_run_sheet.png \ - assets/enemy_sheets/enemy_death_sheet.png \ - assets/maps/map_test.json - -# Deduce assets lz4 -ASSETS_COMPRESSED = $(ASSETS:%=$(BUILD_DIR)/%.lz4) - -# Current file nb to process -CURRENT_ASSET_FILE := 0 + tileset/tileset.png \ + player_sheets/player_idle_sheet.png \ + player_sheets/player_run_sheet.png \ + player_sheets/player_death_sheet.png \ + enemy_sheets/enemy_idle_sheet.png \ + enemy_sheets/enemy_run_sheet.png \ + enemy_sheets/enemy_death_sheet.png \ + maps/map_test.json # Build asset target -compress_assets: asset_setup count_assets_compress $(BUILD_DIR)/$(ASSET_OUTPUT) assets_end +compress_assets: asset_setup $(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)))) + $(Q)mkdir -p $(BUILD_DIR)/$(ASSETS_DIR) # Compress assets into tar file -$(BUILD_DIR)/$(ASSET_OUTPUT): $(ASSETS_COMPRESSED) +$(BUILD_DIR)/$(ASSET_OUTPUT): $(ASSETS:%=$(ASSETS_DIR)/%) @echo -e "[100%] $(YELLOW)Compressing $(ASSET_OUTPUT)$(RESET)" - $(Q)tar -cf $@ $(ASSETS_COMPRESSED) - -# Compress individual assets -$(BUILD_DIR)/%.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 $< $@ + $(Q)tar -cf $(BUILD_DIR)/$(ASSETS_DIR)/assets.tar $^ + $(Q)lz4 --favor-decSpeed -fqtz $(BUILD_DIR)/$(ASSETS_DIR)/assets.tar $@ # Print ending message assets_end: $(BUILD_DIR)/$(SOURCE_OUTPUT)