Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "rustwide"
version = "0.21.0"
edition = "2018"
build = "build.rs"
rust-version = "1.89"

documentation = "https://docs.rs/rustwide"
repository = "https://github.com/rust-lang/rustwide"
Expand All @@ -26,7 +27,6 @@ tokio-stream = { version = "0.1", features = ["io-util"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
scopeguard = "1.0.0"
lazy_static = "1.0.0"
tempfile = "3.0.0"
attohttpc = "0.28.0"
flate2 = "1"
Expand Down
36 changes: 17 additions & 19 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use futures_util::{
};
use log::{error, info};
use process_lines_actions::InnerState;
use std::convert::AsRef;
use std::env::consts::EXE_SUFFIX;
use std::ffi::{OsStr, OsString};
use std::path::{Path, PathBuf};
use std::process::{ExitStatus, Stdio};
use std::time::{Duration, Instant};
use std::{convert::AsRef, sync::LazyLock};
use tokio::{
io::{AsyncBufReadExt, BufReader},
process::Command as AsyncCommand,
Expand All @@ -28,32 +28,30 @@ use tokio::{
};
use tokio_stream::{wrappers::LinesStream, StreamExt};

lazy_static::lazy_static! {
// TODO: Migrate to asynchronous code and remove runtime
pub(super) static ref RUNTIME: Runtime = Runtime::new().expect("Failed to construct tokio runtime");
}
// TODO: Migrate to asynchronous code and remove runtime
pub(super) static RUNTIME: LazyLock<Runtime> =
LazyLock::new(|| Runtime::new().expect("Failed to construct tokio runtime"));

pub(crate) mod container_dirs {
use lazy_static::lazy_static;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;

#[cfg(windows)]
lazy_static! {
pub(super) static ref ROOT_DIR: PathBuf = Path::new(r"C:\rustwide").into();
macro_rules! path_const {
($v:ident, $n:ident, $p:expr) => {
pub($v) static $n: LazyLock<PathBuf> = LazyLock::new(|| $p);
};
}

#[cfg(windows)]
path_const!(super, ROOT_DIR, Path::new(r"C:\rustwide").into());
#[cfg(not(windows))]
lazy_static! {
pub(super) static ref ROOT_DIR: PathBuf = Path::new("/opt/rustwide").into();
}
path_const!(super, ROOT_DIR, Path::new("/opt/rustwide").into());

lazy_static! {
pub(crate) static ref WORK_DIR: PathBuf = ROOT_DIR.join("workdir");
pub(crate) static ref TARGET_DIR: PathBuf = ROOT_DIR.join("target");
pub(super) static ref CARGO_HOME: PathBuf = ROOT_DIR.join("cargo-home");
pub(super) static ref RUSTUP_HOME: PathBuf = ROOT_DIR.join("rustup-home");
pub(super) static ref CARGO_BIN_DIR: PathBuf = CARGO_HOME.join("bin");
}
path_const!(crate, WORK_DIR, ROOT_DIR.join("workdir"));
path_const!(crate, TARGET_DIR, ROOT_DIR.join("target"));
path_const!(super, CARGO_HOME, ROOT_DIR.join("cargo-home"));
path_const!(super, RUSTUP_HOME, ROOT_DIR.join("rustup-home"));
path_const!(super, CARGO_BIN_DIR, CARGO_HOME.join("bin"));
}

/// Error happened while executing a command.
Expand Down