Skip to content

Commit 0f7e332

Browse files
committed
Makefile: add setup-wasm-toolchain
1 parent 8047e6a commit 0f7e332

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}'
@@ -90,6 +92,25 @@ format-md: ## Format all markdown files to wrap at 80 characters
9092
lint: ## Run linter (clippy)
9193
cargo clippy --all-targets -- -D warnings --allow clippy::mutable_key_type
9294

95+
.PHONY: setup-wasm-toolchain
96+
setup-wasm-toolchain: ## Setup the WebAssembly toolchain, using nightly
97+
@ARCH=$$(uname -m); \
98+
OS=$$(uname -s | tr A-Z a-z); \
99+
case $$OS in \
100+
linux) OS_PART="unknown-linux-gnu" ;; \
101+
darwin) OS_PART="apple-darwin" ;; \
102+
*) echo "Unsupported OS: $$OS" && exit 1 ;; \
103+
esac; \
104+
case $$ARCH in \
105+
x86_64) ARCH_PART="x86_64" ;; \
106+
aarch64) ARCH_PART="aarch64" ;; \
107+
arm64) ARCH_PART="aarch64" ;; \
108+
*) echo "Unsupported architecture: $$ARCH" && exit 1 ;; \
109+
esac; \
110+
TARGET="$$ARCH_PART-$$OS_PART"; \
111+
echo "Installing rust-src and rustfmt for ${NIGHTLY_RUST_VERSION}-$$TARGET with wasm32 target"; \
112+
rustup target add wasm32-unknown-unknown --toolchain ${NIGHTLY_RUST_VERSION}-$$TARGET
113+
93114
.PHONY: test
94115
test: ## Run tests
95116
cargo test

0 commit comments

Comments
 (0)