summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-12-29 11:18:04 +0100
committertomsmeding <tom.smeding@gmail.com>2016-12-29 11:18:04 +0100
commitc8a110cdeca8c23b88d6908f0b06231847c9e722 (patch)
tree525313eb4007aab6a318c038f5fae0984ccb532a /Makefile
parent1f00b2bb92cd4bcfcc4c24806df71a453f481f34 (diff)
Enable retrieving of sprite image length
Without having to know the name of the symbol at compile time...
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile6
1 files changed, 3 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 09b0e36..995f07f 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ sprite_allfiles := $(wildcard src/sprites/*)
sprite_fnames := $(filter %.png,$(sprite_allfiles))
sprite_skipped := $(filter-out %.png,$(sprite_allfiles))
sprite_obj := $(patsubst src/sprites/%.png,build/sprites/%.o,$(sprite_fnames))
-sprite_externs := $(shell echo $$(for f in $(sprite_obj); do basename $$f | sed 's/\.[^.]*$$//' | sed 's/.*/extern const unsigned char &[];/'; done))
+sprite_externs := $(shell echo $$(for f in $(sprite_obj); do basename $$f | sed 's/\.[^.]*$$//' | sed 's/.*/extern const Sprite &;/'; done))
base_src := $(wildcard *_base.cpp)
base_src += library.cpp main.cpp
@@ -80,10 +80,10 @@ build/sprites/%.o: build/sprites/%.cpp
build/sprites/%.cpp: src/sprites/%.png
echo Generating for sprite $*
mkdir -p $(dir $@)
- printf "const unsigned char $*[]={\n%s, 0\n};\nconst unsigned int _$*_len=%d;\n" "$$(xxd -i <"$<")" $$(stat -f '%z' "$<") >"$@"
+ printf "#include \"sprite.h\"\n\nstatic const unsigned char data[]={\n%s, 0\n};\n\nSprite $*=(Sprite){.image=data,.image_len=%d};\n" "$$(xxd -i <"$<")" $$(stat -f '%z' "$<") >"$@"
build/sprites.h:
echo Collecting generated sprite files
mkdir -p $(dir $@)
- echo "$(sprite_externs)" >"$@"
+ printf "#include \"sprite.h\"\n\n$(sprite_externs)\n" >"$@"
test -z "$(sprite_skipped)" || printf "\x1B[1mWARNING: skipped files in src/sprites: $(notdir $(sprite_skipped))\x1B[0m\n"