summaryrefslogtreecommitdiff
path: root/pixel-client/makefile
blob: 339defcf07bec02aa4f9166e9787eb9eac70a99a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Hurry Curry! - a game about cooking
# Copyright 2024 metamuffin
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
SPRITES = $(shell find assets/sprites -name '*.ta')
SPRITES_PNG = $(patsubst %.ta,%.png,$(SPRITES))

TEXTURES = $(shell find assets/textures -name '*.ta')
TEXTURES_PNG = $(patsubst %.ta,%.png,$(TEXTURES))
TEXTURES_IMPORT_PNG = $(patsubst %.import.png,%.ta,$(shell find assets/textures -name '*.import.png'))

PNG = $(shell find assets/textures -name '*.png')

CLIENT_DEPS = assets/atlas.meta.csv assets/atlas.ta assets/connect.csv assets/palette.csv

IMPORT = ../target/release/tex_import
EXPORT = ../target/release/tex_export
PACK = ../target/release/tex_pack
COMPOSE = ../target/release/tex_compose
CLIENT = ../target/release/pixelcurry

.PHONY: all tex_pack tex_export tex_import clean
all: $(CLIENT) icon.png
tex_pack: assets/atlas.ta
tex_import: $(TEXTURES_IMPORT_PNG)
tex_export: $(TEXTURES_PNG) $(SPRITES_PNG) assets/atlas.png
clean:
	$(RM) $(PNG)
	$(RM) -r assets/sprites
	$(RM) assets/atlas.ta assets/atlas.meta.csv

$(CLIENT): $(shell find src -type f) $(CLIENT_DEPS)
	cargo $(CARGOFLAGS) build --release --bin pixelcurry
$(IMPORT) $(EXPORT) $(PACK) $(COMPOSE): $(shell find tools/src -type f)
	{ cd tools; cargo $(CARGOFLAGS) build --release; }

%.ta: %.import.png $(IMPORT)
	$(IMPORT) $< $@
%.png: %.ta $(EXPORT)
	$(EXPORT) $< $@

icon.png: assets/sprites/misc/icon+a.png
	ffmpeg -i $< -vf scale=512x512:sws_flags=neighbor -y $@

assets/sprites/%/all: assets/%.ini $(TEXTURES) $(COMPOSE)
	@mkdir -p $(shell dirname $@)
	$(COMPOSE) $< assets/textures $(shell dirname $@)
	@touch $@

assets/atlas.ta assets/atlas.meta.csv: assets/sprites/items/all assets/sprites/tiles/all assets/sprites/font/all assets/sprites/misc/all $(PACK)
	@echo $(PACK) assets/atlas.ta assets/atlas.meta.csv ...
	@$(PACK) assets/atlas.ta assets/atlas.meta.csv $(SPRITES)