@@ -23,8 +23,8 @@ use std::{
2323 sync:: Arc ,
2424} ;
2525
26+ use crate :: Tool ;
2627use crate :: ToolFamily ;
27- use crate :: { target:: TargetInfo , Tool } ;
2828
2929const MSVC_FAMILY : ToolFamily = ToolFamily :: Msvc { clang_cl : false } ;
3030
@@ -90,39 +90,53 @@ impl EnvGetter for StdEnvGetter {
9090/// Attempts to find a tool within an MSVC installation using the Windows
9191/// registry as a point to search from.
9292///
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`).
96105///
97106/// This function will return `None` if the tool could not be found, or it will
98107/// return `Some(cmd)` which represents a command that's ready to execute the
99108/// tool with the appropriate environment variables set.
100109///
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 ( ) )
104114}
105115
106116/// Similar to the `find` function above, this function will attempt the same
107117/// operation (finding a MSVC tool in a local install) but instead returns a
108118/// `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 )
111131}
112132
113133pub ( crate ) fn find_tool_inner (
114- target : & TargetInfo ,
134+ full_arch : & str ,
115135 tool : & str ,
116136 env_getter : & dyn EnvGetter ,
117137) -> 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-
124138 // We only need the arch.
125- let target = TargetArch ( target . full_arch ) ;
139+ let target = TargetArch ( full_arch) ;
126140
127141 // Looks like msbuild isn't located in the same location as other tools like
128142 // cl.exe and lib.exe.
0 commit comments