fxsdk: update Makefile-based build system for fxconv

* Use [find] for sources since it's used for dependency files...
* Get fxconv parameters from fxconv-metadata.txt
* Approximate dependencies: every asset depends on every metadata file
* Update location of example image
This commit is contained in:
Lephenixnoir 2021-01-25 23:31:57 +01:00
parent e8bbf63d95
commit ad5d9bdb4c
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
3 changed files with 24 additions and 46 deletions

View file

@ -68,18 +68,15 @@ ELF_CG := build-cg/$(shell basename "$(TARGET_CG)" .g3a).elf
BIN_CG := $(ELF_CG:.elf=.bin)
# Source files
src := $(wildcard src/*.[csS] \
src/*/*.[csS] \
src/*/*/*.[csS] \
src/*/*/*/*.[csS])
assets-fx := $(wildcard assets-fx/*/*)
assets-cg := $(wildcard assets-cg/*/*)
src := $(shell find src/ -name '*.[csS]')
assets-fx := $(shell find assets-fx/*/ -type f -not -name 'fxconv-metadata.txt')
assets-cg := $(shell find assets-cg/*/ -type f -not -name 'fxconv-metadata.txt')
meta-fx := $(shell find assets-fx -name 'fxconv-metadata.txt')
meta-cg := $(shell find assets-cg -name 'fxconv-metadata.txt')
# Object files
obj-fx := $(src:%=build-fx/%.o) \
$(assets-fx:assets-fx/%=build-fx/assets/%.o)
obj-cg := $(src:%=build-cg/%.o) \
$(assets-cg:assets-cg/%=build-cg/assets/%.o)
obj-fx := $(src:%=build-fx/%.o) $(assets-fx:assets-fx/%=build-fx/assets/%.o)
obj-cg := $(src:%=build-cg/%.o) $(assets-cg:assets-cg/%=build-cg/assets/%.o)
# Additional dependencies
deps-fx := $(ICON_FX)
@ -139,37 +136,13 @@ build-cg/%.S.o: %.S
@ mkdir -p $(dir $@)
$(TOOLCHAIN_CG)-gcc -c $< -o $@ $(INCLUDE_CG)
# Images
build-fx/assets/img/%.o: assets-fx/img/%
# Assets
build-fx/assets/%.o: assets-fx/% $(meta-fx)
@ mkdir -p $(dir $@)
fxconv --bopti-image $< -o $@ $(FXCONVFX) name:img_$(basename $*) $(IMG.$*)
build-cg/assets/img/%.o: assets-cg/img/%
fxconv $< -o $@ $(FXCONVFX)
build-cg/assets/%.o: assets-cg/% $(meta-cg)
@ mkdir -p $(dir $@)
fxconv --bopti-image $< -o $@ $(FXCONVCG) name:img_$(basename $*) $(IMG.$*)
# Fonts
build-fx/assets/fonts/%.o: assets-fx/fonts/%
@ mkdir -p $(dir $@)
fxconv -f $< -o $@ $(FXCONVFX) name:font_$(basename $*) $(FONT.$*)
build-cg/assets/fonts/%.o: assets-cg/fonts/%
@ mkdir -p $(dir $@)
fxconv -f $< -o $@ $(FXCONVCG) name:font_$(basename $*) $(FONT.$*)
# Binaries
build-fx/assets/bin/%.o: assets-fx/bin/%
@ mkdir -p $(dir $@)
fxconv -b $< -o $@ $(FXCONVFX) name:bin_$(basename $*) $(BIN.$*)
build-cg/assets/bin/%.o: assets-cg/bin/%
@ mkdir -p $(dir $@)
fxconv -b $< -o $@ $(FXCONVCG) name:bin_$(basename $*) $(BIN.$*)
# Custom conversions
build-fx/assets/%.o: assets-fx/%
@ mkdir -p $(dir $@)
fxconv --custom $< -o $@ $(FXCONVFX) type:$(subst /,,$(dir $*)) name:$(subst /,_,$(basename $*))
build-cg/assets/%.o: assets-cg/%
@ mkdir -p $(dir $@)
fxconv --custom $< -o $@ $(FXCONVCG) type:$(subst /,,$(dir $*)) name:$(subst /,_,$(basename $*))
fxconv $< -o $@ $(FXCONVCG)
#
# Cleaning and utilities

View file

@ -17,10 +17,10 @@ TARGET_FX :=
TARGET_CG :=
# fx-9860G icon location
ICON_FX = assets-fx/icon-fx.png
ICON_FX = assets-fx/icon.png
# fx-CG 50 icon locations
ICON_CG_UNS = assets-cg/icon-cg-uns.png
ICON_CG_SEL = assets-cg/icon-cg-sel.png
ICON_CG_UNS = assets-cg/icon-uns.png
ICON_CG_SEL = assets-cg/icon-sel.png
#---
# Toolchain selection

View file

@ -90,9 +90,16 @@ fxsdk_new_project() {
"Makefile")
sed -e "s/@NAME@/$NAME/g" -e "s/@INTERNAL@/$INTERNAL/g" \
"$assets/project.cfg" > "$1/project.cfg"
cp "$assets/Makefile" "$1";;
cp "$assets/Makefile" "$1"
mkdir -p "$1"/{assets-fx,assets-cg}/img
cp -r "$assets"/assets-fx/* "$1"/assets-fx/img/
cp -r "$assets"/assets-cg/* "$1"/assets-cg/img/;;
"CMake")
cp "$assets/CMakeLists.txt" "$1";;
cp "$assets/CMakeLists.txt" "$1"
cp -r "$assets"/assets-fx "$1"/
cp -r "$assets"/assets-cg "$1"/;;
esac
cp "$assets"/gitignore "$1"/.gitignore
@ -100,8 +107,6 @@ fxsdk_new_project() {
cp "$assets"/icon-fx.png "$1"/assets-fx/icon.png
cp "$assets"/icon-cg-uns.png "$1"/assets-cg/icon-uns.png
cp "$assets"/icon-cg-sel.png "$1"/assets-cg/icon-sel.png
cp -r "$assets"/assets-fx "$1"/
cp -r "$assets"/assets-cg "$1"/
echo "Created a new project $NAME (build system: $generator)."
echo "Type 'fxsdk build-fx' or 'fxsdk build-cg' to compile the program."