From 60f0fa559a468c8bf6d2c7343e0cd12ce2326c92 Mon Sep 17 00:00:00 2001 From: Lukasz Rubaszewski <117115317+lrubasze@users.noreply.github.com> Date: Wed, 27 Nov 2024 08:35:53 +0100 Subject: [PATCH 01/10] Update Rust version comments --- .github/actions/setup-env/action.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml index fa08868559..a72ec9f18c 100644 --- a/.github/actions/setup-env/action.yml +++ b/.github/actions/setup-env/action.yml @@ -8,7 +8,7 @@ runs: uses: RDXWorks-actions/toolchain@master with: # IMPORTANT: - # To update the Rust version, you must update it in five total places (including the toolchain below): + # To update the Rust version, you must update it in below places (including the toolchain below) in this repo: # => [README.md - part 1] Update "Install Rust - we recommend to use Rust X.XX.X" # => [README.md - part 2] Update "rustup default X.XX.X" # => [action.yml - part 1] Update "toolchain: X.XX.X" below @@ -18,6 +18,9 @@ runs: # => [Dockerfile] Update "FROM rust:X.XX.X-slim-bookworm AS base-image" in the deterministic builder # => [radix-clis/assets/template/rust-toolchain.toml_template] Update the rust version # => [https://docs.radixdlt.com/docs/getting-rust-scrypto] Update the recommended rust version on docs + # Additionally, Rust version should be updated in below repos on respective branches: + # - babylon-node - .github/actions/setup-env/action.yml + # - fuzzer - .github/actions/setup-env/action.yml toolchain: 1.81.0 default: true target: wasm32-unknown-unknown From 8e3ae20319c54696737e0b31c3078caa4053ca1e Mon Sep 17 00:00:00 2001 From: Lukasz Rubaszewski <117115317+lrubasze@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:27:32 +0100 Subject: [PATCH 02/10] Warning (instead of error) when no tests to run --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5180dcc76a..55ee3c4b40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,9 @@ on: env: CARGO_TERM_COLOR: always SCRYPTO_CARGO_LOCKED: 1 + # Produce a warning and exit with code 0 if no tests to run + # (nextest returns error by default since version 0.9.85) + NEXTEST_NO_TESTS: warn concurrency: group: ci-${{ github.ref }} From 9a871e5928a66b696806354a2f62f29512df2133 Mon Sep 17 00:00:00 2001 From: Lukasz Rubaszewski <117115317+lrubasze@users.noreply.github.com> Date: Wed, 27 Nov 2024 19:27:28 +0100 Subject: [PATCH 03/10] Comment corrected --- .github/actions/setup-env/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml index a72ec9f18c..8a7acddb91 100644 --- a/.github/actions/setup-env/action.yml +++ b/.github/actions/setup-env/action.yml @@ -8,7 +8,7 @@ runs: uses: RDXWorks-actions/toolchain@master with: # IMPORTANT: - # To update the Rust version, you must update it in below places (including the toolchain below) in this repo: + # To update the Rust version, you must update it in the below places (including the toolchain below) in this repo: # => [README.md - part 1] Update "Install Rust - we recommend to use Rust X.XX.X" # => [README.md - part 2] Update "rustup default X.XX.X" # => [action.yml - part 1] Update "toolchain: X.XX.X" below From 2cdf1e1cdbaa6c7e0bca78ff4a42806dc9a77b29 Mon Sep 17 00:00:00 2001 From: Lukasz Rubaszewski <117115317+lrubasze@users.noreply.github.com> Date: Thu, 28 Nov 2024 08:31:55 +0100 Subject: [PATCH 04/10] Pin nextest to 0.9.85 --- .github/actions/setup-env/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml index 8a7acddb91..979367d280 100644 --- a/.github/actions/setup-env/action.yml +++ b/.github/actions/setup-env/action.yml @@ -27,7 +27,9 @@ runs: components: rustfmt - name: Install nextest - uses: RDXWorks-actions/install-action@nextest + uses: RDXWorks-actions/install-action@main + with: + tool: nextest@0.9.85 - name: Set LIBCLANG_PATH # See https://github.com/rust-lang/rust-bindgen/issues/1797 if: runner.os == 'Windows' From 89e2d03cc8ce282b95594157dcbd1200338ef22e Mon Sep 17 00:00:00 2001 From: David Edey Date: Thu, 28 Nov 2024 14:56:08 +0000 Subject: [PATCH 05/10] Update `pull_request_template.md` --- .github/pull_request_template.md | 98 +++++++++++++------------------- 1 file changed, 41 insertions(+), 57 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index bfbd8b110e..c81dd398e7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,62 +1,46 @@ -## Summary -``` -INSTRUCTIONS: -Add summary - one or two sentences explaining the purpose of this PR. -``` +> [!IMPORTANT] +> +> * Please read our [Contributing Guidelines](/CONTRIBUTING.md) before opening a PR. +> * Before creating your PR, please ensure you read the [node branching strategy](https://github.com/radixdlt/babylon-node/blob/main/docs/branching-strategy.md), which is also used in this repository. The end result after completing the merge actions should be that `main <= release/XXX <= develop`, where `XXX` is the latest released protocol version. This ensures that we minimise merge conflicts, and that work doesn't go missing. +> * As per the branching strategy, **you must ensure you select the _correct base branch_**, both for branching from, and in the PR UI above. The following process can be used to decide the base branch: +> * For code changes which can wait until the next protocol update to be released, use `develop`. This should be the default for code changes. +> * For code changes which need to go out as a fully-interoperable update to the node at the current protocol version, use `release/XXX`. +> * Such changes must be tested and reviewed more carefully to mitigate the risk of regression. +> * Once the change is merged, it is the merger's responsibility to ensure `release/XXX` is merged into the `develop` branch. +> * For github workflow changes, use `main`. +> * Once the change is merged, it is the merger's responsibility to ensure `main` is merged into both `release/XXX` and `develop`, so that the changes also apply to hotfixes, and to current development. +> * For changes to README files, use `main`. +> * Once the change is merged, it is the merger's responsibility to ensure `main` is merged into both `release/XXX` and `develop`, so that the changes also apply on these branches. +> +> _Please remove this section once you confirm you follow its guidance._ -## Details -``` -INSTRUCTIONS: -Provide further details about the changes, or how they fit into the roadmap. -You can delete this section if it's not useful. -``` +## Summary + ## Testing -``` -INSTRUCTIONS: -Further details about the tests you've added or manually performed. -You can delete this section if it's not useful. -``` + ## Update Recommendations -``` -INSTRUCTIONS: -This section is to provide recommendations to consumers of this repo about how they -should handle breaking changes, or integrate new features. The two key stakeholder -groups are dApp Developers and Internal Integrators, and there are separate sections -for each. - -In order to allow us to compile aggregated update instructions across PRs, please tag the PR -with 0+ of the relevant labels: -* scrypto-lib - Any change to the scrypto library -* sbor - Any breaking change to SBOR encoding/decoding -* manifest - Any change to manifest display, compilation/decompilation -* transaction - Any change which affects the compiled manifest, or transaction semantics -* substate - Any change to substates, the state model, or what's stored in the DB -* native-blueprint-interface - Any change to the interface of native blueprints -* files-moved - Any change to where engine types have moved, which will require - internal integrators to update their imports - -If you have a breaking change which doesn't fix into a category above, then tag it with -the closest label, and discuss in slack/discord. - -If your PR contains no breaking changes or new features or hasn't been tagged, this whole -section can be deleted. -``` - -### For dApp Developers -``` -INSTRUCTIONS: -Migration recommendations for a dApp developer to update their dApp/integrations -due to to the change/s in this PR. - -These will be aggregated by the Developer Ecosystem team and included in the next Scrypto migration guide -(eg https://docs-babylon.radixdlt.com/main/scrypto/release_notes/migrating_from_0.7_to_0.8.html ) -``` - -### For Internal Integrators -``` -INSTRUCTIONS: -Instructions to any internal integrations (eg Node, Toolkit, Gateway, Ledger App) for how the changes may affect -them and recommendations for how they should update to support this change. -``` + From 635c9a3985cf2e792afef527f1073087bdff9c60 Mon Sep 17 00:00:00 2001 From: Azizi <64193693+azizi-a@users.noreply.github.com> Date: Wed, 13 Nov 2024 08:35:38 +0000 Subject: [PATCH 06/10] Add scrypto install shell scripts --- .../install-scrypto-debian.sh | 151 ++++++++++++++++++ .../install-scrypto-macos.sh | 73 +++++++++ .../install-scrypto-windows.ps1 | 111 +++++++++++++ 3 files changed, 335 insertions(+) create mode 100644 scrypto-install-scripts/install-scrypto-debian.sh create mode 100755 scrypto-install-scripts/install-scrypto-macos.sh create mode 100644 scrypto-install-scripts/install-scrypto-windows.ps1 diff --git a/scrypto-install-scripts/install-scrypto-debian.sh b/scrypto-install-scripts/install-scrypto-debian.sh new file mode 100644 index 0000000000..ecb56d9e9d --- /dev/null +++ b/scrypto-install-scripts/install-scrypto-debian.sh @@ -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 radix-clis@1.2.0 + + 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 + diff --git a/scrypto-install-scripts/install-scrypto-macos.sh b/scrypto-install-scripts/install-scrypto-macos.sh new file mode 100755 index 0000000000..5cb675129a --- /dev/null +++ b/scrypto-install-scripts/install-scrypto-macos.sh @@ -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 radix-clis@1.2.0 +check_status "Radix tools installation" + +echo -e "\n${GREEN}Installation complete! Please restart your terminal or run:${NC}" +echo -e "source $SHELL_CONFIG" diff --git a/scrypto-install-scripts/install-scrypto-windows.ps1 b/scrypto-install-scripts/install-scrypto-windows.ps1 new file mode 100644 index 0000000000..05edc52887 --- /dev/null +++ b/scrypto-install-scripts/install-scrypto-windows.ps1 @@ -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" From 505948993d9cb4718abf52615b6c06e4777b2f16 Mon Sep 17 00:00:00 2001 From: Azizi <64193693+azizi-a@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:41:10 +0000 Subject: [PATCH 07/10] fix: windows scrypto install script --- .../install-scrypto-windows.ps1 | 64 ++++++++++++++----- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/scrypto-install-scripts/install-scrypto-windows.ps1 b/scrypto-install-scripts/install-scrypto-windows.ps1 index 05edc52887..46aa04d530 100644 --- a/scrypto-install-scripts/install-scrypto-windows.ps1 +++ b/scrypto-install-scripts/install-scrypto-windows.ps1 @@ -3,7 +3,7 @@ # Script configuration $ErrorActionPreference = "Stop" -$ProgressPreference = "SilentlyContinue" # Speeds up downloads +$ProgressPreference = "Continue" # Colors for output function Write-ColorOutput($ForegroundColor) { @@ -15,6 +15,11 @@ function Write-ColorOutput($ForegroundColor) { $host.UI.RawUI.ForegroundColor = $fc } +function Refresh-EnvironmentVariables { + # Refresh the PATH variable + $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") +} + function Install-IfNotPresent { param ( [string]$Name, @@ -31,6 +36,7 @@ function Install-IfNotPresent { exit 1 } Write-ColorOutput Green "$Name installed successfully" + Refresh-EnvironmentVariables } else { Write-ColorOutput Green "$Name is already installed" } @@ -46,45 +52,62 @@ if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent Install-IfNotPresent "Git" "git" { # Using winget for Git installation winget install --id Git.Git -e --source winget + Refresh-EnvironmentVariables # 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" +$Name = "Visual Studio Build Tools 2022" +Write-ColorOutput Yellow "Checking for $Name..." if (!(Test-Path $vsInstallerPath)) { - Write-ColorOutput Cyan "Downloading Visual Studio Build Tools 2022..." + Write-ColorOutput Cyan "Downloading $Name..." $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", ` + Start-BitsTransfer -Source $vsUrl -Destination $vsInstaller + + Write-ColorOutput Cyan "Installing $Name with C++ support - This may take a long time..." + Start-Process -Wait -FilePath $vsInstaller -ArgumentList @( + "--passive", + "--wait", + "--norestart", + "--nocache", + "--installPath", "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools", + "--add", "Microsoft.VisualStudio.Workload.VCTools" "--includeRecommended" + ) Remove-Item $vsInstaller + Refresh-EnvironmentVariables +} else { + Write-ColorOutput Green "Visual Studio Build Tools are already installed" } # 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 + Start-BitsTransfer -Source $llvmUrl -Destination $llvmInstaller - Write-ColorOutput Cyan "Installing LLVM..." + Write-ColorOutput Cyan "Installing LLVM - This may take a long time too..." Start-Process -Wait -FilePath $llvmInstaller -ArgumentList "/S", "/D=C:\Program Files\LLVM" Remove-Item $llvmInstaller + + # Add LLVM bin directory to the system PATH + $llvmBinPath = "C:\Program Files\LLVM\bin" + [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$llvmBinPath", [EnvironmentVariableTarget]::Machine) + $env:Path += ";$llvmBinPath" } # 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-BitsTransfer -Source "https://win.rustup.rs" -Destination $rustupInit Start-Process -Wait -FilePath $rustupInit -ArgumentList "-y", "--default-toolchain", "1.77.2" Remove-Item $rustupInit } @@ -100,12 +123,19 @@ 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 +Refresh-EnvironmentVariables # 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" +Write-ColorOutput Yellow "`nVerifying instillations..." +Write-ColorOutput White "Versions installed:" +Write-ColorOutput White "git" +git --version +Write-ColorOutput White "`nclang" +clang --version +Write-ColorOutput White "`nrustc" +rustc --version +Write-ColorOutput White "`ncargo" +cargo --version +Write-ColorOutput White "`nscrypto" +scrypto --version \ No newline at end of file From de518d6baf1839f39a0b5dd1ca6ae2dfcf533683 Mon Sep 17 00:00:00 2001 From: Azizi <64193693+azizi-a@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:53:36 +0000 Subject: [PATCH 08/10] feat: update scrypto install scripts for v1.3.0 --- scrypto-install-scripts/install-scrypto-debian.sh | 4 ++-- scrypto-install-scripts/install-scrypto-macos.sh | 8 ++++---- scrypto-install-scripts/install-scrypto-windows.ps1 | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/scrypto-install-scripts/install-scrypto-debian.sh b/scrypto-install-scripts/install-scrypto-debian.sh index ecb56d9e9d..8c40ae7139 100644 --- a/scrypto-install-scripts/install-scrypto-debian.sh +++ b/scrypto-install-scripts/install-scrypto-debian.sh @@ -67,7 +67,7 @@ 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 + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=1.81.0 -y if [ $? -eq 0 ]; then log "SUCCESS" "Rust installed successfully" @@ -110,7 +110,7 @@ add_wasm_target() { install_radix_tools() { log "INFO" "Installing Radix Engine Simulator and CLI tools..." - cargo install --force radix-clis@1.2.0 + cargo install --force radix-clis@1.3.0 if [ $? -eq 0 ]; then log "SUCCESS" "Radix tools installed successfully" diff --git a/scrypto-install-scripts/install-scrypto-macos.sh b/scrypto-install-scripts/install-scrypto-macos.sh index 5cb675129a..0808933ced 100755 --- a/scrypto-install-scripts/install-scrypto-macos.sh +++ b/scrypto-install-scripts/install-scrypto-macos.sh @@ -44,14 +44,14 @@ 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" +if ! grep -q "$(brew --prefix llvm@18)/bin" "$SHELL_CONFIG"; then + echo 'PATH="$(brew --prefix llvm@18)/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 +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=1.81.0 -y check_status "Rust installation" # Source cargo environment @@ -66,7 +66,7 @@ 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 radix-clis@1.2.0 +cargo install --force radix-clis@1.3.0 check_status "Radix tools installation" echo -e "\n${GREEN}Installation complete! Please restart your terminal or run:${NC}" diff --git a/scrypto-install-scripts/install-scrypto-windows.ps1 b/scrypto-install-scripts/install-scrypto-windows.ps1 index 46aa04d530..37c6de78c7 100644 --- a/scrypto-install-scripts/install-scrypto-windows.ps1 +++ b/scrypto-install-scripts/install-scrypto-windows.ps1 @@ -85,7 +85,7 @@ if (!(Test-Path $vsInstallerPath)) { } # 3. Install LLVM -$llvmVersion = "17.0.6" +$llvmVersion = "18.1.8" Install-IfNotPresent "LLVM" "clang" { Write-ColorOutput Cyan "Downloading LLVM..." @@ -104,17 +104,18 @@ Install-IfNotPresent "LLVM" "clang" { } # 4. Install Rust +$rustVersion = "1.81.0" Install-IfNotPresent "Rust" "rustc" { Write-ColorOutput Cyan "Downloading and installing Rust..." $rustupInit = "$env:TEMP\rustup-init.exe" Start-BitsTransfer -Source "https://win.rustup.rs" -Destination $rustupInit - Start-Process -Wait -FilePath $rustupInit -ArgumentList "-y", "--default-toolchain", "1.77.2" + Start-Process -Wait -FilePath $rustupInit -ArgumentList "-y", "--default-toolchain", $rustVersion Remove-Item $rustupInit } # 5. Set Rust default version -Write-ColorOutput Cyan "Setting Rust default version to 1.77.2..." -rustup default 1.77.2 +Write-ColorOutput Cyan "Setting Rust default version to $rustVersion..." +rustup default $rustVersion # 6. Add WebAssembly target Write-ColorOutput Cyan "Adding WebAssembly target..." @@ -122,7 +123,7 @@ 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 +cargo install --force radix-clis@1.3.0 Refresh-EnvironmentVariables # Final success message From 614a2134449d97771c58b543a0228a7830444da2 Mon Sep 17 00:00:00 2001 From: Azizi <64193693+azizi-a@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:08:24 +0000 Subject: [PATCH 09/10] tweak: parametrise install scripts tool versions --- .github/actions/setup-env/action.yml | 10 +++++++--- scrypto-install-scripts/install-scrypto-debian.sh | 11 ++++++++--- scrypto-install-scripts/install-scrypto-macos.sh | 15 ++++++++++----- .../install-scrypto-windows.ps1 | 13 ++++++++----- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml index 979367d280..528d7c70bb 100644 --- a/.github/actions/setup-env/action.yml +++ b/.github/actions/setup-env/action.yml @@ -1,5 +1,5 @@ -name: 'Setup environment' -description: 'Common GH action to setup job environment' +name: "Setup environment" +description: "Common GH action to setup job environment" runs: using: "composite" @@ -17,6 +17,10 @@ runs: # different version is used. # => [Dockerfile] Update "FROM rust:X.XX.X-slim-bookworm AS base-image" in the deterministic builder # => [radix-clis/assets/template/rust-toolchain.toml_template] Update the rust version + # => [scrypto-install-scripts/*] Update the all version in each scripts "# Versions to install" section. Keep the current version number format: + # => [scrypto-install-scripts/install-scrypto-debian.sh] "LLVM_VERSION=XX", "RUST_VERSION=X.XX.X", "RADIX_CLI_VERSION=X.X.X" + # => [scrypto-install-scripts/install-scrypto-macos.sh] "LLVM_VERSION=XX", "RUST_VERSION=X.XX.X", "RADIX_CLI_VERSION=X.X.X" + # => [scrypto-install-scripts/install-scrypto-windows.ps1] "$llvmVersion = 'XX.X.X'", "$rustVersion = 'X.XX.X'", "$radixCliVersion = 'X.X.X'" # => [https://docs.radixdlt.com/docs/getting-rust-scrypto] Update the recommended rust version on docs # Additionally, Rust version should be updated in below repos on respective branches: # - babylon-node - .github/actions/setup-env/action.yml @@ -43,7 +47,7 @@ runs: if: runner.os == 'Linux' uses: RDXWorks-actions/actions-setup-cmake@master with: - cmake-version: '3.27.9' + cmake-version: "3.27.9" - name: Install libclang-dev if: runner.os == 'Linux' run: sudo apt-get -y update && sudo apt-get install clang libclang-dev -y -f diff --git a/scrypto-install-scripts/install-scrypto-debian.sh b/scrypto-install-scripts/install-scrypto-debian.sh index 8c40ae7139..1c3b2b52f7 100644 --- a/scrypto-install-scripts/install-scrypto-debian.sh +++ b/scrypto-install-scripts/install-scrypto-debian.sh @@ -3,6 +3,11 @@ # Exit on error set -e +# Versions to install +LLVM_VERSION=18 +RUST_VERSION=1.81.0 +RADIX_CLI_VERSION=1.3.0 + # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' @@ -52,7 +57,7 @@ install_llvm() { sudo apt-get update # Install build essentials and LLVM - sudo apt-get install -y clang build-essential llvm + sudo apt-get install -y clang build-essential llvm-$LLVM_VERSION if [ $? -eq 0 ]; then log "SUCCESS" "LLVM and build essentials installed successfully" @@ -67,7 +72,7 @@ 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.81.0 -y + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=$RUST_VERSION -y if [ $? -eq 0 ]; then log "SUCCESS" "Rust installed successfully" @@ -110,7 +115,7 @@ add_wasm_target() { install_radix_tools() { log "INFO" "Installing Radix Engine Simulator and CLI tools..." - cargo install --force radix-clis@1.3.0 + cargo install --force radix-clis@$RADIX_CLI_VERSION if [ $? -eq 0 ]; then log "SUCCESS" "Radix tools installed successfully" diff --git a/scrypto-install-scripts/install-scrypto-macos.sh b/scrypto-install-scripts/install-scrypto-macos.sh index 0808933ced..0ed66f6f90 100755 --- a/scrypto-install-scripts/install-scrypto-macos.sh +++ b/scrypto-install-scripts/install-scrypto-macos.sh @@ -3,6 +3,11 @@ # Print commands and exit on errors set -ex +# Versions to install +LLVM_VERSION=18 +RUST_VERSION=1.81.0 +RADIX_CLI_VERSION=1.3.0 + # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' @@ -28,7 +33,7 @@ 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 +brew install cmake llvm@$LLVM_VERSION check_status "cmake and LLVM installation" # Detect shell and configure appropriate rc file @@ -44,14 +49,14 @@ fi # Add LLVM to PATH echo -e "\n${BLUE}Configuring LLVM in $SHELL_CONFIG...${NC}" -if ! grep -q "$(brew --prefix llvm@18)/bin" "$SHELL_CONFIG"; then - echo 'PATH="$(brew --prefix llvm@18)/bin:$PATH"' >> "$SHELL_CONFIG" +if ! grep -q "$(brew --prefix llvm@${LLVM_VERSION})/bin" "$SHELL_CONFIG"; then + echo 'PATH="$(brew --prefix llvm@'$LLVM_VERSION')/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.81.0 -y +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=$RUST_VERSION -y check_status "Rust installation" # Source cargo environment @@ -66,7 +71,7 @@ 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 radix-clis@1.3.0 +cargo install --force radix-clis@$RADIX_CLI_VERSION check_status "Radix tools installation" echo -e "\n${GREEN}Installation complete! Please restart your terminal or run:${NC}" diff --git a/scrypto-install-scripts/install-scrypto-windows.ps1 b/scrypto-install-scripts/install-scrypto-windows.ps1 index 37c6de78c7..79ed9b4efb 100644 --- a/scrypto-install-scripts/install-scrypto-windows.ps1 +++ b/scrypto-install-scripts/install-scrypto-windows.ps1 @@ -1,9 +1,14 @@ # Requires PowerShell running as Administrator #Requires -RunAsAdministrator +# Versions to install +$llvmVersion = '18.1.8' +$rustVersion = '1.81.0' +$radixCliVersion = '1.3.0' + # Script configuration -$ErrorActionPreference = "Stop" -$ProgressPreference = "Continue" +$ErrorActionPreference = 'Stop' +$ProgressPreference = 'Continue' # Colors for output function Write-ColorOutput($ForegroundColor) { @@ -85,7 +90,6 @@ if (!(Test-Path $vsInstallerPath)) { } # 3. Install LLVM -$llvmVersion = "18.1.8" Install-IfNotPresent "LLVM" "clang" { Write-ColorOutput Cyan "Downloading LLVM..." @@ -104,7 +108,6 @@ Install-IfNotPresent "LLVM" "clang" { } # 4. Install Rust -$rustVersion = "1.81.0" Install-IfNotPresent "Rust" "rustc" { Write-ColorOutput Cyan "Downloading and installing Rust..." $rustupInit = "$env:TEMP\rustup-init.exe" @@ -123,7 +126,7 @@ 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.3.0 +cargo install --force radix-clis@$radixCliVersion Refresh-EnvironmentVariables # Final success message From 28b0758f423d0a8aa293735afbd2caac7a94f137 Mon Sep 17 00:00:00 2001 From: Azizi <64193693+azizi-a@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:46:48 +0000 Subject: [PATCH 10/10] fix: update llvm install in scrypto linux install script --- .../install-scrypto-debian.sh | 78 ++++++++++++++++--- 1 file changed, 68 insertions(+), 10 deletions(-) diff --git a/scrypto-install-scripts/install-scrypto-debian.sh b/scrypto-install-scripts/install-scrypto-debian.sh index 1c3b2b52f7..2e739eec76 100644 --- a/scrypto-install-scripts/install-scrypto-debian.sh +++ b/scrypto-install-scripts/install-scrypto-debian.sh @@ -49,20 +49,38 @@ check_dependencies() { fi } -# Function to install LLVM and build essentials -install_llvm() { - log "INFO" "Installing LLVM and build essentials..." +# Function to install build essentials +install_build_essentials() { + log "INFO" "Installing build essentials..." # Update package list sudo apt-get update - # Install build essentials and LLVM - sudo apt-get install -y clang build-essential llvm-$LLVM_VERSION + # Install build essentials + sudo apt-get install -y build-essential if [ $? -eq 0 ]; then - log "SUCCESS" "LLVM and build essentials installed successfully" + log "SUCCESS" "Build essentials installed successfully" else - log "ERROR" "Failed to install LLVM and build essentials" + log "ERROR" "Failed to install build essentials" + exit 1 + fi +} + +# Function to install LLVM +install_llvm() { + log "INFO" "Installing LLVM..." + + # Download and install LLVM + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh $LLVM_VERSION + rm llvm.sh + + if [ $? -eq 0 ]; then + log "SUCCESS" "LLVM installed successfully" + else + log "ERROR" "Failed to install LLVM" exit 1 fi } @@ -125,6 +143,40 @@ install_radix_tools() { fi } +# Function to add Clang to shell configuration +add_clang_to_shell_config() { + # Determine the user's shell + SHELL_NAME=$(basename "$SHELL") + + # Determine the shell configuration file based on the default shell + case "$SHELL_NAME" in + bash) SHELL_CONFIG="$HOME/.bashrc" ;; + zsh) SHELL_CONFIG="$HOME/.zshrc" ;; + ksh) SHELL_CONFIG="$HOME/.kshrc" ;; + fish) SHELL_CONFIG="$HOME/.config/fish/config.fish" ;; + *) + log "ERROR" "Unsupported shell. Please add 'export CC=clang-${LLVM_VERSION}' to your shell configuration manually." + exit 1 + ;; + esac + + # The line to add + EXPORT_LINE="export CC=clang-${LLVM_VERSION}" + + # Check if the line already exists to prevent duplicates + if grep -Fxq "$EXPORT_LINE" "$SHELL_CONFIG" + then + log "INFO" "The CC variable is already set in $SHELL_CONFIG" + else + # Backup the shell configuration file + cp "$SHELL_CONFIG" "${SHELL_CONFIG}.backup" + + # Append the export line to the shell configuration file + echo "$EXPORT_LINE" >> "$SHELL_CONFIG" + log "INFO" "Added '$EXPORT_LINE' to $SHELL_CONFIG" + fi +} + # Main installation process main() { log "INFO" "Starting installation process..." @@ -133,24 +185,30 @@ main() { check_dependencies # Install components + install_build_essentials install_llvm install_rust setup_cargo add_wasm_target install_radix_tools + add_clang_to_shell_config # Final success message log "SUCCESS" "Installation completed successfully!" - log "INFO" "Please restart your terminal or run: source $HOME/.cargo/env" + source $HOME/.cargo/env # Verify installations log "INFO" "Verifying installations..." echo -e "\nVersions installed:" - echo -e "LLVM: $(clang --version | head -n 1)" + echo -e "LLVM: $(llvm-config-${LLVM_VERSION} --version)" + echo -e "Clang: $(clang-${LLVM_VERSION} --version | head -n 1)" echo -e "Rust: $(rustc --version)" echo -e "Cargo: $(cargo --version)" + echo -e "Radix CLI: $(scrypto --version)\n" + + log "INFO" "Please restart your terminal or run:" + echo "source $SHELL_CONFIG" } # Run main function main -