1
- PACKAGES =$(shell go list ./... | grep -v '/simulation')
2
1
VERSION ?= $(shell echo $(shell git describe --tags) | sed 's/^v//')
3
2
COMMIT := $(shell git log -1 --format='% H')
4
3
DOCKER := $(shell which docker)
5
4
DOCKER_BUF := $(DOCKER ) run --rm -v $(CURDIR ) :/workspace --workdir /workspace bufbuild/buf
6
5
6
+ # SPID and API_KEY are used for Intel SGX attestation
7
7
SPID ?= 00000000000000000000000000000000
8
8
API_KEY ?= FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
9
9
10
+ # Environment variables and build tags setup
10
11
LEDGER_ENABLED ?= true
11
12
BINDIR ?= $(GOPATH ) /bin
12
13
BUILD_PROFILE ?= release
@@ -22,24 +23,23 @@ DOCKER_TAG ?= latest
22
23
23
24
TM_SGX ?= true
24
25
26
+ # Paths for contracts and modules
25
27
CW_CONTRACTS_V010_PATH = ./cosmwasm/contracts/v010/
26
28
CW_CONTRACTS_V1_PATH = ./cosmwasm/contracts/v1/
27
-
28
29
TEST_CONTRACT_V010_PATH = ./cosmwasm/contracts/v010/compute-tests
29
30
TEST_CONTRACT_V1_PATH = ./cosmwasm/contracts/v1/compute-tests
30
-
31
31
TEST_COMPUTE_MODULE_PATH = ./x/compute/internal/keeper/testdata/
32
-
33
32
ENCLAVE_PATH = cosmwasm/enclaves/
34
33
EXECUTE_ENCLAVE_PATH = $(ENCLAVE_PATH ) /execute/
35
- DOCKER_BUILD_ARGS ?=
36
34
35
+ # Determine if Docker Buildx is available for multi-platform builds
36
+ DOCKER_BUILD_ARGS ?=
37
37
DOCKER_BUILDX_CHECK = $(@shell docker build --load test )
38
-
39
38
ifeq (Building,$(findstring Building,$(DOCKER_BUILDX_CHECK ) ) )
40
39
DOCKER_BUILD_ARGS += "--load"
41
40
endif
42
41
42
+ # Check and set the SGX_MODE to either HW or SW, error if not set
43
43
ifeq ($(SGX_MODE ) , HW)
44
44
ext := hw
45
45
else ifeq ($(SGX_MODE), SW)
48
48
$(error SGX_MODE must be either HW or SW)
49
49
endif
50
50
51
+ # Set CGO flags based on the selected database backend (unused - currently only cleveldb is supported)
51
52
ifeq ($(DB_BACKEND ) , rocksdb)
52
53
DB_BACKEND = rocksdb
53
54
DOCKER_CGO_LDFLAGS = "-L/usr/lib/x86_64-linux-gnu/ -lrocksdb -lstdc++ -llz4 -lm -lz -lbz2 -lsnappy"
63
64
64
65
CUR_DIR: =$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
65
66
67
+ # Build tags setup for various configurations like ledger, database, etc.
66
68
build_tags = netgo
67
69
ifeq ($(LEDGER_ENABLED ) ,true)
68
70
ifeq ($(OS),Windows_NT)
@@ -120,6 +122,7 @@ whitespace += $(whitespace)
120
122
comma := ,
121
123
build_tags_comma_sep := $(subst $(whitespace ) ,$(comma ) ,$(build_tags ) )
122
124
125
+ # Linker flags to embed version information and other metadata into the binaries
123
126
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=SecretNetwork \
124
127
-X github.com/cosmos/cosmos-sdk/version.AppName=secretd \
125
128
-X github.com/scrtlabs/SecretNetwork/cmd/secretcli/version.ClientName=secretcli \
@@ -151,6 +154,7 @@ go.sum: go.mod
151
154
@echo " --> Ensure dependencies have not been modified"
152
155
GO111MODULE=on go mod verify
153
156
157
+ # Build the CLI tool
154
158
build_cli :
155
159
go build -o secretcli -mod=readonly -tags " $( filter-out sgx, $( GO_TAGS) ) secretcli" -ldflags ' $(LD_FLAGS)' ./cmd/secretd
156
160
@@ -173,6 +177,7 @@ build-tm-secret-enclave:
173
177
rustup component add rust-src
174
178
SGX_MODE=$(SGX_MODE ) $(MAKE ) -C /tmp/tm-secret-enclave build
175
179
180
+ # Targets for building the cli on various platforms like Windows, macOS, Linux
176
181
build_windows_cli :
177
182
$(MAKE ) xgo_build_secretcli XGO_TARGET=windows/amd64
178
183
sudo mv github.com/scrtlabs/SecretNetwork-windows-* secretcli-windows-amd64.exe
@@ -195,6 +200,7 @@ build_linux_arm64_cli:
195
200
196
201
build_all : build-linux build_windows_cli build_macos_cli build_linux_arm64_cli
197
202
203
+ # Build Debian package
198
204
deb : build-linux deb-no-compile
199
205
200
206
deb-no-compile :
@@ -226,6 +232,7 @@ deb-no-compile:
226
232
dpkg-deb --build /tmp/SecretNetwork/deb/ .
227
233
-rm -rf /tmp/SecretNetwork
228
234
235
+ # Clean up generated files and reset the environment
229
236
clean :
230
237
-rm -rf /tmp/SecretNetwork
231
238
-rm -f ./secretcli*
@@ -247,6 +254,11 @@ clean:
247
254
$(MAKE ) -C $(TEST_CONTRACT_V1_PATH ) /test-compute-contract clean
248
255
$(MAKE ) -C $(TEST_CONTRACT_V1_PATH ) /test-compute-contract-v2 clean
249
256
257
+ # ##############################################################################
258
+ # ## Dockerized Build Targets ###
259
+ # ##############################################################################
260
+
261
+ # Build localsecret - dockerized local chain for development and testing. In this version SGX is ran in software/simulation mode
250
262
localsecret :
251
263
DOCKER_BUILDKIT=1 docker build \
252
264
--build-arg FEATURES=" ${FEATURES} ,debug-print,random,light-client-validation" \
@@ -309,6 +321,7 @@ build-testnet:
309
321
--target build-deb .
310
322
docker run -e VERSION=${VERSION} -v $(CUR_DIR ) /build:/build deb_build
311
323
324
+ # special targets for building a deb package that compiles a new secretd but takes the enclaves from the latest package - used for upgrades when we don't want to replace the enclave
312
325
build-mainnet-upgrade :
313
326
@mkdir build 2>&3 || true
314
327
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES=" verify-validator-whitelist,light-client-validation,production, ${FEATURES} " \
@@ -336,6 +349,8 @@ build-mainnet-upgrade:
336
349
-t deb_build \
337
350
--target build-deb-mainnet .
338
351
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build
352
+
353
+ # full mainnet build - will end up with a .deb package in the ./build folder
339
354
build-mainnet :
340
355
@mkdir build 2>&3 || true
341
356
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES=" verify-validator-whitelist,light-client-validation,production,random, ${FEATURES} " \
@@ -367,6 +382,7 @@ build-mainnet:
367
382
--target build-deb .
368
383
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build
369
384
385
+ # Build the hardware compatability checker - this is a binary that just runs attestation and provides details on the result
370
386
build-check-hw-tool :
371
387
@mkdir build 2>&3 || true
372
388
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES=" ${FEATURES} " \
@@ -383,23 +399,22 @@ build-check-hw-tool:
383
399
-t compile-check-hw-tool \
384
400
--target compile-check-hw-tool .
385
401
386
- # while developing:
402
+ # ##############################################################################
403
+ # ## Local Build Targets ###
404
+ # ##############################################################################
405
+
387
406
build-enclave :
388
407
$(MAKE ) -C $(EXECUTE_ENCLAVE_PATH ) enclave
389
408
390
- # while developing:
391
409
check-enclave :
392
410
$(MAKE ) -C $(EXECUTE_ENCLAVE_PATH ) check
393
411
394
- # while developing:
395
412
clippy-enclave :
396
413
$(MAKE ) -C $(EXECUTE_ENCLAVE_PATH ) clippy
397
414
398
- # while developing:
399
415
clean-enclave :
400
416
$(MAKE ) -C $(EXECUTE_ENCLAVE_PATH ) clean
401
417
402
- # while developing:
403
418
clippy : clippy-enclave
404
419
$(MAKE ) -C check-hw clippy
405
420
0 commit comments