diff --git a/install_rust_dependencies.sh b/install_rust_dependencies.sh index 0925a71855..466de65005 100755 --- a/install_rust_dependencies.sh +++ b/install_rust_dependencies.sh @@ -11,6 +11,8 @@ global_azle_rust_bin_dir="$global_azle_rust_dir"/bin global_azle_logs_dir="$global_azle_rust_dir"/logs global_azle_cargo_bin="$global_azle_rust_bin_dir"/cargo global_azle_rustup_bin="$global_azle_rust_bin_dir"/rustup +global_azle_rustc_bin="$global_azle_rust_bin_dir"/rustc +global_azle_wasi2ic_bin="$global_azle_rust_bin_dir"/wasi2ic export CARGO_TARGET_DIR="$global_azle_config_dir"/rust/target export CARGO_HOME="$global_azle_rust_dir" @@ -18,15 +20,15 @@ export RUSTUP_HOME="$global_azle_rust_dir" export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse function run() { - if [ -e "$global_azle_rustup_bin" ] && $global_azle_rustup_bin target list | grep -q "wasm32-wasi (installed)"; then - update_rustup - else + if ! ([ -e "$global_azle_rustup_bin" ] && [ -e "$global_azle_wasi2ic_bin" ] && [ -e "$global_azle_cargo_bin" ] && [ -e "$global_azle_rustc_bin" ] && $global_azle_rustup_bin target list | grep -q "wasm32-wasi (installed)"); then mkdir -p "$global_azle_rust_dir" mkdir -p "$global_azle_logs_dir" install_rustup install_wasm32 install_wasi2ic + + echo -e "[4/4] 🚀 Launching..." fi } @@ -35,10 +37,6 @@ function install_rustup() { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path -y --default-toolchain="$rust_version" --profile=minimal &> "$global_azle_logs_dir"/install_rustup } -function update_rustup() { - "$global_azle_rustup_bin" update "$rust_version" &> "$global_azle_logs_dir"/update_rustup -} - function install_wasm32() { echo -e "[2/4] 🛠️ Commencing development..." "$global_azle_rustup_bin" target add wasm32-wasi &> "$global_azle_logs_dir"/install_wasm32_wasi diff --git a/src/compiler/install_rust_dependencies.ts b/src/compiler/install_rust_dependencies.ts index 73bd3c2eb5..631bd302cf 100644 --- a/src/compiler/install_rust_dependencies.ts +++ b/src/compiler/install_rust_dependencies.ts @@ -1,20 +1,10 @@ import { execSync } from 'child_process'; -import { existsSync } from 'fs'; import { resolve } from 'path'; -import { - GLOBAL_AZLE_RUST_DIR, - GLOBAL_AZLE_RUST_BIN_DIR, - GLOBAL_AZLE_TARGET_DIR -} from './utils'; export function installRustDependencies( azleVersion: string, rustVersion: string ) { - if (isWasm32TargetInstalled()) { - return; - } - const installRustDependenciesPath = resolve( __dirname, '../../install_rust_dependencies.sh' @@ -23,31 +13,4 @@ export function installRustDependencies( execSync(`"${installRustDependenciesPath}" ${azleVersion} ${rustVersion}`, { stdio: 'inherit' }); - - console.log('[4/4] 🚀 Launching...'); -} - -function isWasm32TargetInstalled(): boolean { - if (existsSync(`${GLOBAL_AZLE_RUST_BIN_DIR}/rustup`)) { - try { - const stdout = execSync( - `${GLOBAL_AZLE_RUST_BIN_DIR}/rustup target list`, - { - encoding: 'utf-8', - env: { - ...process.env, - CARGO_TARGET_DIR: GLOBAL_AZLE_TARGET_DIR, - CARGO_HOME: GLOBAL_AZLE_RUST_DIR, - RUSTUP_HOME: GLOBAL_AZLE_RUST_DIR - } - } - ); - return stdout.includes('wasm32-wasi (installed)'); - } catch (error) { - console.error(`execSync error: ${error}`); - return false; - } - } else { - return false; - } }