-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
169 lines (119 loc) · 4.31 KB
/
Makefile
File metadata and controls
169 lines (119 loc) · 4.31 KB
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
PROJECT=tilerenderer
NODE_BIN=./meta/node_modules/.bin
all: check build
.PHONY: all
find = $(foreach dir,$(1),$(foreach d,$(wildcard $(dir)/*),$(call find,$(d),$(2))) $(wildcard $(dir)/$(strip $(2))))
SRC = $(call find, src, *.js)
BUILD = build/$(PROJECT).js build/$(PROJECT)-worker.js
DEBUG_FLAG ?= true
%/node_modules: %/package.json
pnpm -C $(@D) install
touch $@
.SECONDEXPANSION:
%/.dir:
mkdir --parent $(@D)
touch $@
build/min/package.json: package.json | $$(@D)/.dir
jq '{ version, type }' < $< > $@
GLSL = $(wildcard src/shaders/*.glsl)
build/min/src/shaders/%.glsl.js: src/shaders/%.glsl | $$(@D)/.dir meta/node_modules
$(NODE_BIN)/glsl-minify \
--preserveUniforms \
--preserveDefines \
--preserveVariables \
--output=source \
--esModule \
--outDir=build/min \
$<
PREBUILD = \
build/min/package.json \
$(GLSL:%.glsl=build/min/%.glsl.js)
prebuild: $(PREBUILD)
.PHONY: prebuild
check: lint test
.PHONY: check
build: $(PREBUILD)
build: $(BUILD)
.PHONY: build
dist: DEBUG_FLAG=false
dist: build
.PHONY: dist
DEPENDENCIES = meta/node_modules $(CURDIR)/node_modules
dependencies: | $(DEPENDENCIES)
define ESBUILD_OPTIONS
--define:global=globalThis \
--define:DEBUG=$(DEBUG_FLAG) \
--tree-shaking=true \
--minify \
--target=es2020 \
--metafile=${@:.js=.meta.json} \
--outfile=$@
endef
build/$(PROJECT).js: $(SRC) | dependencies
$(NODE_BIN)/esbuild --bundle src/index.js --global-name=mapboxgl $(ESBUILD_OPTIONS)
build/$(PROJECT)-worker.js: $(SRC) | dependencies
$(NODE_BIN)/esbuild --bundle src/worker.js $(ESBUILD_OPTIONS)
lint: | meta/node_modules
$(NODE_BIN)/biome ci
.PHONY: lint
format: | meta/node_modules
$(NODE_BIN)/biome check --write
.PHONY: format
test: test-unit prebuild
test-integration: test-query test-render
TEST_REPORTER ?= dot
DEPENDENCIES_TEST = test/node_modules
test-unit: dependencies $(DEPENDENCIES_TEST)
node --test --test-reporter=$(TEST_REPORTER) "test/unit/**/*.test.js"
RENDER_TESTS := "test/integration/render/tests/*/render.test.js"
QUERY_TESTS := "test/integration/query/tests/*/query.test.js"
TEST_INTG_OPTS += --test-concurrency=true
ifdef TEST_FILTER
TEST_INTG_OPTS += --test-name-pattern=$(TEST_FILTER)
# when filter is provided it is more efficient to run main test file
RENDER_TESTS := "test/integration/render/tests/render-all.test.js"
QUERY_TESTS := "test/integration/query/tests/query-all.test.js"
endif
ifdef TEST_REPORTER
TEST_INTG_OPTS += --test-reporter=$(TEST_REPORTER)
endif
test-render: dependencies dependencies-integration render-test-files
node --test $(TEST_INTG_OPTS) $(RENDER_TESTS)
test-query: dependencies dependencies-integration query-test-files
node --test $(TEST_INTG_OPTS) $(QUERY_TESTS)
DEPENDENCIES_INTEGRATION = test/integration/node_modules
dependencies-integration: | $(DEPENDENCIES_TEST) $(DEPENDENCIES_INTEGRATION)
RENDER_TEST_FILES := $(shell find test/integration/render/tests -mindepth 1 -maxdepth 1 -type d)
render-test-files: $(patsubst %, %/render.test.js, $(RENDER_TEST_FILES))
%/render.test.js: test/integration/lib/render/template.js
@cp $^ $@
.SECONDARY: render-test-files
QUERY_TEST_FILES := $(shell find test/integration/query/tests -mindepth 1 -maxdepth 1 -type d)
query-test-files: $(patsubst %, %/query.test.js, $(QUERY_TEST_FILES))
%/query.test.js: test/integration/lib/query/template.js
@cp $^ $@
.SECONDARY: query-test-files
test-coverage: dependencies dependencies-integration render-test-files query-test-files
node --test --experimental-test-coverage \
--test-concurrency=true \
"test/unit/**/*.test.js" \
"test/integration/render/tests/*/render.test.js" \
"test/integration/query/tests/*/query.test.js"
.PHONY: dependencies-integration test test-integration test-unit test-render test-query test-coverage
update-test-fixtures: export UPDATE=1
update-test-fixtures: test-integration format
.PHONY: update-test-fixtures
ALL_DEPENDENCIES = $(DEPENDENCIES) $(DEPENDENCIES_TEST) $(DEPENDENCIES_INTEGRATION)
distclean: clean clean-test
rm -fr $(ALL_DEPENDENCIES) $(ALL_DEPENDENCIES:node_modules=pnpm-lock.yaml)
clean:
rm -fr build
clean-test:
git clean --quiet -X -f test/integration/*/tests
.PHONY: clean clean-test distclean
generate-struct-arrays:
node meta/bin/generate-struct-arrays.js
.PHONY: generate-struct-arrays
generate-style-code:
node meta/bin/generate-style-code.js
.PHONY: generate-style-code