From b8902dc6037897c54c5a7573c11f5a90f6570a17 Mon Sep 17 00:00:00 2001 From: Wisaroot Lertthaweedech Date: Sat, 2 Aug 2025 17:17:00 +0700 Subject: [PATCH] feat: add rust setup --- Makefile | 8 ++++++++ rust/assert_setup_dev.sh | 40 ++++++++++++++++++++++++++++++++++++++++ rust/setup_dev.sh | 7 +++++++ 3 files changed, 55 insertions(+) create mode 100755 rust/assert_setup_dev.sh create mode 100755 rust/setup_dev.sh diff --git a/Makefile b/Makefile index eb4a953..c325f8a 100644 --- a/Makefile +++ b/Makefile @@ -18,3 +18,11 @@ lint: find . -type f -name "*.sh" -exec shfmt -w -i 6 {} + find . -type f -name "*.sh" -exec shellcheck {} + prettier --write "**/*.{json,yaml,yml,md}" + +rust_setup_dev: + chmod +x rust/setup_dev.sh + ./rust/setup_dev.sh + +rust_assert_setup_dev: + chmod +x rust/assert_setup_dev.sh + ./rust/assert_setup_dev.sh diff --git a/rust/assert_setup_dev.sh b/rust/assert_setup_dev.sh new file mode 100755 index 0000000..8c3bbfc --- /dev/null +++ b/rust/assert_setup_dev.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set -e + +echo "Rust: $(which rustc)" +echo "Cargo: $(which cargo)" +echo "Rustup: $(which rustup)" +echo "Rustdoc: $(which rustdoc)" +FAILED=0 + +if ! test "$(which rustc)" = "$HOME/.cargo/bin/rustc"; then + echo "❌ Rust: ERROR - not in ~/.cargo/bin" + FAILED=1 +else + echo "✅ Rust: OK" +fi +if ! test "$(which cargo)" = "$HOME/.cargo/bin/cargo"; then + echo "❌ Cargo: ERROR - not in ~/.cargo/bin" + FAILED=1 +else + echo "✅ Cargo: OK" +fi +if ! test "$(which rustup)" = "/opt/homebrew/bin/rustup"; then + echo "❌ Rustup: ERROR - not in /opt/homebrew/bin" + FAILED=1 +else + echo "✅ Rustup: OK" +fi +if ! test "$(which rustdoc)" = "$HOME/.cargo/bin/rustdoc"; then + echo "❌ Rustdoc: ERROR - not in ~/.cargo/bin" + FAILED=1 +else + echo "✅ Rustdoc: OK" +fi +if [ $FAILED -eq 1 ]; then + echo "❌ Setup assertion failed." + exit 1 +else + echo "✅ Setup assertion passed." +fi diff --git a/rust/setup_dev.sh b/rust/setup_dev.sh new file mode 100755 index 0000000..467f95a --- /dev/null +++ b/rust/setup_dev.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +brew install rustup +rustup-init -y +rustup default stable