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
4 changes: 2 additions & 2 deletions etc/_cargo
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ _cargo() {
)

msgfmt='--message-format=[specify error format]:error format [human]:(human json short)'
triple='--target=[specify target tuple]:target tuple:_cargo_target_triple'
triple='--target=[specify target tuple]:target tuple:_cargo_target_tuple'
target='--target-dir=[specify directory for all generated artifacts]:directory:_directories'
registry='--registry=[specify registry to use]:registry'

Expand Down Expand Up @@ -409,7 +409,7 @@ _cargo_cmds() {
_describe -t commands 'command' commands
}

_cargo_target_triple() {
_cargo_target_tuple() {
local -a result

if (( $+commands[rustup] )); then
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn cli() -> Command {
.arg_jobs()
.arg_unsupported_keep_going()
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg_unit_graph()
.arg_timings()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn cli() -> Command {
.arg_redundant_default_mode("debug", "build", "release")
.arg_profile("Build artifacts with the specified profile")
.arg_parallel()
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg_artifact_dir()
.arg_unit_graph()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn cli() -> Command {
.arg_parallel()
.arg_release("Check artifacts in release mode, with optimizations")
.arg_profile("Check artifacts with the specified profile")
.arg_target_triple("Check for the target tuple")
.arg_target_tuple("Check for the target tuple")
.arg_target_dir()
.arg_unit_graph()
.arg_timings()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn cli() -> Command {
)
.arg_release("Clean only release artifacts")
.arg_profile("Clean only artifacts of the specified profile")
.arg_target_triple("Target tuple to clean output for")
.arg_target_tuple("Target tuple to clean output for")
.arg_target_dir()
.arg_manifest_path()
.arg_dry_run("Display what would be deleted without deleting anything")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn cli() -> Command {
.arg_parallel()
.arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg_unit_graph()
.arg_timings()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn cli() -> Command {
subcommand("fetch")
.about("Fetch dependencies of a package from the network")
.arg_silent_suggestion()
.arg_target_triple("Fetch dependencies for the target tuple")
.arg_target_tuple("Fetch dependencies for the target tuple")
.arg_manifest_path()
.after_help(color_print::cstr!(
"Run `<bright-cyan,bold>cargo help fetch</>` for more detailed information.\n"
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn cli() -> Command {
.arg_parallel()
.arg_release("Fix artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Fix for the target tuple")
.arg_target_tuple("Fix for the target tuple")
.arg_target_dir()
.arg_timings()
.arg_manifest_path()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn cli() -> Command {
)
.arg_redundant_default_mode("release", "install", "debug")
.arg_profile("Install artifacts with the specified profile")
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg_timings()
.after_help(color_print::cstr!(
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn cli() -> Command {
ArgValueCandidates::new(get_ws_member_candidates),
)
.arg_features()
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg_parallel()
.arg_manifest_path()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn cli() -> Command {
)
.arg_features()
.arg_parallel()
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg_manifest_path()
.after_help(color_print::cstr!(
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 @@ -36,7 +36,7 @@ pub fn cli() -> Command {
.arg_parallel()
.arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg_manifest_path()
.arg_ignore_rust_version()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn cli() -> Command {
.arg_parallel()
.arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Target tuple which compiles will be for")
.arg_target_tuple("Target tuple which compiles will be for")
.arg_target_dir()
.arg_unit_graph()
.arg_timings()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn cli() -> Command {
.arg_parallel()
.arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg(
opt("output-format", "The output type to write (unstable)")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn cli() -> Command {
.arg_unsupported_keep_going()
.arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Build for the target tuple")
.arg_target_tuple("Build for the target tuple")
.arg_target_dir()
.arg_unit_graph()
.arg_timings()
Expand Down
4 changes: 2 additions & 2 deletions src/bin/cargo/commands/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ pub fn cli() -> Command {
)
.arg_features()
.arg(flag("all-targets", "Deprecated, use --target=all instead").hide(true))
.arg_target_triple_with_candidates(
.arg_target_tuple_with_candidates(
"Filter dependencies matching the given target tuple (default host platform). \
Pass `all` to include all targets.",
ArgValueCandidates::new(get_target_triples_with_all),
ArgValueCandidates::new(get_target_tuples_with_all),
)
.arg_manifest_path()
.after_help(color_print::cstr!(
Expand Down
36 changes: 18 additions & 18 deletions src/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl TargetInfo {
&self,
crate_type: &CrateType,
flavor: FileFlavor,
target_triple: &str,
target_tuple: &str,
) -> CargoResult<Option<Vec<FileType>>> {
let crate_type = if *crate_type == CrateType::Lib {
CrateType::Rlib
Expand Down Expand Up @@ -448,7 +448,7 @@ impl TargetInfo {
if crate_type.is_dynamic() {
// Note: Custom JSON specs can alter the suffix. For now, we'll
// just ignore non-DLL suffixes.
if target_triple.ends_with("-windows-msvc") && suffix == ".dll" {
if target_tuple.ends_with("-windows-msvc") && suffix == ".dll" {
// See https://docs.microsoft.com/en-us/cpp/build/reference/working-with-import-libraries-and-export-files
// for more information about DLL import/export files.
ret.push(FileType {
Expand All @@ -467,9 +467,9 @@ impl TargetInfo {
should_replace_hyphens: true,
});
} else if suffix == ".dll"
&& (target_triple.ends_with("windows-gnu")
|| target_triple.ends_with("windows-gnullvm")
|| target_triple.ends_with("cygwin"))
&& (target_tuple.ends_with("windows-gnu")
|| target_tuple.ends_with("windows-gnullvm")
|| target_tuple.ends_with("cygwin"))
{
// See https://cygwin.com/cygwin-ug-net/dll.html for more
// information about GNU import libraries.
Expand All @@ -484,7 +484,7 @@ impl TargetInfo {
}
}

if target_triple.starts_with("wasm32-") && crate_type == CrateType::Bin && suffix == ".js" {
if target_tuple.starts_with("wasm32-") && crate_type == CrateType::Bin && suffix == ".js" {
// emscripten binaries generate a .js file, which loads a .wasm
// file.
ret.push(FileType {
Expand All @@ -511,7 +511,7 @@ impl TargetInfo {
}

// Handle separate debug files.
let is_apple = target_triple.contains("-apple-");
let is_apple = target_tuple.contains("-apple-");
if matches!(
crate_type,
CrateType::Bin | CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro
Expand All @@ -535,7 +535,7 @@ impl TargetInfo {
// the names to match.
should_replace_hyphens: false,
})
} else if target_triple.ends_with("-msvc") || target_triple.ends_with("-uefi") {
} else if target_tuple.ends_with("-msvc") || target_tuple.ends_with("-uefi") {
ret.push(FileType {
suffix: ".pdb".to_string(),
prefix: prefix.clone(),
Expand Down Expand Up @@ -599,12 +599,12 @@ impl TargetInfo {
&self,
mode: CompileMode,
target_kind: &TargetKind,
target_triple: &str,
target_tuple: &str,
) -> CargoResult<(Vec<FileType>, Vec<CrateType>)> {
match mode {
CompileMode::Build => self.calc_rustc_outputs(target_kind, target_triple),
CompileMode::Build => self.calc_rustc_outputs(target_kind, target_tuple),
CompileMode::Test => {
match self.file_types(&CrateType::Bin, FileFlavor::Normal, target_triple)? {
match self.file_types(&CrateType::Bin, FileFlavor::Normal, target_tuple)? {
Some(fts) => Ok((fts, Vec::new())),
None => Ok((Vec::new(), vec![CrateType::Bin])),
}
Expand All @@ -622,7 +622,7 @@ impl TargetInfo {
fn calc_rustc_outputs(
&self,
target_kind: &TargetKind,
target_triple: &str,
target_tuple: &str,
) -> CargoResult<(Vec<FileType>, Vec<CrateType>)> {
let mut unsupported = Vec::new();
let mut result = Vec::new();
Expand All @@ -633,7 +633,7 @@ impl TargetInfo {
} else {
FileFlavor::Normal
};
let file_types = self.file_types(crate_type, flavor, target_triple)?;
let file_types = self.file_types(crate_type, flavor, target_tuple)?;
match file_types {
Some(types) => {
result.extend(types);
Expand Down Expand Up @@ -909,7 +909,7 @@ fn rustflags_from_host(
flag: Flags,
host_triple: &str,
) -> CargoResult<Option<Vec<String>>> {
let target_cfg = gctx.host_cfg_triple(host_triple)?;
let target_cfg = gctx.host_cfg_tuple(host_triple)?;
let list = match flag {
Flags::Rust => &target_cfg.rustflags,
Flags::Rustdoc => {
Expand Down Expand Up @@ -1002,9 +1002,9 @@ impl<'gctx> RustcTargetData<'gctx> {

// This config is used for link overrides and choosing a linker.
let host_config = if target_applies_to_host {
gctx.target_cfg_triple(&rustc.host)?
gctx.target_cfg_tuple(&rustc.host)?
} else {
gctx.host_cfg_triple(&rustc.host)?
gctx.host_cfg_tuple(&rustc.host)?
};

// This is a hack. The unit_dependency graph builder "pretends" that
Expand All @@ -1013,7 +1013,7 @@ impl<'gctx> RustcTargetData<'gctx> {
// needs access to the target config data, create a copy so that it
// can be found. See `rebuild_unit_graph_shared` for why this is done.
if requested_kinds.iter().any(CompileKind::is_host) {
target_config.insert(host_target, gctx.target_cfg_triple(&rustc.host)?);
target_config.insert(host_target, gctx.target_cfg_tuple(&rustc.host)?);

// If target_applies_to_host is true, the host_info is the target info,
// otherwise we need to build target info for the target.
Expand Down Expand Up @@ -1076,7 +1076,7 @@ impl<'gctx> RustcTargetData<'gctx> {
if let CompileKind::Target(target) = kind {
if !self.target_config.contains_key(&target) {
self.target_config
.insert(target, self.gctx.target_cfg_triple(target.short_name())?);
.insert(target, self.gctx.target_cfg_tuple(target.short_name())?);
}
if !self.target_info.contains_key(&target) {
self.target_info.insert(
Expand Down
8 changes: 4 additions & 4 deletions src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2022,13 +2022,13 @@ impl GlobalContext {
}

/// Returns the `[host]` table definition for the given target tuple.
pub fn host_cfg_triple(&self, target: &str) -> CargoResult<TargetConfig> {
target::load_host_triple(self, target)
pub fn host_cfg_tuple(&self, target: &str) -> CargoResult<TargetConfig> {
target::load_host_tuple(self, target)
}

/// Returns the `[target]` table definition for the given target tuple.
pub fn target_cfg_triple(&self, target: &str) -> CargoResult<TargetConfig> {
target::load_target_triple(self, target)
pub fn target_cfg_tuple(&self, target: &str) -> CargoResult<TargetConfig> {
target::load_target_tuple(self, target)
}

/// Returns the cached [`SourceId`] corresponding to the main repository.
Expand Down
8 changes: 4 additions & 4 deletions src/context/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ pub(super) fn get_target_applies_to_host(gctx: &GlobalContext) -> CargoResult<bo
}

/// Loads a single `[host]` table for the given tuple.
pub(super) fn load_host_triple(gctx: &GlobalContext, triple: &str) -> CargoResult<TargetConfig> {
pub(super) fn load_host_tuple(gctx: &GlobalContext, tuple: &str) -> CargoResult<TargetConfig> {
if gctx.cli_unstable().host_config {
let host_triple_prefix = ["host", triple];
let host_triple_prefix = ["host", tuple];
let host_triple_key = ConfigKey::from_parts(host_triple_prefix);
let host_prefix = match gctx.get_cv(&host_triple_key)? {
Some(_) => host_triple_prefix.as_slice(),
Expand All @@ -112,8 +112,8 @@ pub(super) fn load_host_triple(gctx: &GlobalContext, triple: &str) -> CargoResul
}

/// Loads a single `[target]` table for the given tuple.
pub(super) fn load_target_triple(gctx: &GlobalContext, triple: &str) -> CargoResult<TargetConfig> {
load_config_table(gctx, &["target", triple])
pub(super) fn load_target_tuple(gctx: &GlobalContext, tuple: &str) -> CargoResult<TargetConfig> {
load_config_table(gctx, &["target", tuple])
}

/// Loads a single table for the given prefix.
Expand Down
20 changes: 10 additions & 10 deletions src/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ pub trait CommandExt: Sized {
self._arg(flag("doc", doc))
}

fn arg_target_triple(self, target: &'static str) -> Self {
self.arg_target_triple_with_candidates(target, ArgValueCandidates::new(get_target_triples))
fn arg_target_tuple(self, target: &'static str) -> Self {
self.arg_target_tuple_with_candidates(target, ArgValueCandidates::new(get_target_tuples))
}

fn arg_target_triple_with_candidates(
fn arg_target_tuple_with_candidates(
self,
target: &'static str,
target_completion: ArgValueCandidates,
Expand Down Expand Up @@ -1208,15 +1208,15 @@ fn get_crate_candidates(kind: TargetKind) -> CargoResult<Vec<clap_complete::Comp
Ok(targets)
}

fn get_target_triples() -> Vec<clap_complete::CompletionCandidate> {
fn get_target_tuples() -> Vec<clap_complete::CompletionCandidate> {
let mut candidates = Vec::new();

if let Ok(targets) = get_target_triples_from_rustup() {
if let Ok(targets) = get_target_tuples_from_rustup() {
candidates = targets;
}

if candidates.is_empty() {
if let Ok(targets) = get_target_triples_from_rustc() {
if let Ok(targets) = get_target_tuples_from_rustc() {
candidates = targets;
}
}
Expand All @@ -1232,15 +1232,15 @@ fn get_target_triples() -> Vec<clap_complete::CompletionCandidate> {
candidates
}

pub fn get_target_triples_with_all() -> Vec<clap_complete::CompletionCandidate> {
pub fn get_target_tuples_with_all() -> Vec<clap_complete::CompletionCandidate> {
let mut candidates = vec![
clap_complete::CompletionCandidate::new("all").help(Some("Include all targets".into())),
];
candidates.extend(get_target_triples());
candidates.extend(get_target_tuples());
candidates
}

fn get_target_triples_from_rustup() -> CargoResult<Vec<clap_complete::CompletionCandidate>> {
fn get_target_tuples_from_rustup() -> CargoResult<Vec<clap_complete::CompletionCandidate>> {
let output = std::process::Command::new("rustup")
.arg("target")
.arg("list")
Expand All @@ -1264,7 +1264,7 @@ fn get_target_triples_from_rustup() -> CargoResult<Vec<clap_complete::Completion
.collect())
}

fn get_target_triples_from_rustc() -> CargoResult<Vec<clap_complete::CompletionCandidate>> {
fn get_target_tuples_from_rustc() -> CargoResult<Vec<clap_complete::CompletionCandidate>> {
let gctx = new_gctx_for_completions()?;

let ws = Workspace::new(&find_root_manifest_for_wd(gctx.cwd())?, &gctx);
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Caused by:
}

#[cargo_test]
fn check_with_invalid_target_triple() {
fn check_with_invalid_target_tuple() {
// invalid name
let p = project()
.file(
Expand Down
Loading
Loading