diff --git a/.github/.cspell/project-dictionary.txt b/.github/.cspell/project-dictionary.txt index 422f712c..644c3ec1 100644 --- a/.github/.cspell/project-dictionary.txt +++ b/.github/.cspell/project-dictionary.txt @@ -14,6 +14,7 @@ mcdc microkernel MSYSTEM nextest +normpath notcovered profdata profraw diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcb0939d..d2771ddf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,8 @@ jobs: uses: taiki-e/github-actions/.github/workflows/msrv.yml@main with: event_name: ${{ github.event_name }} + # MSRV is 1.74 on Windows due to normpath. + target: x86_64-unknown-linux-gnu release-dry-run: uses: taiki-e/github-actions/.github/workflows/release-dry-run.yml@main tidy: diff --git a/Cargo.toml b/Cargo.toml index 256c1a5f..fb4c4d86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ pkg-fmt = "tgz" [dependencies] anyhow = "1.0.47" camino = "1.0.5" -cargo-config2 = "0.1.29" +cargo-config2 = "0.1.31" duct = "0.13.1" fs-err = "3" glob = "0.3" @@ -43,9 +43,6 @@ tar = "0.4.40" termcolor = "1.1.2" walkdir = "2.2.3" -[target.'cfg(windows)'.dependencies] -home = "0.5" - [dev-dependencies] easy-ext = "1" rustversion = "1" diff --git a/README.md b/README.md index eacc4e23..1a920af6 100644 --- a/README.md +++ b/README.md @@ -634,7 +634,7 @@ cargo-llvm-cov --json | some-program cargo +stable install cargo-llvm-cov --locked ``` -Currently, installing cargo-llvm-cov requires rustc 1.73+. +Currently, installing cargo-llvm-cov requires rustc 1.73+ for non-Windows and rustc 1.74+ for Windows. cargo-llvm-cov is usually runnable with Cargo versions older than the Rust version required for installation (e.g., `cargo +1.60 llvm-cov`). Currently, to run diff --git a/src/env.rs b/src/env.rs index 89cc7709..3c6ef1ac 100644 --- a/src/env.rs +++ b/src/env.rs @@ -1,12 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT pub(crate) use std::env::*; -use std::{ - ffi::OsString, - path::{Path, PathBuf}, -}; +use std::ffi::OsString; use anyhow::Result; +pub(crate) use cargo_config2::{cargo_home_with_cwd, home_dir, rustup_home_with_cwd}; pub(crate) fn var(key: &str) -> Result> { match std::env::var(key) { @@ -20,43 +18,3 @@ pub(crate) fn var(key: &str) -> Result> { pub(crate) fn var_os(key: &str) -> Option { std::env::var_os(key).filter(|v| !v.is_empty()) } - -// Use the home crate only on Windows which std::env::home_dir is not correct. -// https://github.com/rust-lang/cargo/blob/0.80.0/crates/home/src/lib.rs#L65-L72 -#[cfg(windows)] -pub(crate) use home::home_dir; -#[cfg(not(windows))] -pub(crate) fn home_dir() -> Option { - #[allow(deprecated)] - std::env::home_dir() -} - -// Follow the cargo's behavior. -// https://github.com/rust-lang/cargo/blob/0.80.0/crates/home/src/lib.rs#L77-L86 -// https://github.com/rust-lang/cargo/blob/0.80.0/crates/home/src/lib.rs#L114-L123 -// https://github.com/rust-lang/cargo/blob/0.80.0/crates/home/src/env.rs#L63-L77 -// https://github.com/rust-lang/cargo/blob/0.80.0/crates/home/src/env.rs#L92-L106 -pub(crate) fn cargo_home_with_cwd(cwd: &Path) -> Option { - match var_os("CARGO_HOME").map(PathBuf::from) { - Some(home) => { - if home.is_absolute() { - Some(home) - } else { - Some(cwd.join(home)) - } - } - _ => Some(home_dir()?.join(".cargo")), - } -} -pub(crate) fn rustup_home_with_cwd(cwd: &Path) -> Option { - match var_os("RUSTUP_HOME").map(PathBuf::from) { - Some(home) => { - if home.is_absolute() { - Some(home) - } else { - Some(cwd.join(home)) - } - } - _ => Some(home_dir()?.join(".rustup")), - } -}