mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
rename rustc_cfg::Config
to rustc_cfg::RustcCfgConfig
and import
This commit is contained in:
parent
553152e2d5
commit
fad3823a20
@ -7,7 +7,7 @@ use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::{cfg_flag::CfgFlag, utf8_stdout, ManifestPath, Sysroot};
|
||||
|
||||
pub(crate) enum Config<'a> {
|
||||
pub(crate) enum RustcCfgConfig<'a> {
|
||||
Cargo(&'a ManifestPath),
|
||||
Explicit(&'a Sysroot),
|
||||
Discover,
|
||||
@ -16,7 +16,7 @@ pub(crate) enum Config<'a> {
|
||||
pub(crate) fn get(
|
||||
target: Option<&str>,
|
||||
extra_env: &FxHashMap<String, String>,
|
||||
config: Config<'_>,
|
||||
config: RustcCfgConfig<'_>,
|
||||
) -> Vec<CfgFlag> {
|
||||
let _p = profile::span("rustc_cfg::get");
|
||||
let mut res = Vec::with_capacity(6 * 2 + 1);
|
||||
@ -61,10 +61,10 @@ pub(crate) fn get(
|
||||
fn get_rust_cfgs(
|
||||
target: Option<&str>,
|
||||
extra_env: &FxHashMap<String, String>,
|
||||
config: Config<'_>,
|
||||
config: RustcCfgConfig<'_>,
|
||||
) -> anyhow::Result<String> {
|
||||
let mut cmd = match config {
|
||||
Config::Cargo(cargo_toml) => {
|
||||
RustcCfgConfig::Cargo(cargo_toml) => {
|
||||
let mut cmd = Command::new(toolchain::cargo());
|
||||
cmd.envs(extra_env);
|
||||
cmd.current_dir(cargo_toml.parent())
|
||||
@ -76,12 +76,12 @@ fn get_rust_cfgs(
|
||||
|
||||
return utf8_stdout(cmd).context("Unable to run `cargo rustc`");
|
||||
}
|
||||
Config::Explicit(sysroot) => {
|
||||
RustcCfgConfig::Explicit(sysroot) => {
|
||||
let rustc: std::path::PathBuf = sysroot.discover_rustc()?.into();
|
||||
tracing::debug!(?rustc, "using explicit rustc from sysroot");
|
||||
Command::new(rustc)
|
||||
}
|
||||
Config::Discover => {
|
||||
RustcCfgConfig::Discover => {
|
||||
let rustc = toolchain::rustc();
|
||||
tracing::debug!(?rustc, "using rustc from env");
|
||||
Command::new(rustc)
|
||||
|
@ -21,7 +21,7 @@ use crate::{
|
||||
cargo_workspace::{DepKind, PackageData, RustLibSource},
|
||||
cfg_flag::CfgFlag,
|
||||
project_json::Crate,
|
||||
rustc_cfg,
|
||||
rustc_cfg::{self, RustcCfgConfig},
|
||||
sysroot::SysrootCrate,
|
||||
target_data_layout, utf8_stdout, CargoConfig, CargoWorkspace, InvocationStrategy, ManifestPath,
|
||||
Package, ProjectJson, ProjectManifest, Sysroot, TargetData, TargetKind, WorkspaceBuildScripts,
|
||||
@ -282,7 +282,7 @@ impl ProjectWorkspace {
|
||||
let rustc_cfg = rustc_cfg::get(
|
||||
config.target.as_deref(),
|
||||
&config.extra_env,
|
||||
rustc_cfg::Config::Cargo(cargo_toml),
|
||||
RustcCfgConfig::Cargo(cargo_toml),
|
||||
);
|
||||
|
||||
let cfg_overrides = config.cfg_overrides.clone();
|
||||
@ -337,11 +337,11 @@ impl ProjectWorkspace {
|
||||
let config = match &sysroot {
|
||||
Ok(sysroot) => {
|
||||
tracing::debug!(src_root = %sysroot.src_root(), root = %sysroot.root(), "Using sysroot");
|
||||
rustc_cfg::Config::Explicit(sysroot)
|
||||
RustcCfgConfig::Explicit(sysroot)
|
||||
}
|
||||
Err(_) => {
|
||||
tracing::debug!("discovering sysroot");
|
||||
rustc_cfg::Config::Discover
|
||||
RustcCfgConfig::Discover
|
||||
}
|
||||
};
|
||||
|
||||
@ -370,11 +370,11 @@ impl ProjectWorkspace {
|
||||
let rustc_config = match &sysroot {
|
||||
Ok(sysroot) => {
|
||||
tracing::info!(src_root = %sysroot.src_root(), root = %sysroot.root(), "Using sysroot");
|
||||
rustc_cfg::Config::Explicit(sysroot)
|
||||
RustcCfgConfig::Explicit(sysroot)
|
||||
}
|
||||
Err(_) => {
|
||||
tracing::info!("discovering sysroot");
|
||||
rustc_cfg::Config::Discover
|
||||
RustcCfgConfig::Discover
|
||||
}
|
||||
};
|
||||
|
||||
@ -774,8 +774,8 @@ fn project_json_to_crate_graph(
|
||||
let target_cfgs = match target.as_deref() {
|
||||
Some(target) => cfg_cache.entry(target).or_insert_with(|| {
|
||||
let rustc_cfg = match sysroot {
|
||||
Some(sysroot) => rustc_cfg::Config::Explicit(sysroot),
|
||||
None => rustc_cfg::Config::Discover,
|
||||
Some(sysroot) => RustcCfgConfig::Explicit(sysroot),
|
||||
None => RustcCfgConfig::Discover,
|
||||
};
|
||||
|
||||
rustc_cfg::get(Some(target), extra_env, rustc_cfg)
|
||||
|
Loading…
Reference in New Issue
Block a user