Skip to content

Commit 815dcf9

Browse files
committed
Makefile: add setup-wasm-toolchain
1 parent 3477335 commit 815dcf9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# OpenMina Makefile
22

3+
NIGHTLY_RUST_VERSION = "nightly"
4+
35
.PHONY: help
46
help: ## Ask for help!
57
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@@ -62,6 +64,25 @@ format: ## Format code using rustfmt
6264
lint: ## Run linter (clippy)
6365
cargo clippy --all-targets -- -D warnings --allow clippy::mutable_key_type
6466

67+
.PHONY: setup-wasm-toolchain
68+
setup-wasm-toolchain: ## Setup the WebAssembly toolchain, using nightly
69+
@ARCH=$$(uname -m); \
70+
OS=$$(uname -s | tr A-Z a-z); \
71+
case $$OS in \
72+
linux) OS_PART="unknown-linux-gnu" ;; \
73+
darwin) OS_PART="apple-darwin" ;; \
74+
*) echo "Unsupported OS: $$OS" && exit 1 ;; \
75+
esac; \
76+
case $$ARCH in \
77+
x86_64) ARCH_PART="x86_64" ;; \
78+
aarch64) ARCH_PART="aarch64" ;; \
79+
arm64) ARCH_PART="aarch64" ;; \
80+
*) echo "Unsupported architecture: $$ARCH" && exit 1 ;; \
81+
esac; \
82+
TARGET="$$ARCH_PART-$$OS_PART"; \
83+
echo "Installing rust-src and rustfmt for ${NIGHTLY_RUST_VERSION}-$$TARGET with wasm32 target"; \
84+
rustup target add wasm32-unknown-unknown --toolchain ${NIGHTLY_RUST_VERSION}-$$TARGET
85+
6586
.PHONY: test
6687
test: ## Run tests
6788
cargo test

0 commit comments

Comments
 (0)