-
Notifications
You must be signed in to change notification settings - Fork 44
/
Makefile
107 lines (86 loc) · 2.92 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
GOPATH ?= $(shell go env GOPATH)
NPM_DIR = $(shell npm config get prefix)
.PHONY: all
all: install
.PHONY: lint-go
lint-go:
./scripts/install-lint.sh
${GOPATH}/bin/golangci-lint run
.PHONY: lint-shell
lint-shell:
shellcheck --source-path=.:scripts scripts/*.sh scripts/*/*.sh
.PHONY: lint-solidity
lint-solidity:
"$(NPM_DIR)/bin/solhint" $$(find ethereum -name '*.sol' -not -path '**/@openzeppelin/**')
.PHONY: lint
lint: lint-go lint-shell lint-solidity
.PHONY: format-go
format-go:
test -x $(GOPATH)/bin/goimports || go install golang.org/x/tools/cmd/goimports@latest
$(GOPATH)/bin/goimports -local github.com/athanorlabs/atomic-swap -w .
.PHONY: format-shell
format-shell:
shfmt -w scripts/*.sh scripts/*/*.sh
.PHONY: format-solidity
format-solidity:
"$(NPM_DIR)/bin/prettier" --print-width 100 --write \
--plugin="$(NPM_DIR)/lib/node_modules/prettier-plugin-solidity/src/index.js" \
$$(find ethereum -name '*.sol' -not -path '**/@openzeppelin/**')
.PHONY: format
format: format-go format-shell format-solidity
.PHONY: test
test:
./scripts/run-unit-tests.sh 2>&1 | tee test.log
.PHONY: test-integration
test-integration:
./scripts/run-integration-tests.sh 2>&1 | tee test-integration.log
# Instead of building from the local checked-out source, this will install
# the most recent commit with a release tag. Use the most recent tagged release
# for production swaps.
.PHONY: build-release
build-release:
mkdir -p bin
GOBIN=$(PWD)/bin go install -tags=prod github.com/athanorlabs/atomic-swap/cmd/...@latest
# If you don't have go installed but do have docker, you can build the most
# recent release using docker.
.PHONY: build-release-in-docker
build-release-in-docker:
mkdir -p bin
docker run --rm -v "$(PWD)/bin:/go/bin" -v $(PWD)/Makefile:/go/Makefile "golang:1.20" bash -c \
"make build-release && chown $$(id -u):$$(id -g) bin/{swapd,swapcli,bootnode}"
# Install all the binaries into $HOME/go/bin (or alternative GOPATH bin directory)
.PHONY: install
install:
go install ./cmd/...
# Install swapd and swapcli into this directory (top of the project)
.PHONY: build
build:
./scripts/build.sh
# Test macos/arm build from linux. Use "make build" if compiling on macos.
.PHONY: build-darwin
build-darwin:
mkdir -p bin/
GOOS=darwin GOARCH=arm64 go build -o ./bin ./cmd/...
# Same as build, but also includes some lesser used binaries
.PHONY: build-all
build-all:
ALL=true $(MAKE) build
.PHONY: docker-images
docker-images:
scripts/docker-swapd/build-docker-image.sh
scripts/docker-bootnode/build-docker-image.sh
# Go bindings for solidity contracts
.PHONY: bindings
bindings:
./scripts/install-abigen.sh
./scripts/generate-bindings.sh
./ethereum/block/testdata/generate-bindings.sh
.PHONY: mock
mock:
test -x $(GOPATH)/bin/mockgen || go install github.com/golang/mock/[email protected]
go generate -run mockgen ./...
$(MAKE) format-go
# Deletes all executables matching the directory names in cmd/
.PHONY: clean
clean:
rm -r bin/