@@ -16,7 +16,7 @@ use crate::util::{add_dylib_path, exe, CiEnv};
1616use crate :: Compiler ;
1717use crate :: Mode ;
1818
19- #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
19+ #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
2020pub enum SourceType {
2121 InTree ,
2222 Submodule ,
@@ -226,14 +226,10 @@ pub fn prepare_tool_cargo(
226226 source_type : SourceType ,
227227 extra_features : & [ String ] ,
228228) -> CargoCommand {
229- let mut cargo = builder. cargo ( compiler, mode, target, command) ;
229+ let mut cargo = builder. cargo ( compiler, mode, source_type , target, command) ;
230230 let dir = builder. src . join ( path) ;
231231 cargo. arg ( "--manifest-path" ) . arg ( dir. join ( "Cargo.toml" ) ) ;
232232
233- if source_type == SourceType :: Submodule {
234- cargo. env ( "RUSTC_EXTERNAL_TOOL" , "1" ) ;
235- }
236-
237233 let mut features = extra_features. to_vec ( ) ;
238234 if builder. build . config . cargo_native_static {
239235 if path. ends_with ( "cargo" )
@@ -596,6 +592,7 @@ macro_rules! tool_extended {
596592 $path: expr,
597593 $tool_name: expr,
598594 stable = $stable: expr,
595+ $( in_tree = $in_tree: expr, ) *
599596 $extra_deps: block; ) +) => {
600597 $(
601598 #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
@@ -647,7 +644,11 @@ macro_rules! tool_extended {
647644 path: $path,
648645 extra_features: $sel. extra_features,
649646 is_optional_tool: true ,
650- source_type: SourceType :: Submodule ,
647+ source_type: if false $( || $in_tree) * {
648+ SourceType :: InTree
649+ } else {
650+ SourceType :: Submodule
651+ } ,
651652 } )
652653 }
653654 }
@@ -659,8 +660,8 @@ macro_rules! tool_extended {
659660// to make `./x.py build <tool>` work.
660661tool_extended ! ( ( self , builder) ,
661662 Cargofmt , rustfmt, "src/tools/rustfmt" , "cargo-fmt" , stable=true , { } ;
662- CargoClippy , clippy, "src/tools/clippy" , "cargo-clippy" , stable=true , { } ;
663- Clippy , clippy, "src/tools/clippy" , "clippy-driver" , stable=true , { } ;
663+ CargoClippy , clippy, "src/tools/clippy" , "cargo-clippy" , stable=true , in_tree= true , { } ;
664+ Clippy , clippy, "src/tools/clippy" , "clippy-driver" , stable=true , in_tree= true , { } ;
664665 Miri , miri, "src/tools/miri" , "miri" , stable=false , { } ;
665666 CargoMiri , miri, "src/tools/miri/cargo-miri" , "cargo-miri" , stable=false , { } ;
666667 Rls , rls, "src/tools/rls" , "rls" , stable=true , {
0 commit comments