forked from canopy-network/canopy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
194 lines (155 loc) · 7.03 KB
/
Makefile
File metadata and controls
194 lines (155 loc) · 7.03 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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Variables
GO_BIN_DIR := ~/go/bin
CLI_DIR := ./cmd/main/...
AUTO_UPDATE_DIR := ./cmd/auto-update/...
WALLET_DIR := ./cmd/rpc/web/wallet
EXPLORER_DIR := ./cmd/rpc/web/explorer
DOCKER_DIR := ./.docker/compose.yaml
# ==================================================================================== #
# HELPERS
# ==================================================================================== #
## help: print each command's help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
# Targets, this is a list of all available commands which can be executed using the make command.
.PHONY: build/canopy build/canopy-full build/wallet build/explorer build/auto-update build/auto-update-local run/auto-update run/auto-update-build run/auto-update-test test/all dev/deps docker/up \
docker/down docker/build docker/up-fast docker/down docker/logs \
build/plugin build/kotlin-plugin build/go-plugin build/all-plugins docker/plugin \
docker/run docker/run-kotlin docker/run-go docker/run-typescript docker/run-python docker/run-csharp
# ==================================================================================== #
# BUILDING
# ==================================================================================== #
## build/canopy: build the canopy binary into the GO_BIN_DIR
build/canopy:
go build -o $(GO_BIN_DIR)/canopy $(CLI_DIR)
## build/canopy-full: build the canopy binary and its wallet and explorer altogether
build/canopy-full: build/wallet build/explorer build/canopy
## build/wallet: build the canopy's wallet project
build/wallet:
npm install --prefix $(WALLET_DIR) && npm run build --prefix $(WALLET_DIR)
## build/explorer: build the canopy's explorer project
build/explorer:
npm install --prefix $(EXPLORER_DIR) && npm run build --prefix $(EXPLORER_DIR)
## build/auto-update: build the canopy auto-update binary into the GO_BIN_DIR
build/auto-update:
go build -o $(GO_BIN_DIR)/canopy-auto-update $(AUTO_UPDATE_DIR)
## build/auto-update-local: build canopy CLI to ./cli and auto-update binary for local development
build/auto-update-local:
go build -o ./cli $(CLI_DIR)
go build -o $(GO_BIN_DIR)/canopy-auto-update $(AUTO_UPDATE_DIR)
## run/auto-update: run the canopy auto-update binary with 'start' command (requires ./cli to exist)
run/auto-update:
BIN_PATH=./cli go run $(AUTO_UPDATE_DIR) start
## run/auto-update-build: build canopy CLI to ./cli and then run auto-update
run/auto-update-build: build/auto-update-local
BIN_PATH=./cli go run $(AUTO_UPDATE_DIR) start
# ==================================================================================== #
# TESTING
# ==================================================================================== #
## test/all: run all canopy tests
test/all:
go test ./... -p=1
## test/fuzz: run all canopy fuzz tests individually
test/fuzz:
# Golang currently does not support multiple fuzz targets, so each need to be called individually
# For more information check the open issue: https://github.com/golang/go/issues/46312
go test -fuzz=FuzzKeyDecodeEncode ./store -fuzztime=5s
go test -fuzz=FuzzBytesToBits ./store -fuzztime=5s
# ==================================================================================== #
# DEVELOPMENT
# ==================================================================================== #
## dev/deps: install all dependencies on the project's directory
dev/deps:
go mod vendor
# Detect OS to run the docker compose command, this is because Docker for MacOS does not support the
# modern docker compose command and still uses the legacy docker-compose
ifeq ($(shell uname -s),Darwin)
DOCKER_COMPOSE_CMD = docker-compose
else
DOCKER_COMPOSE_CMD = docker compose
endif
## docker/build: build the compose containers
docker/build:
$(DOCKER_COMPOSE_CMD) -f $(DOCKER_DIR) build
## docker/up: build and start the compose containers in detached mode
docker/up:
$(DOCKER_COMPOSE_CMD) -f $(DOCKER_DIR) down && \
$(DOCKER_COMPOSE_CMD) -f $(DOCKER_DIR) up --build -d
## docker/down: stop the compose containers
docker/down:
$(DOCKER_COMPOSE_CMD) -f $(DOCKER_DIR) down
## docker/up-fast: build and start the compose containers in detached mode without rebuilding
docker/up-fast:
$(DOCKER_COMPOSE_CMD) -f $(DOCKER_DIR) down && \
$(DOCKER_COMPOSE_CMD) -f $(DOCKER_DIR) up -d
## docker/logs: show the latest logs of the compose containers
docker/logs:
$(DOCKER_COMPOSE_CMD) -f $(DOCKER_DIR) logs -f --tail=1000
# ==================================================================================== #
# PLUGINS
# ==================================================================================== #
# Plugin selection: make build/plugin PLUGIN=kotlin
PLUGIN ?= kotlin
## build/plugin: build a specific plugin (PLUGIN=kotlin|go|typescript|python|csharp|all)
build/plugin:
ifeq ($(PLUGIN),kotlin)
cd plugin/kotlin && ./gradlew fatJar --no-daemon
else ifeq ($(PLUGIN),go)
cd plugin/go && go build -o go-plugin .
else ifeq ($(PLUGIN),typescript)
cd plugin/typescript && npm ci && npm run build:all
else ifeq ($(PLUGIN),python)
cd plugin/python && make dev
else ifeq ($(PLUGIN),csharp)
cd plugin/csharp && rm -rf bin && dotnet publish -c Release -r linux-x64 --self-contained true -o bin
else ifeq ($(PLUGIN),all)
$(MAKE) build/plugin PLUGIN=go
$(MAKE) build/plugin PLUGIN=kotlin
$(MAKE) build/plugin PLUGIN=typescript
$(MAKE) build/plugin PLUGIN=python
$(MAKE) build/plugin PLUGIN=csharp
else
@echo "Unknown plugin: $(PLUGIN). Options: kotlin, go, typescript, python, csharp, all"
@exit 1
endif
## build/kotlin-plugin: build the Kotlin plugin
build/kotlin-plugin:
$(MAKE) build/plugin PLUGIN=kotlin
## build/go-plugin: build the Go plugin
build/go-plugin:
$(MAKE) build/plugin PLUGIN=go
## build/typescript-plugin: build the TypeScript plugin
build/typescript-plugin:
$(MAKE) build/plugin PLUGIN=typescript
## build/python-plugin: build the Python plugin
build/python-plugin:
$(MAKE) build/plugin PLUGIN=python
## build/csharp-plugin: build the C# plugin
build/csharp-plugin:
$(MAKE) build/plugin PLUGIN=csharp
## build/all-plugins: build all plugins
build/all-plugins:
$(MAKE) build/plugin PLUGIN=all
## docker/plugin: build Docker image with specific plugin (PLUGIN=kotlin|go|typescript|python|csharp)
docker/plugin:
docker build -f plugin/$(PLUGIN)/Dockerfile -t canopy-$(PLUGIN) .
## docker/run: run Docker container with specific plugin (PLUGIN=kotlin|go|typescript|python|csharp)
docker/run:
docker run -v ~/.canopy:/root/.canopy canopy-$(PLUGIN)
## docker/run-kotlin: run Kotlin plugin container
docker/run-kotlin:
docker run -v ~/.canopy:/root/.canopy canopy-kotlin
## docker/run-go: run Go plugin container
docker/run-go:
docker run -v ~/.canopy:/root/.canopy canopy-go
## docker/run-typescript: run TypeScript plugin container
docker/run-typescript:
docker run -v ~/.canopy:/root/.canopy canopy-typescript
## docker/run-python: run Python plugin container
docker/run-python:
docker run -v ~/.canopy:/root/.canopy canopy-python
## docker/run-csharp: run C# plugin container
docker/run-csharp:
docker run -v ~/.canopy:/root/.canopy canopy-csharp