@@ -253,8 +253,7 @@ mod command_helpers;
253
253
use command_helpers:: * ;
254
254
255
255
mod tool;
256
- pub use tool:: Tool ;
257
- use tool:: ToolFamily ;
256
+ pub use tool:: { Tool , ToolFamily } ;
258
257
259
258
mod tempfile;
260
259
@@ -701,25 +700,25 @@ impl Build {
701
700
if compiler. family . verbose_stderr ( ) {
702
701
compiler. remove_arg ( "-v" . into ( ) ) ;
703
702
}
704
- if compiler. is_like_clang ( ) {
703
+ let clang = matches ! ( compiler. family( ) , ToolFamily :: Clang { .. } ) ;
704
+ if clang {
705
705
// Avoid reporting that the arg is unsupported just because the
706
706
// compiler complains that it wasn't used.
707
707
compiler. push_cc_arg ( "-Wno-unused-command-line-argument" . into ( ) ) ;
708
708
}
709
709
710
710
let mut cmd = compiler. to_command ( ) ;
711
711
let is_arm = matches ! ( target. arch, "aarch64" | "arm" ) ;
712
- let clang = compiler. is_like_clang ( ) ;
713
- let gnu = compiler. family == ToolFamily :: Gnu ;
712
+ let msvc = matches ! ( compiler. family( ) , ToolFamily :: Msvc { .. } ) ;
714
713
command_add_output_file (
715
714
& mut cmd,
716
715
& obj,
717
716
CmdAddOutputFileArgs {
718
717
cuda : self . cuda ,
719
718
is_assembler_msvc : false ,
720
- msvc : compiler . is_like_msvc ( ) ,
719
+ msvc,
721
720
clang,
722
- gnu,
721
+ gnu : matches ! ( compiler . family ( ) , ToolFamily :: Gnu ) ,
723
722
is_asm : false ,
724
723
is_arm,
725
724
} ,
@@ -733,7 +732,7 @@ impl Build {
733
732
734
733
// On MSVC skip the CRT by setting the entry point to `main`.
735
734
// This way we don't need to add the default library paths.
736
- if compiler . is_like_msvc ( ) {
735
+ if msvc {
737
736
// Flags from _LINK_ are appended to the linker arguments.
738
737
cmd. env ( "_LINK_" , "-entry:main" ) ;
739
738
}
@@ -1753,8 +1752,6 @@ impl Build {
1753
1752
let target = self . get_target ( ) ?;
1754
1753
let msvc = target. env == "msvc" ;
1755
1754
let compiler = self . try_get_compiler ( ) ?;
1756
- let clang = compiler. is_like_clang ( ) ;
1757
- let gnu = compiler. family == ToolFamily :: Gnu ;
1758
1755
1759
1756
let is_assembler_msvc = msvc && asm_ext == Some ( AsmFileExt :: DotAsm ) ;
1760
1757
let ( mut cmd, name) = if is_assembler_msvc {
@@ -1782,9 +1779,9 @@ impl Build {
1782
1779
CmdAddOutputFileArgs {
1783
1780
cuda : self . cuda ,
1784
1781
is_assembler_msvc,
1785
- msvc : compiler. is_like_msvc ( ) ,
1786
- clang,
1787
- gnu,
1782
+ msvc : matches ! ( compiler. family ( ) , ToolFamily :: Msvc { .. } ) ,
1783
+ clang : matches ! ( compiler . family ( ) , ToolFamily :: Clang { .. } ) ,
1784
+ gnu : matches ! ( compiler . family ( ) , ToolFamily :: Gnu ) ,
1788
1785
is_asm,
1789
1786
is_arm,
1790
1787
} ,
@@ -2036,15 +2033,16 @@ impl Build {
2036
2033
}
2037
2034
}
2038
2035
ToolFamily :: Gnu | ToolFamily :: Clang { .. } => {
2036
+ let clang = matches ! ( cmd. family, ToolFamily :: Clang { .. } ) ;
2039
2037
// arm-linux-androideabi-gcc 4.8 shipped with Android NDK does
2040
2038
// not support '-Oz'
2041
- if opt_level == "z" && !cmd . is_like_clang ( ) {
2039
+ if opt_level == "z" && !clang {
2042
2040
cmd. push_opt_unless_duplicate ( "-Os" . into ( ) ) ;
2043
2041
} else {
2044
2042
cmd. push_opt_unless_duplicate ( format ! ( "-O{}" , opt_level) . into ( ) ) ;
2045
2043
}
2046
2044
2047
- if cmd . is_like_clang ( ) && target. os == "android" {
2045
+ if clang && target. os == "android" {
2048
2046
// For compatibility with code that doesn't use pre-defined `__ANDROID__` macro.
2049
2047
// If compiler used via ndk-build or cmake (officially supported build methods)
2050
2048
// this macros is defined.
@@ -2141,7 +2139,9 @@ impl Build {
2141
2139
family. add_force_frame_pointer ( cmd) ;
2142
2140
}
2143
2141
2144
- if !cmd. is_like_msvc ( ) {
2142
+ let msvc = matches ! ( cmd. family, ToolFamily :: Msvc { .. } ) ;
2143
+
2144
+ if !msvc {
2145
2145
if target. arch == "x86" {
2146
2146
cmd. args . push ( "-m32" . into ( ) ) ;
2147
2147
} else if target. abi == "x32" {
@@ -2653,7 +2653,8 @@ impl Build {
2653
2653
// it does not support iOS in general), but we specify them anyhow in
2654
2654
// case we actually have a Clang-like compiler disguised as a GNU-like
2655
2655
// compiler, or in case GCC adds support for these in the future.
2656
- if !cmd. is_like_clang ( ) {
2656
+ let clang = matches ! ( cmd. family, ToolFamily :: Clang { .. } ) ;
2657
+ if !clang {
2657
2658
let min_version = self . apple_deployment_target ( & target) ;
2658
2659
cmd. args
2659
2660
. push ( target. apple_version_flag ( & min_version) . into ( ) ) ;
@@ -3225,7 +3226,8 @@ impl Build {
3225
3226
// And even extend it to gcc targets by searching for "ar" instead
3226
3227
// of "llvm-ar"...
3227
3228
let compiler = self . get_base_compiler ( ) . ok ( ) ?;
3228
- if compiler. is_like_clang ( ) {
3229
+ let clang = matches ! ( compiler. family, ToolFamily :: Clang { .. } ) ;
3230
+ if clang {
3229
3231
name = format ! ( "llvm-{}" , tool) . into ( ) ;
3230
3232
self . search_programs (
3231
3233
& mut self . cmd ( & compiler. path ) ,
0 commit comments