Skip to content
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
24 changes: 21 additions & 3 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ cargo-test-macro = { version = "0.4.10", path = "crates/cargo-test-macro" }
cargo-test-support = { version = "0.11.0", path = "crates/cargo-test-support" }
cargo-util = { version = "0.2.28", path = "crates/cargo-util" }
cargo-util-schemas = { version = "0.13.0", path = "crates/cargo-util-schemas" }
cargo-util-terminal = { version = "0.1.0", path = "crates/cargo-util-terminal" }
cargo_metadata = "0.23.1"
clap = "4.5.60"
clap_complete = { version = "4.5.66", features = ["unstable-dynamic"] }
Expand Down Expand Up @@ -159,14 +160,14 @@ path = "src/cargo/lib.rs"
annotate-snippets.workspace = true
anstream.workspace = true
anstyle.workspace = true
anstyle-hyperlink = { workspace = true, features = ["file"] }
anstyle-progress.workspace = true
anyhow.workspace = true
base64.workspace = true
blake3.workspace = true
cargo-credential.workspace = true
cargo-platform.workspace = true
cargo-util-schemas.workspace = true
cargo-util-terminal.workspace = true
cargo-util.workspace = true
clap = { workspace = true, features = ["wrap_help"] }
clap_complete.workspace = true
Expand Down Expand Up @@ -211,8 +212,6 @@ serde_ignored.workspace = true
serde_json = { workspace = true, features = ["raw_value"] }
sha1.workspace = true
shell-escape.workspace = true
supports-hyperlinks.workspace = true
supports-unicode.workspace = true
tar.workspace = true
tempfile.workspace = true
thiserror.workspace = true
Expand Down
1 change: 1 addition & 0 deletions benches/benchsuite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ publish = false
[dependencies]
cargo.workspace = true
cargo-util.workspace = true
cargo-util-terminal.workspace = true
criterion.workspace = true
flate2.workspace = true
rand.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion benches/benchsuite/benches/global_cache_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn cargo_home() -> PathBuf {

fn initialize_context() -> GlobalContext {
// Set up config.
let shell = cargo::core::Shell::new();
let shell = cargo_util_terminal::Shell::new();
let homedir = cargo_home();
if !homedir.exists() {
fs::create_dir_all(&homedir).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion benches/benchsuite/src/bin/capture-last-use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::path::Path;

fn main() {
// Set up config.
let shell = cargo::core::Shell::new();
let shell = cargo_util_terminal::Shell::new();
let homedir = Path::new(env!("CARGO_MANIFEST_DIR")).join("global-cache-tracker");
let cwd = homedir.clone();
let mut gctx = GlobalContext::new(shell, cwd, homedir.clone());
Expand Down
2 changes: 1 addition & 1 deletion benches/benchsuite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl Fixtures {

/// Creates a new Context.
pub fn make_context(&self, ws_root: &Path) -> GlobalContext {
let shell = cargo::core::Shell::new();
let shell = cargo_util_terminal::Shell::new();
let mut gctx = GlobalContext::new(shell, ws_root.to_path_buf(), self.cargo_home());
// Configure is needed to set the target_dir which is needed to write
// the .rustc_info.json file which is very expensive.
Expand Down
38 changes: 38 additions & 0 deletions crates/cargo-util-terminal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "cargo-util-terminal"
version = "0.1.0"
rust-version = "1.94" # MSRV:1
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "Cargo's terminal rendering"

[dependencies]
annotate-snippets.workspace = true
anstream.workspace = true
anstyle.workspace = true
anstyle-hyperlink = { workspace = true, features = ["file"] }
anstyle-progress.workspace = true
anyhow.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["raw_value"] }
supports-hyperlinks.workspace = true
supports-unicode.workspace = true

[target.'cfg(unix)'.dependencies]
libc.workspace = true

[target.'cfg(windows)'.dependencies.windows-sys]
workspace = true
features = [
"Win32_Foundation",
"Win32_Security",
"Win32_Storage_FileSystem",
"Win32_System_IO",
"Win32_System_Console",
"Win32_System_JobObjects",
"Win32_System_Threading",
]

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/cargo-util-terminal/LICENSE-APACHE
1 change: 1 addition & 0 deletions crates/cargo-util-terminal/LICENSE-MIT
3 changes: 3 additions & 0 deletions crates/cargo-util-terminal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> This crate is maintained by the Cargo team, primarily for use by Cargo
> and not intended for external use (except as a transitive dependency). This
> crate may make major changes to its APIs or be deprecated without warning.
19 changes: 19 additions & 0 deletions crates/cargo-util-terminal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! Miscellaneous support code used by Cargo.
//!
//! > This crate is maintained by the Cargo team, primarily for use by Cargo
//! > and not intended for external use (except as a transitive dependency). This
//! > crate may make major changes to its APIs or be deprecated without warning.
#![allow(clippy::disallowed_methods)]

mod shell;

pub mod style;

pub use shell::ColorChoice;
pub use shell::Hyperlink;
pub use shell::Shell;
pub use shell::TtyWidth;
pub use shell::Verbosity;

pub type CargoResult<T> = anyhow::Result<T>;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use annotate_snippets::{Renderer, Report};
use anstream::AutoStream;
use anstyle::Style;

use crate::util::errors::CargoResult;
use crate::util::style::*;
use crate::CargoResult;
use crate::style::*;

pub use anstyle_hyperlink::Hyperlink;

Expand Down Expand Up @@ -373,7 +373,7 @@ impl Shell {
}
}

pub(crate) fn set_unstable_flags_rustc_unicode(&mut self, yes: bool) -> CargoResult<()> {
pub fn set_unstable_flags_rustc_unicode(&mut self, yes: bool) -> CargoResult<()> {
if let ShellOut::Stream {
unstable_flags_rustc_unicode,
..
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions crates/xtask-bump-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ publish = false
anyhow.workspace = true
cargo.workspace = true
cargo-util.workspace = true
cargo-util-terminal.workspace = true
clap.workspace = true
git2.workspace = true
semver.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/xtask-bump-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
let matches = cli.get_matches();

let mut gctx = cargo::util::context::GlobalContext::default().unwrap_or_else(|e| {
let mut eval = cargo::core::shell::Shell::new();
let mut eval = cargo_util_terminal::Shell::new();
cargo::exit_with_error(e.into(), &mut eval)
});
if let Err(e) = xtask::exec(&matches, &mut gctx) {
Expand Down
11 changes: 11 additions & 0 deletions crates/xtask-bump-check/src/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
// See `TO_PUBLISH` in publish.py.
"home",
];
let crates_not_checked = ["cargo-util-terminal"];

status(&format!("base commit `{}`", base_commit.id()))?;
status(&format!("head commit `{}`", head_commit.id()))?;
Expand All @@ -152,6 +153,10 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
continue;
}

if crates_not_checked.contains(&pkg_name) {
continue;
}

let Some(changed_member) = changed_members.get(pkg_name) else {
tracing::trace!("skipping {pkg_name}, may be removed or not published");
continue;
Expand Down Expand Up @@ -186,6 +191,9 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
.arg("--workspace")
.arg("--baseline-rev")
.arg(referenced_commit.id().to_string());
for krate in crates_not_checked {
cmd.args(&["--exclude", krate]);
}
for krate in crates_not_check_against_channels {
cmd.args(&["--exclude", krate]);
}
Expand All @@ -208,6 +216,9 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
.arg("check-release")
.arg("--workspace")
.args(&["--exclude", "cargo"]);
for krate in crates_not_checked {
cmd.args(&["--exclude", krate]);
}

gctx.shell().status("Running", &cmd)?;
cmd.exec()?;
Expand Down
1 change: 1 addition & 0 deletions publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'crates/cargo-util',
'crates/crates-io',
'crates/cargo-util-schemas',
'crates/cargo-util-terminal',
'crates/cargo-test-macro',
'crates/cargo-test-support',
'crates/build-rs',
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use super::third_party_subcommands;
use super::user_defined_aliases;
use crate::command_prelude::*;
use crate::util::is_rustup;
use cargo::core::shell::ColorChoice;
use cargo::util::style;
use cargo_util_terminal::ColorChoice;

#[tracing::instrument(skip_all)]
pub fn main(gctx: &mut GlobalContext) -> CliResult {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ help: specify a package with `-p <PKGID>`
let verbosity = ws.gctx().shell().verbosity();
ws.gctx()
.shell()
.set_verbosity(cargo::core::Verbosity::Quiet);
.set_verbosity(cargo_util_terminal::Verbosity::Quiet);
let resolve = resolve_ws(&ws, dry_run);
ws.gctx().shell().set_verbosity(verbosity);
resolve?.1
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use std::path::Path;

use crate::command_prelude::*;
use crate::util::restricted_names::is_glob_pattern;
use cargo::core::Verbosity;
use cargo::core::Workspace;
use cargo::ops::{self, CompileFilter, Packages};
use cargo::util::closest;
use cargo_util::ProcessError;
use cargo_util_terminal::Verbosity;
use itertools::Itertools as _;

pub fn cli() -> Command {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use cargo::core::features;
use cargo::core::shell::Shell;
use cargo::util::network::http::http_handle;
use cargo::util::network::http::needs_custom_http_transport;
use cargo::util::{self, CargoResult, closest_msg, command_prelude};
use cargo_util::{ProcessBuilder, ProcessError};
use cargo_util_schemas::manifest::StringOrVec;
use cargo_util_terminal::Shell;
use std::collections::BTreeMap;
use std::env;
use std::ffi::OsStr;
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/fingerprint/dirty_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::fmt::Debug;
use serde::Serialize;

use super::*;
use crate::core::Shell;
use crate::core::compiler::UnitIndex;
use cargo_util_terminal::Shell;

/// Tells a better story of why a build is considered "dirty" that leads
/// to a recompile. Usually constructed via [`Fingerprint::compare`].
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/job_queue/job_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct JobState<'a, 'gctx> {
/// interleaving is still prevented as the lock would be held for the whole printing of an
/// output message.
///
/// [`Shell`]: crate::core::Shell
/// [`Shell`]: cargo_util_terminal::Shell
/// [`GlobalContext`]: crate::GlobalContext
output: Option<&'a DiagDedupe<'gctx>>,

Expand Down
3 changes: 2 additions & 1 deletion src/cargo/core/compiler/job_queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,15 @@ use crate::core::compiler::future_incompat::{
self, FutureBreakageItem, FutureIncompatReportPackage,
};
use crate::core::resolver::ResolveBehavior;
use crate::core::{PackageId, Shell, TargetKind};
use crate::core::{PackageId, TargetKind};
use crate::util::CargoResult;
use crate::util::context::WarningHandling;
use crate::util::diagnostic_server::{self, DiagnosticPrinter};
use crate::util::errors::AlreadyPrintedError;
use crate::util::machine_message::{self, Message as _};
use crate::util::{self, internal};
use crate::util::{DependencyQueue, GlobalContext, Progress, ProgressStyle, Queue};
use cargo_util_terminal::Shell;

/// This structure is backed by the `DependencyQueue` type and manages the
/// queueing of compilation steps for each package. Packages enqueue units of
Expand Down
3 changes: 2 additions & 1 deletion src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub use crate::core::compiler::unit::UnitIndex;
pub use crate::core::compiler::unit::UnitInterner;
use crate::core::manifest::TargetSourcePath;
use crate::core::profiles::{PanicStrategy, Profile, StripInner};
use crate::core::{Feature, PackageId, Target, Verbosity};
use crate::core::{Feature, PackageId, Target};
use crate::lints::get_key_value;
use crate::util::OnceExt;
use crate::util::context::WarningHandling;
Expand All @@ -115,6 +115,7 @@ use cargo_util::{ProcessBuilder, ProcessError, paths};
use cargo_util_schemas::manifest::TomlDebugInfo;
use cargo_util_schemas::manifest::TomlTrimPaths;
use cargo_util_schemas::manifest::TomlTrimPathsValue;
use cargo_util_terminal::Verbosity;
use rustfix::diagnostics::Applicability;

const RUSTDOC_CRATE_VERSION_FLAG: &str = "--crate-version";
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/global_cache_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
//!
//! There are checks for read-only filesystems, which is generally ignored.

use crate::core::Verbosity;
use crate::core::gc::GcOpts;
use crate::ops::CleanContext;
use crate::util::cache_lock::CacheLockMode;
Expand All @@ -124,6 +123,7 @@ use crate::util::{Filesystem, Progress, ProgressStyle};
use crate::{CargoResult, GlobalContext};
use anyhow::{Context as _, bail};
use cargo_util::paths;
use cargo_util_terminal::Verbosity;
use rusqlite::{Connection, ErrorCode, params};
use std::collections::{HashMap, hash_map};
use std::path::{Path, PathBuf};
Expand Down
Loading