Building assets !
This commit is contained in:
parent
5b3d4c6615
commit
7ba5e651cf
2
Makefile
2
Makefile
|
|
@ -24,7 +24,7 @@ YELLOW := \033[33m
|
|||
RESET := \033[m
|
||||
|
||||
# Default targets
|
||||
all: build_core build_src compress_assets
|
||||
all: build_core build_src build_assets
|
||||
|
||||
# Sub Makefiles
|
||||
SOURCE_DIR = src
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
ASSETS := \
|
||||
player_sheets/player_idle_sheet.png \
|
||||
player_sheets/player_walk_sheet.png
|
||||
|
||||
ASSETS := $(ASSETS:%=$(ASSETS_DIR)/%)
|
||||
|
||||
ASSET_BUILDER_DIR = $(ASSETS_DIR)/asset_builder/src
|
||||
|
||||
ASSET_BUILDER_OUTPUT = asset_builder
|
||||
|
||||
build_assets: setup_asset asset_end
|
||||
|
||||
include $(ASSET_BUILDER_DIR)/Makefile
|
||||
|
||||
setup_asset:
|
||||
@echo "Building $(ASSET_OUTPUT)"
|
||||
$(Q)mkdir -p $(dir $(ASSETS))
|
||||
|
||||
$(BUILD_DIR)/$(ASSET_OUTPUT): build_asset_builder
|
||||
$(Q)$(BUILD_DIR)/$(ASSET_BUILDER_DIR)/$(ASSET_BUILDER_OUTPUT) $@ $(ASSETS)
|
||||
|
||||
asset_end: $(BUILD_DIR)/$(ASSET_OUTPUT)
|
||||
@echo "Built target $(ASSET_OUTPUT)"
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# Source files
|
||||
ASSET_BUILDER_SOURCES := \
|
||||
main.c
|
||||
|
||||
# Compiler and flags
|
||||
ASSET_BUILDER_CC = gcc
|
||||
#ASSET_BUILDER_CFLAGS = -std=c17 -pedantic -O3 # RELEASE
|
||||
ASSET_BUILDER_CFLAGS = -std=c17 --pedantic -O0 -g \
|
||||
-Wall -Wno-missing-braces -Wextra -Wno-missing-field-initializers \
|
||||
-Wformat=2 -Wswitch-default -Wswitch-enum -Wcast-align \
|
||||
-Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 \
|
||||
-Wstrict-prototypes -Winline -Wundef -Wnested-externs \
|
||||
-Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op \
|
||||
-Wfloat-equal -Wstrict-aliasing=2 -Wredundant-decls \
|
||||
-Wold-style-definition # DEVELOPEMENT
|
||||
|
||||
ASSET_BUILDER_INCLUDE_DIRS = $(ASSET_BUILDER_DIR)/headers
|
||||
ASSET_BUILDER_LDFLAGS =
|
||||
|
||||
# Deduce objects
|
||||
ASSET_BUILDER_OBJECTS = $(ASSET_BUILDER_SOURCES:%.c=$(BUILD_DIR)/$(ASSET_BUILDER_DIR)/%.o)
|
||||
|
||||
# Current file nb to process
|
||||
CURRENT_ASSET_BUILDER_FILE := 0
|
||||
|
||||
# Build asset builder target
|
||||
build_asset_builder: asset_builder_setup count_asset_builder_build $(BUILD_DIR)/$(ASSET_BUILDER_DIR)/$(ASSET_BUILDER_OUTPUT) asset_builder_end
|
||||
|
||||
# Source build directories
|
||||
asset_builder_setup:
|
||||
@echo "Building Asset Builder"
|
||||
$(Q)mkdir -p $(dir $(ASSET_BUILDER_OBJECTS))
|
||||
|
||||
# Count nb of files to build
|
||||
count_asset_builder_build:
|
||||
$(eval export TOTAL_ASSET_BUILDER_FILES := $(shell echo $$(($$(make -n $(ASSET_BUILDER_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))
|
||||
|
||||
# Link asset builder target
|
||||
$(BUILD_DIR)/$(ASSET_BUILDER_DIR)/$(ASSET_BUILDER_OUTPUT): $(ASSET_BUILDER_OBJECTS)
|
||||
@echo -e "[100%] $(YELLOW)Linking $(ASSET_BUILDER_OUTPUT)$(RESET)"
|
||||
$(Q)$(SRC_CC) $(ASSET_BUILDER_OBJECTS) -o $@ $(ASSET_BUILDER_LDFLAGS)
|
||||
|
||||
# Build .o files
|
||||
$(BUILD_DIR)/$(ASSET_BUILDER_DIR)/%.o: $(ASSET_BUILDER_DIR)/%.c
|
||||
$(eval CURRENT_SRC_FILE := $(shell echo $$(($(CURRENT_SRC_FILE)+1))))
|
||||
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_ASSET_BUILDER_FILE)*100/$(TOTAL_ASSET_BUILDER_FILES)))))
|
||||
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
|
||||
$(Q)$(SRC_CC) $(SRC_CFLAGS) $(ASSET_BUILDER_INCLUDE_DIRS:%=-I%) -MMD -MP -c $< -o $@
|
||||
|
||||
# Print ending message
|
||||
asset_builder_end:
|
||||
@echo "Built target $(ASSET_BUILDER_OUTPUT)"
|
||||
|
||||
# Source files dependencies
|
||||
-include $(ASSET_BUILDER_OBJECTS:.o=.d)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("%d args\n", argc);
|
||||
|
||||
for(int i = 0; i < argc; i++)
|
||||
puts(argv[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue