forked from SkipLabs/skip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
242 lines (181 loc) · 6.5 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# this builds the artifacts of this repository, orchestrating the
# various build systems
.PHONY: all
all: npm build/skdb build/init.sql
PLAYWRIGHT_REPORTER?="line"
SKARGO_PROFILE?=release
SKDB_WASM=sql/target/wasm32-unknown-unknown/$(SKARGO_PROFILE)/skdb.wasm
SKDB_BIN=sql/target/host/$(SKARGO_PROFILE)/skdb
SDKMAN_DIR?=$(HOME)/.sdkman
ifndef PLAYWRIGHT_JUNIT_OUTPUT_NAME
SKNPM_FLAG=
else
SKNPM_FLAG=--junitxml $(PLAYWRIGHT_JUNIT_OUTPUT_NAME)
endif # ifndef PLAYWRIGHT_JUNIT_OUTPUT_NAME
################################################################################
# skdb wasm + js client
################################################################################
.PHONY: npm
npm: $(SKDB_WASM) build/package/skdb build/package/package.json
cd build/package && npm install
build/package/package.json:
@echo "{" > build/package/package.json
@echo " \"dependencies\": {" >> build/package/package.json
@echo " \"skdb\": \"file:skdb\"" >> build/package/package.json
@echo " }" >> build/package/package.json
@echo "}" >> build/package/package.json
sql/target/wasm32-unknown-unknown/dev/skdb.wasm: sql/src/*
cd sql && skargo build --target wasm32-unknown-unknown --bin skdb
sql/target/wasm32-unknown-unknown/release/skdb.wasm: sql/src/*
cd sql && skargo build --release --target wasm32-unknown-unknown --bin skdb
$(SDKMAN_DIR):
cd $(dirname $(SDKMAN_DIR)) && sh -c 'wget -q -O- "https://get.sdkman.io?rcupdate=false" | bash'
################################################################################
# skdb native binary
################################################################################
sql/target/host/dev/skdb: sql/src/* prelude/src/**/*.sk skdate/src/* skjson/src/* sqlparser/src/*
cd sql && skargo build
sql/target/host/release/skdb: sql/src/* prelude/src/**/*.sk skdate/src/* skjson/src/* sqlparser/src/*
cd sql && skargo build --release --bin skdb
# TODO: keeping this for now as nearly all test scripts refer to build/skdb
build/skdb: $(SKDB_BIN)
mkdir -p build
cp $^ $@
################################################################################
# skdb server
################################################################################
build/init.sql: sql/privacy/init.sql
mkdir -p build
cp $^ $@
################################################################################
# dev workflow orchestration
################################################################################
.PHONY: update-js-deps
update-js-deps:
find . -name node_modules -not -prune -or -name target -not -prune -or -name package.json -exec sh -c 'cd $$(dirname "$$0"); bun update --latest' {} \;
CHECK_TARGETS=$(patsubst %/Skargo.toml,check-%,$(shell ls -1 */Skargo.toml))
check-%:
cd $* && skargo check
.PHONY: check
check: $(CHECK_TARGETS)
.PHONY: clean
clean:
rm -Rf build
find . -name 'Skargo.toml' -print0 | sed 's|Skargo.toml|target|g' | xargs -0 rm -rf
npm run clean
.PHONY: clean-all
clean-all: clean
find . -type d -name 'node_modules' -prune -print0 | xargs -0 rm -rf
.PHONY: fmt-sk
fmt-sk:
find . -path ./compiler/tests -not -prune -or -name \*.sk | parallel skfmt -i {}
.PHONY: fmt-c
fmt-c:
find . -path ./prelude/libbacktrace -not -prune -or -path ./sql/test/TPC-h/tnt-tpch -not -prune -or -regex '.*\.[ch]\(pp\)*' | parallel clang-format -i {}
.PHONY: fmt-js
fmt-js:
npx prettier --log-level warn --write .
.PHONY: fmt
fmt: fmt-sk fmt-c fmt-js
.PHONY: check-fmt
check-fmt: fmt
if ! git diff --quiet --exit-code; then echo "make fmt changed some files:"; git status --porcelain; exit 1; fi
# run the docs site locally at http://localhost:3000
.PHONY: run-docs
run-docs:
bun install
cd www && npm run start
# regenerate api docs served by run-docs from ts sources
.PHONY: docs
docs:
bun install
cd www && npx docusaurus generate-typedoc
# install the repo pre-commit hook locally
.git/hooks/pre-commit: bin/git_hooks/check_format.sh
ln -s $(PWD)/bin/git_hooks/check_format.sh .git/hooks/pre-commit
.PHONY: setup-git-hooks
setup-git-hooks: .git/hooks/pre-commit
# test targets
.PHONY: test
test:
$(MAKE) --keep-going SKARGO_PROFILE=dev SKDB_WASM=sql/target/wasm32-unknown-unknown/dev/skdb.wasm SKDB_BIN=sql/target/host/dev/skdb sktest-prelude test-native tstest-sql tstest-skipruntime-ts
.PHONY: test-native
test-native: build/skdb
cd sql/ && SKARGO_PROFILE=$(SKARGO_PROFILE) ./test_sql.sh \
|tee /tmp/native-test.out ; \
! grep -v '\*\|^[[:blank:]]*$$\|OK\|PASS' /tmp/native-test.out
.PHONY: test-client
test-client:
cd sql && make test-client
.PHONY: test-replication
test-replication: build/skdb
./sql/test/replication/test_pk.py
./sql/test/replication/test_no_pk.py
.PHONY: test-tpc
test-tpc: test
@echo ""
@echo "*******************************************************************************"
@echo "* TPC-H *"
@echo "*******************************************************************************"
@echo ""
@cd sql/test/TPC-h/ && ./test_tpch.sh
.PHONY: test-soak-priv
test-soak-priv: $(SKNPM_BIN) build/skdb build/init.sql npm
./sql/server/test/test_soak.sh
.PHONY: test-soak
test-soak:
$(MAKE) SKARGO_PROFILE=release test-soak-priv
# run targets
.PHONY: run-dev-server
run-dev-server: sql/target/host/dev/skdb build/init.sql
mkdir -p build
cp sql/target/host/dev/skdb build
(cd sql/server/dev && gradle --console plain run)
# useful for testing in a browser
build/index.html: sql/js/index.html
mkdir -p build
cp $^ $@
.PHONY: check-vite
check-vite: npm
rm -rf build/vitejs
cp -r sql/ts/vitejs build/vitejs
cd build/vitejs && npm install;
rm -r build/vitejs/node_modules/skdb
cp -r build/package/skdb build/vitejs/node_modules/
cd build/vitejs && npm run build
cd build/vitejs && node server.js
cd build/vitejs && npm run dev
.PHONY: test-bun
test-bun: npm
rm -rf build/bun
cp -r sql/ts/bun build/bun
cd build/bun && bun install;
rm -r build/bun/node_modules/skdb
cp -r build/package/skdb build/bun/node_modules/
cd build/bun && bun bun.js true && bun bun.js false
exbuild-%:
cd skipruntime-ts && make build-$*
exrun-%:
cd skipruntime-ts && make bunrun-$*
excheck-%:
cd skipruntime-ts && make check-$*
nexrun-%:
cd skipruntime-ts && make noderun-$*
explay-%:
cd skipruntime-ts && make bunplay-$*
nexplay-%:
cd skipruntime-ts && make nodeplay-$*
skcheck-%:
cd $* && skargo c --profile $(SKARGO_PROFILE)
skfmt-%:
cd $* && skargo fmt
sktest-%:
cd $* && skargo test --profile $(SKARGO_PROFILE)
skbuild-%:
cd $* && skargo b --profile $(SKARGO_PROFILE)
.PHONY: test-wasm
test-wasm:
cd sql && make test
## Backward Compatibility
.PHONY: test-skfs
test-skfs: sktest-prelude