forked from Near-Bridge-Lab/btc-bridge
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (69 loc) · 3.34 KB
/
Makefile
File metadata and controls
91 lines (69 loc) · 3.34 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
MAKEFILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
#INT_OPTIONS = -D warnings -D clippy::pedantic -A clippy::must_use_candidate -A clippy::used_underscore_binding -A clippy::needless_range_loop //TODO: enable it later
BRIDGE_MANIFEST := $(MAKEFILE_DIR)/contracts/satoshi-bridge/Cargo.toml
RFLAGS="-C link-arg=-s"
FEATURES = bitcoin zcash
release: $(addprefix build-,$(FEATURES))
$(call build_release_wasm,nbtc,nbtc)
build-local: $(addprefix build-local-,$(FEATURES)) nbtc mock-chain-signatures mock-btc-light-client mock-dapp
lint: $(addprefix clippy-,$(FEATURES)) $(addprefix fmt-,$(FEATURES))
@cargo fmt --all
@cargo clippy -- $(LINT_OPTIONS)
test: build-local $(addprefix test-,$(FEATURES))
$(foreach feature,$(FEATURES), \
$(eval build-$(feature): ; \
cargo near build reproducible-wasm --variant "$(feature)" --manifest-path $(BRIDGE_MANIFEST) && \
mkdir -p res && mv ./target/near/satoshi_bridge/satoshi_bridge.wasm ./res/$(feature)_bridge_release.wasm \
) \
)
$(foreach feature,$(FEATURES), \
$(eval build-local-$(feature): ; \
cargo near build non-reproducible-wasm --features "$(feature)" --manifest-path $(BRIDGE_MANIFEST) --no-abi && \
mkdir -p res && mv ./target/near/satoshi_bridge/satoshi_bridge.wasm ./res/$(feature)_bridge.wasm \
) \
)
$(foreach feature,$(FEATURES), \
$(eval clippy-$(feature): ; cargo clippy --no-default-features --features "$(feature)" --manifest-path $(BRIDGE_MANIFEST) -- $(LINT_OPTIONS)) \
)
$(foreach feature,$(FEATURES), \
$(eval fmt-$(feature): ; cargo fmt --all --check --manifest-path $(BRIDGE_MANIFEST)) \
)
$(foreach feature,$(FEATURES), \
$(eval test-$(feature): ; cargo test --no-default-features --features "$(feature)" --manifest-path $(BRIDGE_MANIFEST)) \
)
mock-dapp: contracts/mock-dapp
$(call local_build_wasm,mock-dapp,mock_dapp)
mock-chain-signatures: contracts/mock-chain-signatures
$(call local_build_wasm,mock-chain-signatures,mock_chain_signatures)
mock-btc-light-client: contracts/mock-btc-light-client
$(call local_build_wasm,mock-btc-light-client,mock_btc_light_client)
nbtc: contracts/nbtc
$(call local_build_wasm,nbtc,nbtc)
define local_build_wasm
$(eval PACKAGE_NAME := $(1))
$(eval WASM_NAME := $(2))
@mkdir -p res
@rustup target add wasm32-unknown-unknown
@cargo near build non-reproducible-wasm --manifest-path ./contracts/${PACKAGE_NAME}/Cargo.toml --locked --no-abi
@cp target/near/${WASM_NAME}/$(WASM_NAME).wasm ./res/$(WASM_NAME).wasm
endef
define build_release_wasm
$(eval PACKAGE_NAME := $(1))
$(eval WASM_NAME := $(2))
@mkdir -p res
@rustup target add wasm32-unknown-unknown
@cargo near build reproducible-wasm --manifest-path ./contracts/${PACKAGE_NAME}/Cargo.toml
@cp target/near/${WASM_NAME}/$(WASM_NAME).wasm ./res/$(WASM_NAME)_release.wasm
endef
define build_release_zcash_wasm
@mkdir -p res
@rustup target add wasm32-unknown-unknown
@cargo near build reproducible-wasm --manifest-path ./contracts/satoshi-bridge/Cargo.toml --variant zcash
@cp target/near/satoshi_bridge/satoshi_bridge.wasm ./res/zcash_connector_release.wasm
endef
define local_build_zcash_wasm
@mkdir -p res
@rustup target add wasm32-unknown-unknown
@cargo near build non-reproducible-wasm --manifest-path ./contracts/satoshi-bridge/Cargo.toml --locked --no-abi --no-default-features --features zcash
@cp target/near/satoshi_bridge/satoshi_bridge.wasm ./res/zcash.wasm
endef