-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (70 loc) · 2.77 KB
/
Copy pathMakefile
File metadata and controls
93 lines (70 loc) · 2.77 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
# wmtiles build orchestration.
#
# The repo contains only source. Build artifacts (testdata fixtures, viewer
# bundle, library dist, CLI binary) are produced by these targets.
#
# Usage:
# make produce everything needed to run the CLI ($(BIN))
# make test run all tests (Go + Bun)
# make typecheck typecheck both TS packages
# make clean remove all generated artifacts
BIN := wmtiles
.DEFAULT_GOAL := all
# ────── meta targets ──────
.PHONY: all test typecheck clean
all: $(BIN)
test: testdata viewer
go test -race ./...
bun -F wmtiles test
typecheck:
bun run typecheck
clean:
rm -rf wmtiles-js/dist
rm -f wmtiles-js/.dist.stamp
rm -rf cmd/wmtiles/web/dist
rm -rf format/testdata
rm -f $(BIN)
# ────── primitives ──────
# bun install runs once; .stamp lets make track freshness.
node_modules/.stamp: package.json bun.lock wmtiles-js/package.json cmd/wmtiles/web/package.json
bun install --frozen-lockfile
touch $@
# Recursive *.ts under a directory (handles `render/` and `adapters/` subdirs
# that the flat `wildcard` glob misses).
rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
.PHONY: deps
deps: node_modules/.stamp
# testdata is regenerated whenever cmd/gen-testdata changes.
TESTDATA_FILES := format/testdata/minimal.wmt format/testdata/extended.wmt \
format/testdata/compacted.wmt format/testdata/crc_corrupted.wmt \
format/testdata/multistep.wmt
$(TESTDATA_FILES): cmd/gen-testdata/main.go
mkdir -p format/testdata
go run ./cmd/gen-testdata
.PHONY: testdata
testdata: $(TESTDATA_FILES)
# Library bundle (ESM + CJS + .d.ts). The viewer imports the package entry
# point, which resolves to dist just like published consumers do.
LIB_DIST := wmtiles-js/dist/index.js wmtiles-js/dist/index.cjs wmtiles-js/dist/index.d.ts
LIB_STAMP := wmtiles-js/.dist.stamp
LIB_SRC := $(call rwildcard,wmtiles-js/src/,*.ts)
$(LIB_STAMP): node_modules/.stamp $(LIB_SRC)
bun -F wmtiles build
touch $@
$(LIB_DIST): $(LIB_STAMP)
.PHONY: lib
lib: $(LIB_STAMP)
# Viewer bundle. Triggered when viewer or library source changes.
VIEWER_DIST := cmd/wmtiles/web/dist/viewer.js
VIEWER_SRC := $(call rwildcard,cmd/wmtiles/web/src/,*.ts) cmd/wmtiles/web/index.html \
$(call rwildcard,wmtiles-js/src/,*.ts)
$(VIEWER_DIST): node_modules/.stamp $(LIB_STAMP) $(VIEWER_SRC)
bun -F wmtiles-viewer build
.PHONY: viewer
viewer: $(VIEWER_DIST)
# CLI binary embeds VIEWER_DIST. The `embed` build tag activates
# cmd/wmtiles/web/embed.go (the no-tag default uses embed_stub.go and
# omits the viewer, which keeps the rest of the Go module buildable
# without bun).
$(BIN): $(VIEWER_DIST) $(wildcard **/*.go)
go build -tags embed -o $@ ./cmd/wmtiles/