From f1a27fef99bf237651bac886d73565d4e3d7480e Mon Sep 17 00:00:00 2001 From: Alexandru Sardan Date: Thu, 11 Apr 2024 16:32:18 +0000 Subject: [PATCH] Makefile: fix rust smart contracts build The contracts built using `make build-contracts-rs` were not working on a production network because they included the `casper_print` FFI. This happened because of the way `cargo` optimizes builds of dependencies. Because one of the contracts had a requirement for the `test-support` feature, all contracts were built with the `casper-contract` that had that feature enabled (and which enabled the `casper_print` FFI). Now we build each smart contract idependently to make sure that never happens. Signed-off-by: Alexandru Sardan --- Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e0e8810b70..4c6ab104e7 100644 --- a/Makefile +++ b/Makefile @@ -33,17 +33,12 @@ CONTRACT_TARGET_DIR_AS = target_as build-contract-rs/%: cd smart_contracts/contracts && RUSTFLAGS=$(RUSTC_FLAGS) $(CARGO) build --verbose --release $(filter-out --release, $(CARGO_FLAGS)) --package $* - wasm-strip $(CONTRACT_TARGET_DIR)/$(subst -,_,$*).wasm 2>/dev/null | true .PHONY: build-all-contracts-rs -build-all-contracts-rs: - cd smart_contracts/contracts && \ - RUSTFLAGS=$(RUSTC_FLAGS) $(CARGO) build --verbose --release $(filter-out --release, $(CARGO_FLAGS)) $(patsubst %, -p %, $(ALL_CONTRACTS)) +build-all-contracts-rs: $(patsubst %, build-contract-rs/%, $(ALL_CONTRACTS)) .PHONY: build-client-contracts-rs -build-client-contracts-rs: - cd smart_contracts/contracts && \ - $(CARGO) build --release $(filter-out --release, $(CARGO_FLAGS)) $(patsubst %, -p %, $(CLIENT_CONTRACTS)) +build-client-contracts-rs: $(patsubst %, build-contract-rs/%, $(CLIENT_CONTRACTS)) strip-contract/%: wasm-strip $(CONTRACT_TARGET_DIR)/$(subst -,_,$*).wasm 2>/dev/null | true