forked from DegaLabs/collectibleswap-near
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (52 loc) · 1.72 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
NEAR_CONTRACT_BUILDER_IMAGE=nearprotocol/contract-builder
FARMING_DIR=nstable-farming-v2
FARMING_BUILDER_NAME=build_v2_nstable_farming
FARMING_RELEASE=nstable_farming_v2
EXCHANGE_DIR=nstable-exchange
EXCHANGE_BUILDER_NAME=build_nstable_exchange
EXCHANGE_RELEASE=nstable_exchange
test-all: test-exchange test-farming
build-farming:
$(call create_builder,${FARMING_BUILDER_NAME},${FARMING_DIR})
$(call start_builder,${FARMING_BUILDER_NAME})
$(call setup_builder,${FARMING_BUILDER_NAME})
test-farming: build-farming
cd ${FARMING_DIR} && RUSTFLAGS='-C link-arg=-s' cargo test
build-exchange:
$(call create_builder,${EXCHANGE_BUILDER_NAME},${EXCHANGE_DIR})
$(call start_builder,${EXCHANGE_BUILDER_NAME})
$(call setup_builder,${EXCHANGE_BUILDER_NAME})
test-exchange: build-exchange
cd ${EXCHANGE_DIR} && RUSTFLAGS='-C link-arg=-s' cargo test
res:
mkdir -p res
release-farming: res
$(call release_wasm,${FARMING_RELEASE})
release-exchange: res
$(call release_wasm,${EXCHANGE_RELEASE})
remove-builders:
$(call remove_builder,${FARMING_BUILDER_NAME}) || \
$(call remove_builder,${EXCHANGE_BUILDER_NAME})
define create_builder
docker ps -a | grep $(1) || docker create \
--mount type=bind,source=${PWD},target=/host \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
--name=$(1) \
-w /host/$(2) \
-e RUSTFLAGS='-C link-arg=-s' \
-it \
${NEAR_CONTRACT_BUILDER_IMAGE} \
/bin/bash
endef
define start_builder
docker ps | grep $(1) || docker start $(1)
endef
define setup_builder
docker exec $(1) /bin/bash _rust_setup.sh
endef
define remove_builder
docker stop $(1) && sleep 3 && docker rm $(1)
endef
define release_wasm
cp ${PWD}/target/wasm32-unknown-unknown/release/$(1).wasm ${PWD}/res/$(1)_release.wasm
endef