forked from sandstorm-org/tempest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
131 lines (108 loc) · 2.58 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
##
## Variables
##
BUILDTOOL := _build/build-tool
BUILDTOOL_MAIN := cmd/build-tool/main.go
BUILDTOOL_PACKAGE := \
internal/build-tool/common.go \
internal/build-tool/config.go \
internal/build-tool/downloads.go \
internal/build-tool/tinygo.go \
TOOLCHAIN_DIR := ./toolchain
GO_VERSION := 1.23.3
GO := $(TOOLCHAIN_DIR)/go-$(GO_VERSION)/bin/go
GO_BUILD := $(GO) build
GO_GET := $(GO) get
TINYGO_VERSION := 0.35.0
TINYGO := $(TOOLCHAIN_DIR)/tinygo-$(TINYGO_VERSION)/bin/tinygo
##
## Targets
##
.PHONY: help
help:
@echo "Usage: make <target>"
@echo
@echo Targets:
@echo " build Build the project"
@echo " check Run project tests"
@echo " clean Remove build artifacts"
@echo " format Format the source files"
@echo " lint Run the linters"
@echo " nuke Remove build artifacts and configuration"
@echo " toolchain Download and set up the toolchain"
@echo " update-deps Update depedencies"
@echo
.PHONY: all
all: build
#
# Clean Targets
#
.PHONY: clean
clean:
cd c && $(MAKE) clean
rm -rf _build
rm -f \
go/internal/server/embed/*.wasm \
c/config.h \
go/internal/config/config.go
find * -type f -name '*.capnp.go' -delete
find * -type f -name '*.cgr' -delete
find * -type d -empty -delete
rm -f $(BUILDTOOL)
.PHONY: clean-toolchain
clean-toolchain:
rm -rf $(TOOLCHAIN_DIR)
.PHONY: nuke
nuke: clean clean-toolchain
rm -f config.json
# Used by scripts/bootstrap-build-tool.sh
if [ -n "${HOME}" ]; then rm -rf "${HOME}/.cache/tempest-build-tool"; fi
#
# Development Targets
#
.PHONY: format
format:
shfmt --write scripts/bootstrap-build-tool.sh
gofmt -l -w $(BUILDTOOL_MAIN) $(BUILDTOOL_PACKAGE)
.PHONY: lint
lint:
shellcheck scripts/bootstrap-build-tool.sh
#
# Tempest Target
#
.PHONY: build install dev test-app export-import
build install dev test-app export-import:
@# Just shell out to make.go.
go run internal/make/make.go $@
#
# Test Targets
#
.PHONY: check
check: all
./scripts/run-tests.sh
#
# Toolchain Targets
#
.PHONY: toolchain
toolchain: $(GO) $(TINYGO)
$(BUILDTOOL): $(GO)
$(GO_GET) ./internal/build-tool
$(GO_BUILD) -o $(BUILDTOOL) $(BUILDTOOL_SOURCE)
$(GO):
@echo Setting up Go $(GO_VERSION)
./scripts/bootstrap-build-tool.sh
$(TINYGO): $(BUILDTOOL)
@echo Setting up TinyGo $(TINYGO_VERSION)
$(BUILDTOOL) bootstrap-tinygo
#
# Update Targets
#
.PHONY: update-deps
update-deps:
# Update the versions of these in go.mod:
go get capnproto.org/go/capnp/v3
go get zenhack.net/go/util
go get zenhack.net/go/tea
go get zenhack.net/go/websocket-capnp
# and clean up:
go mod tidy