-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (39 loc) · 1.15 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
# Set a sensible default for the $GOPATH in case it's not exported.
# If you're seeing path errors, try exporting your GOPATH.
ifeq ($(origin GOPATH), undefined)
GOPATH := $(HOME)/go
endif
# Use gotip if available
ifeq (, $(shell which gotip))
GO := go
else
GO := gotip
endif
api_dir := ./proto/api
example_file := ./example/example
test_dir := ./test/
wasm_dir := ${test_dir}/wasm
wasm_file := ${wasm_dir}/test.wasm
.PHONY: all test clean example
all: capnp example test
clean: capnp-clean example-clean test-clean
capnp: capnp-raft
# N.B.: compiling capnp schemas requires having capnproto.org/go/capnp/v3 installed
# on the GOPATH.
capnp-raft:
@mkdir -p ${api_dir}
@capnp compile -I$(GOPATH)/src/capnproto.org/go/capnp/v3/std -ogo:${api_dir} --src-prefix=proto proto/raft.capnp
capnp-clean:
@rm -rf ${api_dir}
example:
@${GO} build -o ${example_file} ./example
example-clean:
@rm -rf ${example_file}
test: test-wasm example example-clean
# Test that everything can be compiled to wasm
test-wasm:
@mkdir -p ${wasm_dir}
@env GOOS=wasip1 GOARCH=wasm ${GO} build -o ${wasm_file} ./example
@rm -rf ${wasm_dir}
test-clean:
@rm -rf ${wasm_dir}