-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add scrypto install shell scripts
Showing
3 changed files
with
335 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#!/bin/bash | ||
|
||
# Exit on error | ||
set -e | ||
|
||
# Colors for output | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
BLUE='\033[0;34m' | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # No Color | ||
|
||
# Function to log messages with colors | ||
log() { | ||
local level=$1 | ||
shift | ||
case $level in | ||
"INFO") echo -e "${BLUE}[INFO]${NC} $*" ;; | ||
"SUCCESS") echo -e "${GREEN}[SUCCESS]${NC} $*" ;; | ||
"ERROR") echo -e "${RED}[ERROR]${NC} $*" ;; | ||
"WARN") echo -e "${YELLOW}[WARN]${NC} $*" ;; | ||
esac | ||
} | ||
|
||
# Function to check if command exists | ||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
# Function to check system dependencies | ||
check_dependencies() { | ||
log "INFO" "Checking system dependencies..." | ||
|
||
# Check if we're on a Debian-based system | ||
if ! command_exists apt-get; then | ||
log "ERROR" "This script requires apt-get (Debian/Ubuntu). For other distributions, please modify the script accordingly." | ||
exit 1 | ||
fi | ||
|
||
# Check if sudo is available | ||
if ! command_exists sudo; then | ||
log "ERROR" "This script requires sudo privileges." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function to install LLVM and build essentials | ||
install_llvm() { | ||
log "INFO" "Installing LLVM and build essentials..." | ||
|
||
# Update package list | ||
sudo apt-get update | ||
|
||
# Install build essentials and LLVM | ||
sudo apt-get install -y clang build-essential llvm | ||
|
||
if [ $? -eq 0 ]; then | ||
log "SUCCESS" "LLVM and build essentials installed successfully" | ||
else | ||
log "ERROR" "Failed to install LLVM and build essentials" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function to install Rust | ||
install_rust() { | ||
log "INFO" "Installing Rust..." | ||
|
||
# Download and install Rust with specific toolchain | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=1.77.2 -y | ||
|
||
if [ $? -eq 0 ]; then | ||
log "SUCCESS" "Rust installed successfully" | ||
else | ||
log "ERROR" "Failed to install Rust" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function to setup Cargo environment | ||
setup_cargo() { | ||
log "INFO" "Setting up Cargo environment..." | ||
|
||
# Source cargo environment | ||
source "$HOME/.cargo/env" | ||
|
||
if command_exists cargo; then | ||
log "SUCCESS" "Cargo environment setup successfully" | ||
else | ||
log "ERROR" "Failed to setup Cargo environment" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function to add WebAssembly target | ||
add_wasm_target() { | ||
log "INFO" "Adding WebAssembly target..." | ||
|
||
rustup target add wasm32-unknown-unknown | ||
|
||
if [ $? -eq 0 ]; then | ||
log "SUCCESS" "WebAssembly target added successfully" | ||
else | ||
log "ERROR" "Failed to add WebAssembly target" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function to install Radix tools | ||
install_radix_tools() { | ||
log "INFO" "Installing Radix Engine Simulator and CLI tools..." | ||
|
||
cargo install --force [email protected] | ||
|
||
if [ $? -eq 0 ]; then | ||
log "SUCCESS" "Radix tools installed successfully" | ||
else | ||
log "ERROR" "Failed to install Radix tools" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Main installation process | ||
main() { | ||
log "INFO" "Starting installation process..." | ||
|
||
# Check system dependencies | ||
check_dependencies | ||
|
||
# Install components | ||
install_llvm | ||
install_rust | ||
setup_cargo | ||
add_wasm_target | ||
install_radix_tools | ||
|
||
# Final success message | ||
log "SUCCESS" "Installation completed successfully!" | ||
log "INFO" "Please restart your terminal or run: source $HOME/.cargo/env" | ||
|
||
# Verify installations | ||
log "INFO" "Verifying installations..." | ||
echo -e "\nVersions installed:" | ||
echo -e "LLVM: $(clang --version | head -n 1)" | ||
echo -e "Rust: $(rustc --version)" | ||
echo -e "Cargo: $(cargo --version)" | ||
} | ||
|
||
# Run main function | ||
main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
# Print commands and exit on errors | ||
set -ex | ||
|
||
# Colors for output | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
BLUE='\033[0;34m' | ||
NC='\033[0m' # No Color | ||
|
||
echo -e "${BLUE}Starting installation process...${NC}" | ||
|
||
# Function to check if a command was successful | ||
check_status() { | ||
if [ $? -eq 0 ]; then | ||
echo -e "${GREEN}✓ $1 successful${NC}" | ||
else | ||
echo -e "${RED}✗ $1 failed${NC}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Install Xcode Command Line Tools | ||
echo -e "\n${BLUE}Installing Xcode Command Line Tools...${NC}" | ||
xcode-select --install 2>/dev/null || true | ||
check_status "Xcode Command Line Tools installation" | ||
|
||
# Install cmake and LLVM | ||
echo -e "\n${BLUE}Installing cmake and LLVM...${NC}" | ||
brew install cmake llvm@17 | ||
check_status "cmake and LLVM installation" | ||
|
||
# Detect shell and configure appropriate rc file | ||
SHELL_CONFIG="" | ||
if [[ "$SHELL" == */bin/zsh ]]; then | ||
SHELL_CONFIG="$HOME/.zshrc" | ||
elif [[ "$SHELL" == */bin/bash ]]; then | ||
SHELL_CONFIG="$HOME/.profile" | ||
else | ||
echo -e "${RED}Unsupported shell: $SHELL${NC}" | ||
exit 1 | ||
fi | ||
|
||
# Add LLVM to PATH | ||
echo -e "\n${BLUE}Configuring LLVM in $SHELL_CONFIG...${NC}" | ||
if ! grep -q "$(brew --prefix llvm@17)/bin" "$SHELL_CONFIG"; then | ||
echo 'PATH="$(brew --prefix llvm@17)/bin:$PATH"' >> "$SHELL_CONFIG" | ||
fi | ||
check_status "LLVM path configuration" | ||
|
||
# Install Rust | ||
echo -e "\n${BLUE}Installing Rust...${NC}" | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=1.77.2 -y | ||
check_status "Rust installation" | ||
|
||
# Source cargo environment | ||
echo -e "\n${BLUE}Enabling cargo in current shell...${NC}" | ||
source "$HOME/.cargo/env" | ||
check_status "Cargo environment setup" | ||
|
||
# Add WebAssembly target | ||
echo -e "\n${BLUE}Adding WebAssembly target...${NC}" | ||
rustup target add wasm32-unknown-unknown | ||
check_status "WebAssembly target installation" | ||
|
||
# Install Radix Engine Simulator and CLI tools | ||
echo -e "\n${BLUE}Installing Radix Engine Simulator and CLI tools...${NC}" | ||
cargo install --force [email protected] | ||
check_status "Radix tools installation" | ||
|
||
echo -e "\n${GREEN}Installation complete! Please restart your terminal or run:${NC}" | ||
echo -e "source $SHELL_CONFIG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Requires PowerShell running as Administrator | ||
#Requires -RunAsAdministrator | ||
|
||
# Script configuration | ||
$ErrorActionPreference = "Stop" | ||
$ProgressPreference = "SilentlyContinue" # Speeds up downloads | ||
|
||
# Colors for output | ||
function Write-ColorOutput($ForegroundColor) { | ||
$fc = $host.UI.RawUI.ForegroundColor | ||
$host.UI.RawUI.ForegroundColor = $ForegroundColor | ||
if ($args) { | ||
Write-Output $args | ||
} | ||
$host.UI.RawUI.ForegroundColor = $fc | ||
} | ||
|
||
function Install-IfNotPresent { | ||
param ( | ||
[string]$Name, | ||
[string]$Command, | ||
[scriptblock]$InstallScript | ||
) | ||
|
||
Write-ColorOutput Yellow "Checking for $Name..." | ||
if (!(Get-Command $Command -ErrorAction SilentlyContinue)) { | ||
Write-ColorOutput Cyan "Installing $Name..." | ||
& $InstallScript | ||
if ($LASTEXITCODE -ne 0) { | ||
Write-ColorOutput Red "Failed to install $Name" | ||
exit 1 | ||
} | ||
Write-ColorOutput Green "$Name installed successfully" | ||
} else { | ||
Write-ColorOutput Green "$Name is already installed" | ||
} | ||
} | ||
|
||
# Check if running as admin | ||
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | ||
Write-ColorOutput Red "Please run this script as Administrator" | ||
exit 1 | ||
} | ||
|
||
# 1. Install Git if not present | ||
Install-IfNotPresent "Git" "git" { | ||
# Using winget for Git installation | ||
winget install --id Git.Git -e --source winget | ||
# Enable long paths | ||
git config --system core.longpaths true | ||
} | ||
|
||
# 2. Install Visual Studio Build Tools | ||
$vsInstallerPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" | ||
if (!(Test-Path $vsInstallerPath)) { | ||
Write-ColorOutput Cyan "Downloading Visual Studio Build Tools 2022..." | ||
$vsUrl = "https://aka.ms/vs/17/release/vs_buildtools.exe" | ||
$vsInstaller = "$env:TEMP\vs_buildtools.exe" | ||
Invoke-WebRequest -Uri $vsUrl -OutFile $vsInstaller | ||
|
||
Write-ColorOutput Cyan "Installing Visual Studio Build Tools with C++ support..." | ||
Start-Process -Wait -FilePath $vsInstaller -ArgumentList "--quiet", "--wait", "--norestart", "--nocache", ` | ||
"--installPath", "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools", ` | ||
"--add", "Microsoft.VisualStudio.Workload.VCTools", ` | ||
"--includeRecommended" | ||
|
||
Remove-Item $vsInstaller | ||
} | ||
|
||
# 3. Install LLVM | ||
$llvmVersion = "17.0.6" | ||
Install-IfNotPresent "LLVM" "clang" { | ||
Write-ColorOutput Cyan "Downloading LLVM..." | ||
$llvmUrl = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/LLVM-$llvmVersion-win64.exe" | ||
$llvmInstaller = "$env:TEMP\LLVM-$llvmVersion-win64.exe" | ||
Invoke-WebRequest -Uri $llvmUrl -OutFile $llvmInstaller | ||
|
||
Write-ColorOutput Cyan "Installing LLVM..." | ||
Start-Process -Wait -FilePath $llvmInstaller -ArgumentList "/S", "/D=C:\Program Files\LLVM" | ||
Remove-Item $llvmInstaller | ||
} | ||
|
||
# 4. Install Rust | ||
Install-IfNotPresent "Rust" "rustc" { | ||
Write-ColorOutput Cyan "Downloading and installing Rust..." | ||
$rustupInit = "$env:TEMP\rustup-init.exe" | ||
Invoke-WebRequest -Uri "https://win.rustup.rs" -OutFile $rustupInit | ||
Start-Process -Wait -FilePath $rustupInit -ArgumentList "-y", "--default-toolchain", "1.77.2" | ||
Remove-Item $rustupInit | ||
} | ||
|
||
# 5. Set Rust default version | ||
Write-ColorOutput Cyan "Setting Rust default version to 1.77.2..." | ||
rustup default 1.77.2 | ||
|
||
# 6. Add WebAssembly target | ||
Write-ColorOutput Cyan "Adding WebAssembly target..." | ||
rustup target add wasm32-unknown-unknown | ||
|
||
# 7. Install Radix Engine Simulator and CLI tools | ||
Write-ColorOutput Cyan "Installing Radix Engine Simulator and CLI tools..." | ||
cargo install --force radix-clis@1.2.0 | ||
|
||
# Final success message | ||
Write-ColorOutput Green "`nInstallation complete! Please restart your terminal to ensure all changes take effect." | ||
Write-ColorOutput Yellow "`nTo verify the installation, you can run:" | ||
Write-ColorOutput White "git --version" | ||
Write-ColorOutput White "cl" | ||
Write-ColorOutput White "clang --version" | ||
Write-ColorOutput White "rustc --version" | ||
Write-ColorOutput White "cargo --version" |