This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
122 lines (98 loc) · 3.04 KB
/
makefile
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
include ../../ooz/config.make
dist_dir := dist
assets_dir := assets
atlas_assets_dir := $(assets_dir)/atlas
src_dir := src
# Sort to strip out mem-prop-5x6.aseprite duplicate when it already exists.
atlas_in_files := $(sort \
$(wildcard $(atlas_assets_dir)/*.aseprite) \
$(atlas_assets_dir)/mem-prop-5x6.aseprite \
)
asset_files := \
$(assets_dir)/atlas.json \
$(assets_dir)/atlas.png \
$(wildcard $(assets_dir)/index.*) \
$(assets_dir)/manifest.json
dist_files := \
$(asset_files:$(assets_dir)/%=$(dist_dir)/%) \
$(dist_dir)/favicon.png \
$(dist_dir)/favicon32x32.png \
$(dist_dir)/favicon48x48.png \
$(dist_dir)/favicon64x64.png \
$(dist_dir)/favicon192x192.png \
$(dist_dir)/favicon512x512.png
bundle_args ?=
fmt_args ?=
test_unit_args ?=
.PHONY: build
build: bundle build-dist
.PHONY: build-dist
build-dist: $(dist_files)
.PHONY: watch-build
watch-build:; watchexec --ignore='*/$(dist_dir)/*' '$(make) build-dist'
.PHONY: watch
watch: watch-build watch-bundle serve
.PHONY: serve
serve: | $(dist_dir)/; $(live-server) '$(dist_dir)'
.PHONY: bundle
bundle: $(assets_dir)/atlas.json | $(dist_dir)/
$(deno) bundle --config='$(deno_config)' src/index.ts '$(dist_dir)/green-field.js' $(bundle_args)
.PHONY: watch-bundle
watch-bundle: bundle_args += --watch
watch-bundle: bundle
.PHONY: test
test: test-fmt test-lint build test-unit
.PHONY: test-fmt
test-fmt: fmt_args += --check
.PHONY: fmt
fmt:; $(deno) fmt --config='$(deno_config)' $(fmt_args)
.PHONY: test-lint
test-lint:; $(deno) lint --config='$(deno_config)' $(if $(value v),,--quiet)
.PHONY: test-unit
test-unit: build; $(deno) test --allow-read=. --config='$(deno_config)' $(test_unit_args)
.PHONY: test-unit-update
test-unit-update: test_unit_args += --allow-write=. -- --update
test-unit-update: test-unit
$(dist_dir)/%: $(assets_dir)/% | $(dist_dir)/; $(cp) '$<' '$@'
$(assets_dir)/atlas.json $(assets_dir)/atlas.png&: $(atlas_in_files)
../../atlas-pack/bin/aseprite-batch \
--merge-duplicates \
--sheet='$(assets_dir)/atlas.png' \
$^ \
--color-mode=indexed|
../../atlas-pack/bin/atlas-pack > '$(assets_dir)/atlas.json'
$(atlas_assets_dir)/mem-prop-5x6.aseprite: \
../../mem/src/mem-prop-5x6.aseprite \
$(atlas_assets_dir)/palette.aseprite
$(aseprite) \
'$<' \
--palette=$(atlas_assets_dir)/palette.aseprite \
--save-as='$@'
# $1 stem suffix
# $2 scale
define favicon_template =
$$(dist_dir)/favicon$(1).png: $$(assets_dir)/favicon.aseprite | $$(dist_dir)/
$$(aseprite) '$$<' --scale=$(2) --save-as '$$@'
endef
$(eval $(call favicon_template,,1))
$(eval $(call favicon_template,32x32,2))
$(eval $(call favicon_template,48x48,3))
$(eval $(call favicon_template,64x64,4))
$(eval $(call favicon_template,192x192,12))
$(eval $(call favicon_template,512x512,32))
$(dist_dir)/:; $(mkdir) '$@'
.PHONY: clean
clean:
$(rm) \
'$(dist_dir)/' \
'$(assets_dir)/atlas.json' \
'$(assets_dir)/atlas.png' \
'$(atlas_assets_dir)/mem-prop-5x6.aseprite'
.PHONY: rebuild
rebuild:
$(make) clean
$(make) build
.PHONY: retest
retest:
$(make) clean
$(make) test