File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -84,15 +84,27 @@ impl CompileKind {
8484 fallback : CompileKindFallback ,
8585 ) -> CargoResult < Vec < CompileKind > > {
8686 let dedup = |targets : & [ String ] | {
87- Ok ( targets
87+ let deduplicated_targets = targets
8888 . iter ( )
89- . map ( |value| Ok ( CompileKind :: Target ( CompileTarget :: new ( value) ?) ) )
89+ . map ( |value| {
90+ // This neatly substitutes the manually-specified `host` target directive
91+ // with the compiling machine's target triple.
92+
93+ if value. as_str ( ) == "host" {
94+ let host_triple = env ! ( "RUST_HOST_TARGET" ) ;
95+ Ok ( CompileKind :: Target ( CompileTarget :: new ( host_triple) ?) )
96+ } else {
97+ Ok ( CompileKind :: Target ( CompileTarget :: new ( value. as_str ( ) ) ?) )
98+ }
99+ } )
90100 // First collect into a set to deduplicate any `--target` passed
91101 // more than once...
92102 . collect :: < CargoResult < BTreeSet < _ > > > ( ) ?
93103 // ... then generate a flat list for everything else to use.
94104 . into_iter ( )
95- . collect ( ) )
105+ . collect ( ) ;
106+
107+ Ok ( deduplicated_targets)
96108 } ;
97109
98110 if !targets. is_empty ( ) {
Original file line number Diff line number Diff line change @@ -1257,6 +1257,9 @@ fn get_target_triples() -> Vec<clap_complete::CompletionCandidate> {
12571257 }
12581258 }
12591259
1260+ // Allow tab-completion for `host` as the desired target.
1261+ candidates. push ( clap_complete:: CompletionCandidate :: new ( "host" ) ) ;
1262+
12601263 candidates
12611264}
12621265
You can’t perform that action at this time.
0 commit comments