1
Fork 0

target-triple -> target-tuple

This commit is contained in:
Lukas Wirth 2025-01-07 12:21:27 +01:00
parent 764ce49445
commit 05770f2599
8 changed files with 17 additions and 17 deletions

View file

@ -19,7 +19,7 @@ pub mod project_json;
pub mod toolchain_info { pub mod toolchain_info {
pub mod rustc_cfg; pub mod rustc_cfg;
pub mod target_data_layout; pub mod target_data_layout;
pub mod target_triple; pub mod target_tuple;
use std::path::Path; use std::path::Path;

View file

@ -14,7 +14,7 @@ pub fn get(
target: Option<&str>, target: Option<&str>,
extra_env: &FxHashMap<String, String>, extra_env: &FxHashMap<String, String>,
) -> anyhow::Result<Vec<String>> { ) -> anyhow::Result<Vec<String>> {
let _p = tracing::info_span!("target_triple::get").entered(); let _p = tracing::info_span!("target_tuple::get").entered();
if let Some(target) = target { if let Some(target) = target {
return Ok(vec![target.to_owned()]); return Ok(vec![target.to_owned()]);
} }
@ -28,10 +28,10 @@ pub fn get(
} }
QueryConfig::Rustc(sysroot, current_dir) => (sysroot, current_dir), QueryConfig::Rustc(sysroot, current_dir) => (sysroot, current_dir),
}; };
rustc_discover_host_triple(extra_env, sysroot, current_dir).map(|it| vec![it]) rustc_discover_host_tuple(extra_env, sysroot, current_dir).map(|it| vec![it])
} }
fn rustc_discover_host_triple( fn rustc_discover_host_tuple(
extra_env: &FxHashMap<String, String>, extra_env: &FxHashMap<String, String>,
sysroot: &Sysroot, sysroot: &Sysroot,
current_dir: &Path, current_dir: &Path,
@ -60,14 +60,14 @@ fn cargo_config_build_target(
cmd.envs(extra_env); cmd.envs(extra_env);
cmd.current_dir(cargo_toml.parent()).env("RUSTC_BOOTSTRAP", "1"); cmd.current_dir(cargo_toml.parent()).env("RUSTC_BOOTSTRAP", "1");
cmd.args(["-Z", "unstable-options", "config", "get", "build.target"]); cmd.args(["-Z", "unstable-options", "config", "get", "build.target"]);
// if successful we receive `build.target = "target-triple"` // if successful we receive `build.target = "target-tuple"`
// or `build.target = ["<target 1>", ..]` // or `build.target = ["<target 1>", ..]`
// this might be `error: config value `build.target` is not set` in which case we // this might be `error: config value `build.target` is not set` in which case we
// don't wanna log the error // don't wanna log the error
utf8_stdout(&mut cmd).and_then(parse_output_cargo_config_build_target).ok() utf8_stdout(&mut cmd).and_then(parse_output_cargo_config_build_target).ok()
} }
// Parses `"build.target = [target-triple, target-triple, ...]"` or `"build.target = "target-triple"` // Parses `"build.target = [target-tuple, target-tuple, ...]"` or `"build.target = "target-tuple"`
fn parse_output_cargo_config_build_target(stdout: String) -> anyhow::Result<Vec<String>> { fn parse_output_cargo_config_build_target(stdout: String) -> anyhow::Result<Vec<String>> {
let trimmed = stdout.trim_start_matches("build.target = ").trim_matches('"'); let trimmed = stdout.trim_start_matches("build.target = ").trim_matches('"');

View file

@ -26,7 +26,7 @@ use crate::{
env::{cargo_config_env, inject_cargo_env, inject_cargo_package_env, inject_rustc_tool_env}, env::{cargo_config_env, inject_cargo_env, inject_cargo_package_env, inject_rustc_tool_env},
project_json::{Crate, CrateArrayIdx}, project_json::{Crate, CrateArrayIdx},
sysroot::{SysrootCrate, SysrootWorkspace}, sysroot::{SysrootCrate, SysrootWorkspace},
toolchain_info::{rustc_cfg, target_data_layout, target_triple, QueryConfig}, toolchain_info::{rustc_cfg, target_data_layout, target_tuple, QueryConfig},
utf8_stdout, CargoConfig, CargoWorkspace, CfgOverrides, InvocationStrategy, ManifestPath, utf8_stdout, CargoConfig, CargoWorkspace, CfgOverrides, InvocationStrategy, ManifestPath,
Package, ProjectJson, ProjectManifest, Sysroot, SysrootSourceWorkspaceConfig, TargetData, Package, ProjectJson, ProjectManifest, Sysroot, SysrootSourceWorkspaceConfig, TargetData,
TargetKind, WorkspaceBuildScripts, TargetKind, WorkspaceBuildScripts,
@ -242,7 +242,7 @@ impl ProjectWorkspace {
.ok_or_else(|| Some("Failed to discover rustc source for sysroot.".to_owned())), .ok_or_else(|| Some("Failed to discover rustc source for sysroot.".to_owned())),
None => Err(None), None => Err(None),
}; };
let targets = target_triple::get( let targets = target_tuple::get(
QueryConfig::Cargo(&sysroot, cargo_toml), QueryConfig::Cargo(&sysroot, cargo_toml),
config.target.as_deref(), config.target.as_deref(),
&config.extra_env, &config.extra_env,
@ -397,7 +397,7 @@ impl ProjectWorkspace {
} }
}; };
let targets = target_triple::get( let targets = target_tuple::get(
QueryConfig::Cargo(&sysroot, detached_file), QueryConfig::Cargo(&sysroot, detached_file),
config.target.as_deref(), config.target.as_deref(),
&config.extra_env, &config.extra_env,

View file

@ -600,7 +600,7 @@ config_data! {
/// ///
/// This option does not take effect until rust-analyzer is restarted. /// This option does not take effect until rust-analyzer is restarted.
cargo_sysrootSrc: Option<String> = None, cargo_sysrootSrc: Option<String> = None,
/// Compilation target override (target triple). /// Compilation target override (target tuple).
// FIXME(@poliorcetics): move to multiple targets here too, but this will need more work // FIXME(@poliorcetics): move to multiple targets here too, but this will need more work
// than `checkOnSave_target` // than `checkOnSave_target`
cargo_target: Option<String> = None, cargo_target: Option<String> = None,
@ -2041,7 +2041,7 @@ impl Config {
pub(crate) fn cargo_test_options(&self, source_root: Option<SourceRootId>) -> CargoOptions { pub(crate) fn cargo_test_options(&self, source_root: Option<SourceRootId>) -> CargoOptions {
CargoOptions { CargoOptions {
target_triples: self.cargo_target(source_root).clone().into_iter().collect(), target_tuples: self.cargo_target(source_root).clone().into_iter().collect(),
all_targets: false, all_targets: false,
no_default_features: *self.cargo_noDefaultFeatures(source_root), no_default_features: *self.cargo_noDefaultFeatures(source_root),
all_features: matches!(self.cargo_features(source_root), CargoFeaturesDef::All), all_features: matches!(self.cargo_features(source_root), CargoFeaturesDef::All),
@ -2076,7 +2076,7 @@ impl Config {
Some(_) | None => FlycheckConfig::CargoCommand { Some(_) | None => FlycheckConfig::CargoCommand {
command: self.check_command(source_root).clone(), command: self.check_command(source_root).clone(),
options: CargoOptions { options: CargoOptions {
target_triples: self target_tuples: self
.check_targets(source_root) .check_targets(source_root)
.clone() .clone()
.and_then(|targets| match &targets.0[..] { .and_then(|targets| match &targets.0[..] {

View file

@ -28,7 +28,7 @@ pub(crate) enum InvocationStrategy {
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct CargoOptions { pub(crate) struct CargoOptions {
pub(crate) target_triples: Vec<String>, pub(crate) target_tuples: Vec<String>,
pub(crate) all_targets: bool, pub(crate) all_targets: bool,
pub(crate) no_default_features: bool, pub(crate) no_default_features: bool,
pub(crate) all_features: bool, pub(crate) all_features: bool,
@ -49,7 +49,7 @@ pub(crate) enum Target {
impl CargoOptions { impl CargoOptions {
pub(crate) fn apply_on_command(&self, cmd: &mut Command) { pub(crate) fn apply_on_command(&self, cmd: &mut Command) {
for target in &self.target_triples { for target in &self.target_tuples {
cmd.args(["--target", target.as_str()]); cmd.args(["--target", target.as_str()]);
} }
if self.all_targets { if self.all_targets {

View file

@ -146,7 +146,7 @@ This option does not take effect until rust-analyzer is restarted.
[[rust-analyzer.cargo.target]]rust-analyzer.cargo.target (default: `null`):: [[rust-analyzer.cargo.target]]rust-analyzer.cargo.target (default: `null`)::
+ +
-- --
Compilation target override (target triple). Compilation target override (target tuple).
-- --
[[rust-analyzer.cargo.targetDir]]rust-analyzer.cargo.targetDir (default: `null`):: [[rust-analyzer.cargo.targetDir]]rust-analyzer.cargo.targetDir (default: `null`)::
+ +

View file

@ -769,7 +769,7 @@ interface Crate {
/// The set of cfgs activated for a given crate, like /// The set of cfgs activated for a given crate, like
/// `["unix", "feature=\"foo\"", "feature=\"bar\""]`. /// `["unix", "feature=\"foo\"", "feature=\"bar\""]`.
cfg: string[]; cfg: string[];
/// Target triple for this Crate. /// Target tuple for this Crate.
/// ///
/// Used when running `rustc --print cfg` /// Used when running `rustc --print cfg`
/// to get target-specific cfgs. /// to get target-specific cfgs.

View file

@ -888,7 +888,7 @@
"title": "cargo", "title": "cargo",
"properties": { "properties": {
"rust-analyzer.cargo.target": { "rust-analyzer.cargo.target": {
"markdownDescription": "Compilation target override (target triple).", "markdownDescription": "Compilation target override (target tuple).",
"default": null, "default": null,
"type": [ "type": [
"null", "null",