@@ -23,8 +23,8 @@ use std::{
23
23
sync:: Arc ,
24
24
} ;
25
25
26
+ use crate :: Tool ;
26
27
use crate :: ToolFamily ;
27
- use crate :: { target:: TargetInfo , Tool } ;
28
28
29
29
const MSVC_FAMILY : ToolFamily = ToolFamily :: Msvc { clang_cl : false } ;
30
30
@@ -90,39 +90,53 @@ impl EnvGetter for StdEnvGetter {
90
90
/// Attempts to find a tool within an MSVC installation using the Windows
91
91
/// registry as a point to search from.
92
92
///
93
- /// The `target` argument is the target that the tool should work for (e.g.
94
- /// compile or link for) and the `tool` argument is the tool to find (e.g.
95
- /// `cl.exe` or `link.exe`).
93
+ /// The `arch_or_target` argument is the architecture or the Rust target
94
+ /// triple that the tool should work for (e.g. compile or link for). The
95
+ /// supported architecture names are:
96
+ /// - `"i586"`
97
+ /// - `"i686"`
98
+ /// - `"x86_64"`
99
+ /// - `"arm"`
100
+ /// - `"thumbv7a"`
101
+ /// - `"aarch64"`
102
+ /// - `"arm64ec"`
103
+ ///
104
+ /// The `tool` argument is the tool to find (e.g. `cl.exe` or `link.exe`).
96
105
///
97
106
/// This function will return `None` if the tool could not be found, or it will
98
107
/// return `Some(cmd)` which represents a command that's ready to execute the
99
108
/// tool with the appropriate environment variables set.
100
109
///
101
- /// Note that this function always returns `None` for non-MSVC targets.
102
- pub fn find ( target : & str , tool : & str ) -> Option < Command > {
103
- find_tool ( target, tool) . map ( |c| c. to_command ( ) )
110
+ /// Note that this function always returns `None` for non-MSVC targets (if a
111
+ /// full target name was specified).
112
+ pub fn find ( arch_or_target : & str , tool : & str ) -> Option < Command > {
113
+ find_tool ( arch_or_target, tool) . map ( |c| c. to_command ( ) )
104
114
}
105
115
106
116
/// Similar to the `find` function above, this function will attempt the same
107
117
/// operation (finding a MSVC tool in a local install) but instead returns a
108
118
/// `Tool` which may be introspected.
109
- pub fn find_tool ( target : & str , tool : & str ) -> Option < Tool > {
110
- find_tool_inner ( & target. parse ( ) . ok ( ) ?, tool, & StdEnvGetter )
119
+ pub fn find_tool ( arch_or_target : & str , tool : & str ) -> Option < Tool > {
120
+ let full_arch = if let Some ( ( full_arch, rest) ) = arch_or_target. split_once ( "-" ) {
121
+ // The logic is all tailored for MSVC, if the target is not that then
122
+ // bail out early.
123
+ if !rest. contains ( "msvc" ) {
124
+ return None ;
125
+ }
126
+ full_arch
127
+ } else {
128
+ arch_or_target
129
+ } ;
130
+ find_tool_inner ( full_arch, tool, & StdEnvGetter )
111
131
}
112
132
113
133
pub ( crate ) fn find_tool_inner (
114
- target : & TargetInfo ,
134
+ full_arch : & str ,
115
135
tool : & str ,
116
136
env_getter : & dyn EnvGetter ,
117
137
) -> Option < Tool > {
118
- // This logic is all tailored for MSVC, if we're not that then bail out
119
- // early.
120
- if target. env != "msvc" {
121
- return None ;
122
- }
123
-
124
138
// We only need the arch.
125
- let target = TargetArch ( target . full_arch ) ;
139
+ let target = TargetArch ( full_arch) ;
126
140
127
141
// Looks like msbuild isn't located in the same location as other tools like
128
142
// cl.exe and lib.exe.
0 commit comments