Building is functionnal for all.

This commit is contained in:
Ulysse Cura 2026-05-04 21:40:05 +02:00
parent 6c2034cecc
commit 314cca6434
3 changed files with 30 additions and 12 deletions

View File

@ -7,7 +7,7 @@ BUILD_DIR = build
SOURCE_OUTPUT := 2D_Engine SOURCE_OUTPUT := 2D_Engine
# Assets output # Assets output
ASSETS_OUTPUT := game.data ASSET_OUTPUT := game.data
# Verbosity # Verbosity
Q := @ Q := @
@ -21,8 +21,7 @@ YELLOW := \033[33m
RESET := \033[m RESET := \033[m
# Default targets # Default targets
#all: build_core build_src compress_assets all: build_core build_src compress_assets
all: build_core build_src
# Sub Makefiles # Sub Makefiles
SOURCE_DIR = src SOURCE_DIR = src

View File

@ -12,14 +12,33 @@ ASSETS := \
# Deduce assets lz4 # Deduce assets lz4
ASSETS_COMPRESSED = $(ASSETS:%=$(BUILD_DIR)/%.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 # Compress assets into tar file
$(BUILD_DIR)/$(ASSETS_OUTPUT): $(ASSETS_COMPRESSED) $(BUILD_DIR)/$(ASSET_OUTPUT): $(ASSETS_COMPRESSED)
@echo "[100%] $(YELLOW)Compressing $(ASSETS_OUTPUT)$(RESET)" @echo -e "[100%] $(YELLOW)Compressing $(ASSET_OUTPUT)$(RESET)"
$(Q)tar -cvf $@ $() $(Q)tar -cf $@ $(ASSETS_COMPRESSED)
# Compress individual assets # Compress individual assets
$(BUILD_DIR)/%.lz4: % $(BUILD_DIR)/%.lz4: %
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1)))) $(eval CURRENT_ASSET_FILE := $(shell echo $$(($(CURRENT_ASSET_FILE) + 1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_FILES))))) $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_ASSET_FILE) * 100 / $(TOTAL_ASSETS_FILES)))))
@echo "[$(PERCENTAGE)%] $(GREEN)Compressing asset $@$(RESET)" @echo -e "[$(PERCENTAGE)%] $(GREEN)Compressing asset $@$(RESET)"
$(Q)lz4 $< $@ $(Q)lz4 --favor-decSpeed -fqtz $< $@
# Print ending message
assets_end: $(BUILD_DIR)/$(SOURCE_OUTPUT)
@echo "Compressed target $(ASSET_OUTPUT)"

View File

@ -23,12 +23,12 @@ CURRENT_SRC_FILE := 0
# Build src target # Build src target
build_src: src_setup count_src_build $(BUILD_DIR)/$(SOURCE_OUTPUT) src_end build_src: src_setup count_src_build $(BUILD_DIR)/$(SOURCE_OUTPUT) src_end
# Source build directories and # Source build directories
src_setup: src_setup:
@echo "Building Source (2/3)" @echo "Building Source (2/3)"
$(Q)mkdir -p $(dir $(SOURCE_OBJECTS)) $(Q)mkdir -p $(dir $(SOURCE_OBJECTS))
# Count # Count nb of files to build
count_src_build: count_src_build:
$(eval export TOTAL_SRC_FILES := $(shell echo $$(($$(make -n $(SOURCE_OBJECTS) 2>/dev/null | grep -c "Building") + 1)))) $(eval export TOTAL_SRC_FILES := $(shell echo $$(($$(make -n $(SOURCE_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))