Changed Makefile structure and assets are compressed correctly now.

This commit is contained in:
Ulysse Cura 2026-05-06 20:42:09 +02:00
parent 888c800111
commit d3ce988aaf
2 changed files with 14 additions and 30 deletions

View File

@ -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

View File

@ -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)