-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
158 lines (121 loc) · 3.54 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# This Makefile exists to orchestrate Zig's `build.zig` and JavaScript's
# `package.json`. In many cases you will still want to invoke `zig build` or
# `npm run` directly for more targeted execution, but to have one set of
# commands that covers everything, see below.
.PHONY: default
default: check
.PHONY: zig-build
zig-build:
zig build --summary all -Dlog -Dchance -Dcalc -p build
zig build --summary all -Dshowdown -Dlog -Dchance -Dcalc -p build
.PHONY: js-build
js-build: export DEBUG_PKMN_ENGINE=true
js-build: node_modules
node src/bin/install-pkmn-engine --options='-Dshowdown'
npm run compile
.PHONY: build
build: zig-build js-build
node_modules:
npm install
.PHONY: install
install: node_modules
.PHONY: uninstall
uninstall:
rm -rf node_modules
.PHONY: generate
generate:
npm run generate
.PHONY: zig-lint
zig-lint:
ziglint --exclude examples/zig/example.zig,\
examples/zig/legacy/example.zig,\
examples/zig/modern/example.zig
.PHONY: js-lint
js-lint: node_modules
npm run lint
.PHONY: lint
lint: zig-lint js-lint
.PHONY: zig-fix
zig-fix:
zig fmt . --exclude build
.PHONY: js-fix
js-fix: node_modules
npm run fix
.PHONY: fix
fix: zig-fix js-fix
.PHONY: zig-test
zig-test:
zig build --summary all -Dlog -Dchance -Dcalc test
zig build --summary all -Dshowdown -Dlog -Dchance -Dcalc test
.PHONY: js-test
js-test: js-build
npm run test
.PHONY: test
test: zig-test js-test
.PHONY: zig-coverage
zig-coverage:
rm -rf coverage/zig
mkdir -p coverage/zig
zig build --summary all test -Dtest-coverage=coverage/zig/pkmn
zig build --summary all -Dshowdown -Dlog -Dchance -Dcalc test -Dtest-coverage=coverage/zig/pkmn-showdown
kcov --merge coverage/zig/merged coverage/zig/pkmn coverage/zig/pkmn-showdown
.PHONY: js-coverage
js-coverage: js-build
npm run test -- --coverage
.PHONY: coverage
coverage: zig-coverage js-coverage
.PHONY: check
check: test lint
.PHONY: c-example
c-example:
$(MAKE) -C examples/c
./examples/c/example 1234
examples/js/node_modules:
npm -C examples/js install --install-links=false
.PHONY: js-example
js-example: examples/js/node_modules
npm -C examples/js start
.PHONY: zig-example
zig-example:
cd examples/zig/$(shell zig run src/tools/version.zig); zig build --summary all run -- 1234
.PHONY: example
example: c-example js-example zig-example
.PHONY: addon
addon: export DEBUG_PKMN_ENGINE=true
addon:
node src/bin/install-pkmn-engine --options='-Dshowdown -Dlog -Dchance -Dcalc'
.PHONY: integration
integration: build test example lint addon
npm run test:integration
.PHONY: benchmark
benchmark: export DEBUG_PKMN_ENGINE=
benchmark:
node src/bin/install-pkmn-engine --options='-Dshowdown'
npm run benchmark
.PHONY: clean-example
clean-example:
$(MAKE) clean -C examples/c
rm -rf examples/js/.parcel-cache examples/js/{build,dist}
rm -rf examples/zig/*/.zig-* examples/zig/*/zig-*
.PHONY: clean
clean: clean-example
rm -rf .zig-* zig-* build .tsbuildinfo .eslintcache
.PHONY: release
release:
npm run release -- --prod
, := ,
gen := $(or $(gen),2)
seed := $(or $(seed),1$(,)2$(,)3$(,)4)
opt := $(if $(filter true,$(showdown)),-Dshowdown,)
.PHONY: patch
patch:
sed -i '' 's|"@pkmn/sim":.*",|"@pkmn/sim": "file:../ps/sim",|g' package.json
sed -i '' 's|sim/battle-queue.ts:405:15|sim/battle-queue.ts:408:15|g' src/test/showdown.ts
sed -i '' 's|/.*@pkmn\/sim\//|/.*ps\/sim\//|g' src/test/showdown.ts
npm install --install=links=false
.PHONY: t
t:
zig build --summary all test -Dlog -Dchance -Dcalc -Dtest-filter="$(filter)" $(opt)
.PHONY: it
it:
npm run integration -- --cycles=1 --maxFailures=1 --gen=$(gen) --seed=$(seed)