@@ -745,14 +745,18 @@ impl Step for RustAnalyzerProcMacroSrv {
745
745
746
746
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
747
747
let builder = run. builder ;
748
- run. path ( "src/tools/rust-analyzer" ) . default_condition (
749
- builder. config . extended
750
- && builder
751
- . config
752
- . tools
753
- . as_ref ( )
754
- . map_or ( true , |tools| tools. iter ( ) . any ( |tool| tool == "rust-analyzer" ) ) ,
755
- )
748
+
749
+ // Allow building `rust-analyzer-proc-macro-srv` both as part of the `rust-analyzer` and as a stand-alone tool.
750
+ run. path ( "src/tools/rust-analyzer" )
751
+ . path ( "src/tools/rust-analyzer/crates/proc-macro-srv-cli" )
752
+ . default_condition (
753
+ builder. config . extended
754
+ && builder. config . tools . as_ref ( ) . map_or ( true , |tools| {
755
+ tools. iter ( ) . any ( |tool| {
756
+ tool == "rust-analyzer" || tool == "rust-analyzer-proc-macro-srv"
757
+ } )
758
+ } ) ,
759
+ )
756
760
}
757
761
758
762
fn make_run ( run : RunConfig < ' _ > ) {
@@ -763,7 +767,7 @@ impl Step for RustAnalyzerProcMacroSrv {
763
767
}
764
768
765
769
fn run ( self , builder : & Builder < ' _ > ) -> Option < PathBuf > {
766
- builder. ensure ( ToolBuild {
770
+ let path = builder. ensure ( ToolBuild {
767
771
compiler : self . compiler ,
768
772
target : self . target ,
769
773
tool : "rust-analyzer-proc-macro-srv" ,
@@ -772,7 +776,19 @@ impl Step for RustAnalyzerProcMacroSrv {
772
776
extra_features : vec ! [ "proc-macro-srv/sysroot-abi" . to_owned( ) ] ,
773
777
is_optional_tool : false ,
774
778
source_type : SourceType :: InTree ,
775
- } )
779
+ } ) ?;
780
+
781
+ // Copy `rust-analyzer-proc-macro-srv` to `build/triple/stageN/libexec/`
782
+ // so that r-a can use it.
783
+ let libexec_path = builder
784
+ . out
785
+ . join ( & * builder. config . build . triple )
786
+ . join ( format ! ( "stage{}" , self . compiler. stage) )
787
+ . join ( "libexec" ) ;
788
+ t ! ( fs:: create_dir_all( & libexec_path) ) ;
789
+ builder. copy ( & path, & libexec_path. join ( "rust-analyzer-proc-macro-srv" ) ) ;
790
+
791
+ Some ( path)
776
792
}
777
793
}
778
794
0 commit comments