Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify process interface #3764

Merged
merged 9 commits into from
Jun 4, 2024
Merged
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
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ clap_complete = "4"
download = { path = "download", default-features = false }
effective-limits = "0.5.5"
enum-map = "2.5.0"
enum_dispatch.workspace = true
flate2 = "1"
fs_at.workspace = true
git-testament = "0.2"
Expand Down Expand Up @@ -134,7 +133,6 @@ members = ["download", "rustup-macros"]

[workspace.dependencies]
anyhow = "1.0.69"
enum_dispatch = "0.3.11"
fs_at = "0.1.6"
once_cell = "1.18.0"
opentelemetry = "0.23"
Expand Down
6 changes: 3 additions & 3 deletions src/bin/rustup-init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use rustup::cli::rustup_mode;
#[cfg(windows)]
use rustup::cli::self_update;
use rustup::cli::setup_mode;
use rustup::currentprocess::{process, varsource::VarSource, with_runtime, OSProcess};
use rustup::currentprocess::{process, with_runtime, Process};
use rustup::env_var::RUST_RECURSION_COUNT_MAX;
use rustup::is_proxyable_tools;
use rustup::utils::utils::{self, ExitCode};
Expand All @@ -36,10 +36,10 @@ fn main() {
#[cfg(windows)]
pre_rustup_main_init();

let process = OSProcess::default();
let process = Process::os();
let mut builder = Builder::new_multi_thread();
builder.enable_all();
with_runtime(process.into(), builder, {
with_runtime(process, builder, {
async {
match maybe_trace_rustup().await {
Err(e) => {
Expand Down
7 changes: 1 addition & 6 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ use once_cell::sync::Lazy;

use super::self_update;
use crate::cli::download_tracker::DownloadTracker;
use crate::currentprocess::{
argsource::ArgSource,
filesource::{StdinSource, StdoutSource},
process, terminalsource,
varsource::VarSource,
};
use crate::currentprocess::{process, terminalsource};
use crate::dist::dist::{TargetTriple, ToolchainDesc};
use crate::dist::manifest::ComponentStatus;
use crate::install::UpdateStatus;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::Write;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};

use crate::currentprocess::{filesource::StdoutSource, process, terminalsource};
use crate::currentprocess::{process, terminalsource};
use crate::dist::Notification as In;
use crate::notifications::Notification;
use crate::utils::units::{Size, Unit, UnitMode};
Expand Down
4 changes: 1 addition & 3 deletions src/cli/log.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::fmt;
use std::io::Write;

use crate::currentprocess::{
filesource::StderrSource, process, terminalsource, varsource::VarSource,
};
use crate::currentprocess::{process, terminalsource};

macro_rules! warn {
( $ ( $ arg : tt ) * ) => ( $crate::cli::log::warn_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
Expand Down
5 changes: 3 additions & 2 deletions src/cli/proxy_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
cli::{common::set_globals, job, self_update},
command::run_command_for_dir,
config::Cfg,
currentprocess::{argsource::ArgSource, process},
currentprocess::process,
toolchain::names::{LocalToolchainName, ResolvableLocalToolchainName},
utils::utils,
};
Expand All @@ -18,7 +18,8 @@ pub async fn main(arg0: &str) -> Result<ExitStatus> {

let _setup = job::setup();

let mut args = process().args_os().skip(1);
let process = process();
let mut args = process.args_os().skip(1);

// Check for a + toolchain specifier
let arg1 = args.next();
Expand Down
7 changes: 2 additions & 5 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use crate::{
command,
config::{new_toolchain_with_reason, ActiveReason, Cfg},
currentprocess::{
argsource::ArgSource,
filesource::{StderrSource, StdoutSource},
process,
terminalsource::{self, ColorableTerminal},
},
Expand Down Expand Up @@ -1490,8 +1488,6 @@ async fn man(
command: &str,
toolchain: Option<PartialToolchainDesc>,
) -> Result<utils::ExitCode> {
use crate::currentprocess::varsource::VarSource;

let toolchain = Toolchain::from_partial(toolchain, cfg).await?;
let mut path = toolchain.path().to_path_buf();
path.push("share");
Expand All @@ -1513,7 +1509,8 @@ async fn man(

fn set_auto_self_update(cfg: &mut Cfg, auto_self_update_mode: &str) -> Result<utils::ExitCode> {
if self_update::NEVER_SELF_UPDATE {
let mut args = process().args_os();
let process = process();
let mut args = process.args_os();
let arg0 = args.next().map(PathBuf::from);
let arg0 = arg0
.as_ref()
Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use crate::{
markdown::md,
},
config::Cfg,
currentprocess::{filesource::StdoutSource, process, varsource::VarSource},
currentprocess::process,
dist::dist::{self, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc},
install::UpdateStatus,
toolchain::{
Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::path::PathBuf;
use anyhow::{bail, Result};

use super::utils;
use crate::currentprocess::{process, varsource::VarSource};
use crate::currentprocess::process;

pub(crate) type Shell = Box<dyn UnixShell>;

Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::{bail, Context, Result};

use super::install_bins;
use super::shell;
use crate::currentprocess::{process, varsource::VarSource};
use crate::currentprocess::process;
use crate::utils::utils;
use crate::utils::Notification;

Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::super::errors::*;
use super::common;
use super::{install_bins, InstallOpts};
use crate::cli::download_tracker::DownloadTracker;
use crate::currentprocess::{filesource::StdoutSource, process, varsource::VarSource};
use crate::currentprocess::process;
use crate::dist::dist::TargetTriple;
use crate::utils::utils;
use crate::utils::Notification;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/setup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
common,
self_update::{self, InstallOpts},
},
currentprocess::{filesource::StdoutSource, process},
currentprocess::process,
dist::dist::Profile,
toolchain::names::MaybeOfficialToolchainName,
utils::utils,
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio_stream::StreamExt;

use crate::{
cli::self_update::SelfUpdateMode,
currentprocess::{process, varsource::VarSource},
currentprocess::process,
dist::{
dist::{self, PartialToolchainDesc, Profile, ToolchainDesc},
download::DownloadCfg,
Expand Down
Loading
Loading