@@ -34,6 +34,12 @@ pub enum SourceType {
34
34
Submodule ,
35
35
}
36
36
37
+ #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
38
+ pub enum ToolArtifactKind {
39
+ Binary ,
40
+ Library ,
41
+ }
42
+
37
43
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
38
44
struct ToolBuild {
39
45
compiler : Compiler ,
@@ -47,6 +53,8 @@ struct ToolBuild {
47
53
allow_features : & ' static str ,
48
54
/// Additional arguments to pass to the `cargo` invocation.
49
55
cargo_args : Vec < String > ,
56
+ /// Whether the tool builds a binary or a library.
57
+ artifact_kind : ToolArtifactKind ,
50
58
}
51
59
52
60
impl Builder < ' _ > {
@@ -79,7 +87,7 @@ impl Builder<'_> {
79
87
/// for using this type as `type Output = ToolBuildResult;`
80
88
#[ derive( Clone ) ]
81
89
pub struct ToolBuildResult {
82
- /// Executable path of the corresponding tool that was built.
90
+ /// Artifact path of the corresponding tool that was built.
83
91
pub tool_path : PathBuf ,
84
92
/// Compiler used to build the tool. For non-`ToolRustc` tools this is equal to `target_compiler`.
85
93
/// For `ToolRustc` this is one stage before of the `target_compiler`.
@@ -179,8 +187,14 @@ impl Step for ToolBuild {
179
187
if tool == "tidy" {
180
188
tool = "rust-tidy" ;
181
189
}
182
- let tool_path =
183
- copy_link_tool_bin ( builder, self . compiler , self . target , self . mode , tool) ;
190
+ let tool_path = match self . artifact_kind {
191
+ ToolArtifactKind :: Binary => {
192
+ copy_link_tool_bin ( builder, self . compiler , self . target , self . mode , tool)
193
+ }
194
+ ToolArtifactKind :: Library => builder
195
+ . cargo_out ( self . compiler , self . mode , self . target )
196
+ . join ( format ! ( "lib{tool}.rlib" ) ) ,
197
+ } ;
184
198
185
199
ToolBuildResult { tool_path, build_compiler : self . compiler , target_compiler }
186
200
}
@@ -330,6 +344,7 @@ macro_rules! bootstrap_tool {
330
344
$( , is_unstable_tool = $unstable: expr) *
331
345
$( , allow_features = $allow_features: expr) ?
332
346
$( , submodules = $submodules: expr) ?
347
+ $( , artifact_kind = $artifact_kind: expr) ?
333
348
;
334
349
) +) => {
335
350
#[ derive( PartialEq , Eq , Clone ) ]
@@ -389,6 +404,7 @@ macro_rules! bootstrap_tool {
389
404
builder. require_submodule( submodule, None ) ;
390
405
}
391
406
) *
407
+
392
408
builder. ensure( ToolBuild {
393
409
compiler: self . compiler,
394
410
target: self . target,
@@ -407,7 +423,12 @@ macro_rules! bootstrap_tool {
407
423
} ,
408
424
extra_features: vec![ ] ,
409
425
allow_features: concat!( $( $allow_features) * ) ,
410
- cargo_args: vec![ ]
426
+ cargo_args: vec![ ] ,
427
+ artifact_kind: if false $( || $artifact_kind == ToolArtifactKind :: Library ) * {
428
+ ToolArtifactKind :: Library
429
+ } else {
430
+ ToolArtifactKind :: Binary
431
+ }
411
432
} )
412
433
}
413
434
}
@@ -491,6 +512,7 @@ impl Step for RustcPerf {
491
512
// Only build the collector package, which is used for benchmarking through
492
513
// a CLI.
493
514
cargo_args : vec ! [ "-p" . to_string( ) , "collector" . to_string( ) ] ,
515
+ artifact_kind : ToolArtifactKind :: Binary ,
494
516
} ;
495
517
let res = builder. ensure ( tool. clone ( ) ) ;
496
518
// We also need to symlink the `rustc-fake` binary to the corresponding directory,
@@ -548,6 +570,7 @@ impl Step for ErrorIndex {
548
570
extra_features : Vec :: new ( ) ,
549
571
allow_features : "" ,
550
572
cargo_args : Vec :: new ( ) ,
573
+ artifact_kind : ToolArtifactKind :: Binary ,
551
574
} )
552
575
}
553
576
}
@@ -583,6 +606,7 @@ impl Step for RemoteTestServer {
583
606
extra_features : Vec :: new ( ) ,
584
607
allow_features : "" ,
585
608
cargo_args : Vec :: new ( ) ,
609
+ artifact_kind : ToolArtifactKind :: Binary ,
586
610
} )
587
611
}
588
612
}
@@ -687,6 +711,7 @@ impl Step for Rustdoc {
687
711
extra_features,
688
712
allow_features : "" ,
689
713
cargo_args : Vec :: new ( ) ,
714
+ artifact_kind : ToolArtifactKind :: Binary ,
690
715
} ) ;
691
716
692
717
// don't create a stage0-sysroot/bin directory.
@@ -741,6 +766,7 @@ impl Step for Cargo {
741
766
extra_features : Vec :: new ( ) ,
742
767
allow_features : "" ,
743
768
cargo_args : Vec :: new ( ) ,
769
+ artifact_kind : ToolArtifactKind :: Binary ,
744
770
} )
745
771
}
746
772
}
@@ -789,6 +815,7 @@ impl Step for LldWrapper {
789
815
extra_features : Vec :: new ( ) ,
790
816
allow_features : "" ,
791
817
cargo_args : Vec :: new ( ) ,
818
+ artifact_kind : ToolArtifactKind :: Binary ,
792
819
} ) ;
793
820
794
821
let libdir_bin = builder. sysroot_target_bindir ( self . target_compiler , target) ;
@@ -849,6 +876,7 @@ impl Step for RustAnalyzer {
849
876
source_type : SourceType :: InTree ,
850
877
allow_features : RustAnalyzer :: ALLOW_FEATURES ,
851
878
cargo_args : Vec :: new ( ) ,
879
+ artifact_kind : ToolArtifactKind :: Binary ,
852
880
} )
853
881
}
854
882
}
@@ -893,6 +921,7 @@ impl Step for RustAnalyzerProcMacroSrv {
893
921
source_type : SourceType :: InTree ,
894
922
allow_features : RustAnalyzer :: ALLOW_FEATURES ,
895
923
cargo_args : Vec :: new ( ) ,
924
+ artifact_kind : ToolArtifactKind :: Binary ,
896
925
} ) ;
897
926
898
927
// Copy `rust-analyzer-proc-macro-srv` to `<sysroot>/libexec/`
@@ -947,6 +976,7 @@ impl Step for LlvmBitcodeLinker {
947
976
extra_features : self . extra_features ,
948
977
allow_features : "" ,
949
978
cargo_args : Vec :: new ( ) ,
979
+ artifact_kind : ToolArtifactKind :: Binary ,
950
980
} ) ;
951
981
952
982
if tool_result. target_compiler . stage > 0 {
@@ -1126,6 +1156,7 @@ fn run_tool_build_step(
1126
1156
source_type : SourceType :: InTree ,
1127
1157
allow_features : "" ,
1128
1158
cargo_args : vec ! [ ] ,
1159
+ artifact_kind : ToolArtifactKind :: Binary ,
1129
1160
} ) ;
1130
1161
1131
1162
// FIXME: This should just be an if-let-chain, but those are unstable.
@@ -1204,6 +1235,7 @@ impl Step for TestFloatParse {
1204
1235
extra_features : Vec :: new ( ) ,
1205
1236
allow_features : "" ,
1206
1237
cargo_args : Vec :: new ( ) ,
1238
+ artifact_kind : ToolArtifactKind :: Binary ,
1207
1239
} )
1208
1240
}
1209
1241
}
0 commit comments