-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
176 lines (134 loc) · 5.08 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
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
170
171
172
173
174
175
176
PKG := github.com/BoltzExchange/boltz-client
VERSION := 2.3.5
GDK_VERSION = 0.73.3
GO_VERSION := 1.23.0
RUST_VERSION := 1.82.0
PKG_BOLTZD := github.com/BoltzExchange/boltz-client/v2/cmd/boltzd
PKG_BOLTZ_CLI := github.com/BoltzExchange/boltz-client/v2/cmd/boltzcli
GO_BIN := ${GOPATH}/bin
GOTEST := CGO_ENABLED=1 GO111MODULE=on go test -v -timeout 5m
GOBUILD := CGO_ENABLED=1 GO111MODULE=on go build -v
GORUN := CGO_ENABLED=1 GO111MODULE=on go run -v
GOINSTALL := CGO_ENABLED=1 GO111MODULE=on go install -v
COMMIT := $(shell git log --pretty=format:'%h' -n 1)
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT) -X $(PKG)/build.Version=$(VERSION) -w -s"
GREEN := "\\033[0;32m"
NC := "\\033[0m"
define print
echo $(GREEN)$1$(NC)
endef
default: build
#
# Dependencies
#
$(TOOLS_PATH):
eval export PATH="$PATH:$(go env GOPATH)/bin"
release:
git commit -a -m "chore: bump version to v$(VERSION)"
git tag -s v$(VERSION) -m "v$(VERSION)"
make changelog
git commit -a -m "chore: update changelog"
install-tools: $(TOOLS_PATH)
@$(call print, "Installing tools")
cat tools/tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
proto: $(TOOLS_PATH)
@$(call print, "Generating protosbufs")
eval cd boltzrpc && ./gen_protos.sh && cd ..
#
# Tests
#
unit:
@$(call print, "Running unit tests")
$(GOTEST) ./... -v -tags unit
integration: start-regtest
@$(call print, "Running integration tests")
$(GOTEST) ./... -v
download-regtest:
ifeq ("$(wildcard regtest/start.sh)","")
@$(call print, "Downloading regtest")
make submodules
cp regtest.override.yml regtest/docker-compose.override.yml
endif
start-regtest: download-regtest
@$(call print, "Starting regtest")
eval cd regtest && ./start.sh
restart-regtest: download-regtest
@$(call print, "Restarting regtest")
eval cd regtest && ./restart.sh
#
# Building
#
build-bolt12:
@$(call print, "Building bolt12")
cd internal/lightning/lib/bolt12 && cargo build --release
build: download-gdk build-bolt12
@$(call print, "Building boltz-client")
$(GOBUILD) $(ARGS) -o boltzd $(LDFLAGS) $(PKG_BOLTZD)
$(GOBUILD) $(ARGS) -o boltzcli $(LDFLAGS) $(PKG_BOLTZ_CLI)
static: download-gdk build-bolt12
@$(call print, "Building static boltz-client")
$(GOBUILD) -tags static -o boltzd $(LDFLAGS) $(PKG_BOLTZD)
$(GOBUILD) -tags static -o boltzcli $(LDFLAGS) $(PKG_BOLTZ_CLI)
daemon:
@$(call print, "running boltzd")
$(GORUN) $(LDFLAGS) $(PKG_BOLTZD)
cli:
@$(call print, "running boltzcli")
$(GORUN) $(LDFLAGS) $(PKG_BOLTZ_CLI)
install:
@$(call print, "Installing boltz-client")
$(GOINSTALL) $(LDFLAGS) $(PKG_BOLTZD)
$(GOINSTALL) $(LDFLAGS) $(PKG_BOLTZ_CLI)
deps: submodules
go mod vendor
cp -r ./go-secp256k1-zkp/secp256k1-zkp ./vendor/github.com/vulpemventures/go-secp256k1-zkp
# exclude the package and any lines including a # (#cgo, #include, etc.)
cd ./vendor/github.com/vulpemventures/go-secp256k1-zkp && \
sed -i '/#\|package/!s/secp256k1/go_secp256k1/g' *.go && \
find secp256k1-zkp -type f -name "*.c" -print0 | xargs -0 sed -i '/include/!s/secp256k1/go_secp256k1/g' && \
find secp256k1-zkp -type f -name "*.h" -print0 | xargs -0 sed -i '/include/!s/secp256k1/go_secp256k1/g'
download-gdk:
ifeq ("$(wildcard internal/onchain/wallet/lib/libgreen_gdk.so)","")
@$(call print, "Downloading gdk library")
@container_id=$$(docker create "boltz/gdk-ubuntu:$(GDK_VERSION)" true); \
docker cp "$$container_id:/" internal/onchain/wallet/lib/ && \
docker rm "$$container_id";
endif
#
# Utils
#
submodules:
@$(call print, "Updating submodules")
git submodule update --init --recursive
mockery:
@$(call print, "Generating mocks")
mockery
fmt:
@$(call print, "Formatting source")
gofmt -l -s -w .
lint:
@$(call print, "Linting source")
golangci-lint run -v
changelog:
@$(call print, "Updating changelog")
git-chglog --output CHANGELOG.md
PLATFORMS := linux/amd64,linux/arm64
DOCKER_CACHE := boltz/boltz-client:buildcache
DOCKER_ARGS := --platform $(PLATFORMS) --build-arg GO_VERSION=$(GO_VERSION) --build-arg GDK_VERSION=$(GDK_VERSION) --build-arg RUST_VERSION=$(RUST_VERSION) --cache-from type=registry,ref=$(DOCKER_CACHE) --cache-to type=registry,ref=$(DOCKER_CACHE),mode=max
docker:
@$(call print, "Building docker image")
docker buildx build --push -t boltz/boltz-client:$(VERSION) -t boltz/boltz-client:latest $(DOCKER_ARGS) .
binaries:
@$(call print, "Building binaries")
docker buildx build --output bin --target binaries $(DOCKER_ARGS) .
tar -czvf boltz-client-linux-amd64-v$(VERSION).tar.gz bin/linux_amd64
tar -czvf boltz-client-linux-arm64-v$(VERSION).tar.gz bin/linux_arm64
sha256sum boltz-client-*.tar.gz bin/**/* > boltz-client-manifest-v$(VERSION).txt
gdk-source: submodules
cd gdk && git checkout release_$(GDK_VERSION) && git apply ../gdk.patch
cp ./gdk/include/gdk.h ./onchain/wallet/include/gdk.h
build-gdk-builder: gdk-source
docker buildx build --push -t boltz/gdk-ubuntu-builder:latest -t boltz/gdk-ubuntu-builder:$(GDK_VERSION) $(DOCKER_ARGS) -f ./gdk/docker/ubuntu/Dockerfile ./gdk
build-gdk:
docker buildx build --push -t boltz/gdk-ubuntu:latest -t boltz/gdk-ubuntu:$(GDK_VERSION) -f gdk.Dockerfile $(DOCKER_ARGS) .
.PHONY: build binaries