@@ -1035,7 +1035,7 @@ pub struct Rls {
10351035}
10361036
10371037impl Step for Rls {
1038- type Output = PathBuf ;
1038+ type Output = Option < PathBuf > ;
10391039 const ONLY_BUILD_TARGETS : bool = true ;
10401040 const ONLY_HOSTS : bool = true ;
10411041
@@ -1050,12 +1050,17 @@ impl Step for Rls {
10501050 } ) ;
10511051 }
10521052
1053- fn run ( self , builder : & Builder ) -> PathBuf {
1053+ fn run ( self , builder : & Builder ) -> Option < PathBuf > {
10541054 let build = builder. build ;
10551055 let stage = self . stage ;
10561056 let target = self . target ;
10571057 assert ! ( build. config. extended) ;
10581058
1059+ if !builder. config . toolstate . rls . testing ( ) {
1060+ println ! ( "skipping Dist RLS stage{} ({})" , stage, target) ;
1061+ return None
1062+ }
1063+
10591064 println ! ( "Dist RLS stage{} ({})" , stage, target) ;
10601065 let src = build. src . join ( "src/tools/rls" ) ;
10611066 let release_num = build. release_num ( "rls" ) ;
@@ -1102,7 +1107,7 @@ impl Step for Rls {
11021107 . arg ( "--component-name=rls-preview" ) ;
11031108
11041109 build. run ( & mut cmd) ;
1105- distdir ( build) . join ( format ! ( "{}-{}.tar.gz" , name, target) )
1110+ Some ( distdir ( build) . join ( format ! ( "{}-{}.tar.gz" , name, target) ) )
11061111 }
11071112}
11081113
@@ -1202,8 +1207,12 @@ impl Step for Extended {
12021207 // upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
12031208 // the std files during uninstall. To do this ensure that rustc comes
12041209 // before rust-std in the list below.
1205- let mut tarballs = vec ! [ rustc_installer, cargo_installer, rls_installer,
1206- analysis_installer, std_installer] ;
1210+ let mut tarballs = Vec :: new ( ) ;
1211+ tarballs. push ( rustc_installer) ;
1212+ tarballs. push ( cargo_installer) ;
1213+ tarballs. extend ( rls_installer. clone ( ) ) ;
1214+ tarballs. push ( analysis_installer) ;
1215+ tarballs. push ( std_installer) ;
12071216 if build. config . docs {
12081217 tarballs. push ( docs_installer) ;
12091218 }
@@ -1245,35 +1254,38 @@ impl Step for Extended {
12451254 }
12461255 rtf. push_str ( "}" ) ;
12471256
1257+ fn filter ( contents : & str , marker : & str ) -> String {
1258+ let start = format ! ( "tool-{}-start" , marker) ;
1259+ let end = format ! ( "tool-{}-end" , marker) ;
1260+ let mut lines = Vec :: new ( ) ;
1261+ let mut omitted = false ;
1262+ for line in contents. lines ( ) {
1263+ if line. contains ( & start) {
1264+ omitted = true ;
1265+ } else if line. contains ( & end) {
1266+ omitted = false ;
1267+ } else if !omitted {
1268+ lines. push ( line) ;
1269+ }
1270+ }
1271+
1272+ lines. join ( "\n " )
1273+ }
1274+
1275+ let xform = |p : & Path | {
1276+ let mut contents = String :: new ( ) ;
1277+ t ! ( t!( File :: open( p) ) . read_to_string( & mut contents) ) ;
1278+ if rls_installer. is_none ( ) {
1279+ contents = filter ( & contents, "rls" ) ;
1280+ }
1281+ let ret = tmp. join ( p. file_name ( ) . unwrap ( ) ) ;
1282+ t ! ( t!( File :: create( & ret) ) . write_all( contents. as_bytes( ) ) ) ;
1283+ return ret
1284+ } ;
1285+
12481286 if target. contains ( "apple-darwin" ) {
12491287 let pkg = tmp. join ( "pkg" ) ;
12501288 let _ = fs:: remove_dir_all ( & pkg) ;
1251- t ! ( fs:: create_dir_all( pkg. join( "rustc" ) ) ) ;
1252- t ! ( fs:: create_dir_all( pkg. join( "cargo" ) ) ) ;
1253- t ! ( fs:: create_dir_all( pkg. join( "rust-docs" ) ) ) ;
1254- t ! ( fs:: create_dir_all( pkg. join( "rust-std" ) ) ) ;
1255- t ! ( fs:: create_dir_all( pkg. join( "rls" ) ) ) ;
1256- t ! ( fs:: create_dir_all( pkg. join( "rust-analysis" ) ) ) ;
1257-
1258- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rustc" ) , target) ) ,
1259- & pkg. join ( "rustc" ) ) ;
1260- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "cargo" ) , target) ) ,
1261- & pkg. join ( "cargo" ) ) ;
1262- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rust-docs" ) , target) ) ,
1263- & pkg. join ( "rust-docs" ) ) ;
1264- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rust-std" ) , target) ) ,
1265- & pkg. join ( "rust-std" ) ) ;
1266- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rls" ) , target) ) ,
1267- & pkg. join ( "rls" ) ) ;
1268- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rust-analysis" ) , target) ) ,
1269- & pkg. join ( "rust-analysis" ) ) ;
1270-
1271- install ( & etc. join ( "pkg/postinstall" ) , & pkg. join ( "rustc" ) , 0o755 ) ;
1272- install ( & etc. join ( "pkg/postinstall" ) , & pkg. join ( "cargo" ) , 0o755 ) ;
1273- install ( & etc. join ( "pkg/postinstall" ) , & pkg. join ( "rust-docs" ) , 0o755 ) ;
1274- install ( & etc. join ( "pkg/postinstall" ) , & pkg. join ( "rust-std" ) , 0o755 ) ;
1275- install ( & etc. join ( "pkg/postinstall" ) , & pkg. join ( "rls" ) , 0o755 ) ;
1276- install ( & etc. join ( "pkg/postinstall" ) , & pkg. join ( "rust-analysis" ) , 0o755 ) ;
12771289
12781290 let pkgbuild = |component : & str | {
12791291 let mut cmd = Command :: new ( "pkgbuild" ) ;
@@ -1283,12 +1295,23 @@ impl Step for Extended {
12831295 . arg ( pkg. join ( component) . with_extension ( "pkg" ) ) ;
12841296 build. run ( & mut cmd) ;
12851297 } ;
1286- pkgbuild ( "rustc" ) ;
1287- pkgbuild ( "cargo" ) ;
1288- pkgbuild ( "rust-docs" ) ;
1289- pkgbuild ( "rust-std" ) ;
1290- pkgbuild ( "rls" ) ;
1291- pkgbuild ( "rust-analysis" ) ;
1298+
1299+ let prepare = |name : & str | {
1300+ t ! ( fs:: create_dir_all( pkg. join( name) ) ) ;
1301+ cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, name) , target) ) ,
1302+ & pkg. join ( name) ) ;
1303+ install ( & etc. join ( "pkg/postinstall" ) , & pkg. join ( name) , 0o755 ) ;
1304+ pkgbuild ( name) ;
1305+ } ;
1306+ prepare ( "rustc" ) ;
1307+ prepare ( "cargo" ) ;
1308+ prepare ( "rust-docs" ) ;
1309+ prepare ( "rust-std" ) ;
1310+ prepare ( "rust-analysis" ) ;
1311+
1312+ if rls_installer. is_some ( ) {
1313+ prepare ( "rls" ) ;
1314+ }
12921315
12931316 // create an 'uninstall' package
12941317 install ( & etc. join ( "pkg/postinstall" ) , & pkg. join ( "uninstall" ) , 0o755 ) ;
@@ -1298,7 +1321,7 @@ impl Step for Extended {
12981321 t ! ( t!( File :: create( pkg. join( "res/LICENSE.txt" ) ) ) . write_all( license. as_bytes( ) ) ) ;
12991322 install ( & etc. join ( "gfx/rust-logo.png" ) , & pkg. join ( "res" ) , 0o644 ) ;
13001323 let mut cmd = Command :: new ( "productbuild" ) ;
1301- cmd. arg ( "--distribution" ) . arg ( etc. join ( "pkg/Distribution.xml" ) )
1324+ cmd. arg ( "--distribution" ) . arg ( xform ( & etc. join ( "pkg/Distribution.xml" ) ) )
13021325 . arg ( "--resources" ) . arg ( pkg. join ( "res" ) )
13031326 . arg ( distdir ( build) . join ( format ! ( "{}-{}.pkg" ,
13041327 pkgname( build, "rust" ) ,
@@ -1310,46 +1333,34 @@ impl Step for Extended {
13101333 if target. contains ( "windows" ) {
13111334 let exe = tmp. join ( "exe" ) ;
13121335 let _ = fs:: remove_dir_all ( & exe) ;
1313- t ! ( fs:: create_dir_all( exe. join( "rustc" ) ) ) ;
1314- t ! ( fs:: create_dir_all( exe. join( "cargo" ) ) ) ;
1315- t ! ( fs:: create_dir_all( exe. join( "rls" ) ) ) ;
1316- t ! ( fs:: create_dir_all( exe. join( "rust-analysis" ) ) ) ;
1317- t ! ( fs:: create_dir_all( exe. join( "rust-docs" ) ) ) ;
1318- t ! ( fs:: create_dir_all( exe. join( "rust-std" ) ) ) ;
1319- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rustc" ) , target) )
1320- . join ( "rustc" ) ,
1321- & exe. join ( "rustc" ) ) ;
1322- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "cargo" ) , target) )
1323- . join ( "cargo" ) ,
1324- & exe. join ( "cargo" ) ) ;
1325- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rust-docs" ) , target) )
1326- . join ( "rust-docs" ) ,
1327- & exe. join ( "rust-docs" ) ) ;
1328- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rust-std" ) , target) )
1329- . join ( format ! ( "rust-std-{}" , target) ) ,
1330- & exe. join ( "rust-std" ) ) ;
1331- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rls" ) , target) ) . join ( "rls-preview" ) ,
1332- & exe. join ( "rls" ) ) ;
1333- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rust-analysis" ) , target) )
1334- . join ( format ! ( "rust-analysis-{}" , target) ) ,
1335- & exe. join ( "rust-analysis" ) ) ;
1336-
1337- t ! ( fs:: remove_file( exe. join( "rustc/manifest.in" ) ) ) ;
1338- t ! ( fs:: remove_file( exe. join( "cargo/manifest.in" ) ) ) ;
1339- t ! ( fs:: remove_file( exe. join( "rust-docs/manifest.in" ) ) ) ;
1340- t ! ( fs:: remove_file( exe. join( "rust-std/manifest.in" ) ) ) ;
1341- t ! ( fs:: remove_file( exe. join( "rls/manifest.in" ) ) ) ;
1342- t ! ( fs:: remove_file( exe. join( "rust-analysis/manifest.in" ) ) ) ;
13431336
1337+ let prepare = |name : & str | {
1338+ t ! ( fs:: create_dir_all( exe. join( name) ) ) ;
1339+ let dir = if name == "rust-std" || name == "rust-analysis" {
1340+ format ! ( "{}-{}" , name, target)
1341+ } else if name == "rls" {
1342+ "rls-preview" . to_string ( )
1343+ } else {
1344+ name. to_string ( )
1345+ } ;
1346+ cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, name) , target) )
1347+ . join ( dir) ,
1348+ & exe. join ( name) ) ;
1349+ t ! ( fs:: remove_file( exe. join( name) . join( "manifest.in" ) ) ) ;
1350+ } ;
1351+ prepare ( "rustc" ) ;
1352+ prepare ( "cargo" ) ;
1353+ prepare ( "rust-analysis" ) ;
1354+ prepare ( "rust-docs" ) ;
1355+ prepare ( "rust-std" ) ;
1356+ if rls_installer. is_some ( ) {
1357+ prepare ( "rls" ) ;
1358+ }
13441359 if target. contains ( "windows-gnu" ) {
1345- t ! ( fs:: create_dir_all( exe. join( "rust-mingw" ) ) ) ;
1346- cp_r ( & work. join ( & format ! ( "{}-{}" , pkgname( build, "rust-mingw" ) , target) )
1347- . join ( "rust-mingw" ) ,
1348- & exe. join ( "rust-mingw" ) ) ;
1349- t ! ( fs:: remove_file( exe. join( "rust-mingw/manifest.in" ) ) ) ;
1360+ prepare ( "rust-mingw" ) ;
13501361 }
13511362
1352- install ( & etc. join ( "exe/rust.iss" ) , & exe, 0o644 ) ;
1363+ install ( & xform ( & etc. join ( "exe/rust.iss" ) ) , & exe, 0o644 ) ;
13531364 install ( & etc. join ( "exe/modpath.iss" ) , & exe, 0o644 ) ;
13541365 install ( & etc. join ( "exe/upgrade.iss" ) , & exe, 0o644 ) ;
13551366 install ( & etc. join ( "gfx/rust-logo.ico" ) , & exe, 0o644 ) ;
@@ -1413,16 +1424,18 @@ impl Step for Extended {
14131424 . arg ( "-dr" ) . arg ( "Std" )
14141425 . arg ( "-var" ) . arg ( "var.StdDir" )
14151426 . arg ( "-out" ) . arg ( exe. join ( "StdGroup.wxs" ) ) ) ;
1416- build. run ( Command :: new ( & heat)
1417- . current_dir ( & exe)
1418- . arg ( "dir" )
1419- . arg ( "rls" )
1420- . args ( & heat_flags)
1421- . arg ( "-cg" ) . arg ( "RlsGroup" )
1422- . arg ( "-dr" ) . arg ( "Rls" )
1423- . arg ( "-var" ) . arg ( "var.RlsDir" )
1424- . arg ( "-out" ) . arg ( exe. join ( "RlsGroup.wxs" ) )
1425- . arg ( "-t" ) . arg ( etc. join ( "msi/remove-duplicates.xsl" ) ) ) ;
1427+ if rls_installer. is_some ( ) {
1428+ build. run ( Command :: new ( & heat)
1429+ . current_dir ( & exe)
1430+ . arg ( "dir" )
1431+ . arg ( "rls" )
1432+ . args ( & heat_flags)
1433+ . arg ( "-cg" ) . arg ( "RlsGroup" )
1434+ . arg ( "-dr" ) . arg ( "Rls" )
1435+ . arg ( "-var" ) . arg ( "var.RlsDir" )
1436+ . arg ( "-out" ) . arg ( exe. join ( "RlsGroup.wxs" ) )
1437+ . arg ( "-t" ) . arg ( etc. join ( "msi/remove-duplicates.xsl" ) ) ) ;
1438+ }
14261439 build. run ( Command :: new ( & heat)
14271440 . current_dir ( & exe)
14281441 . arg ( "dir" )
@@ -1456,26 +1469,30 @@ impl Step for Extended {
14561469 . arg ( "-dDocsDir=rust-docs" )
14571470 . arg ( "-dCargoDir=cargo" )
14581471 . arg ( "-dStdDir=rust-std" )
1459- . arg ( "-dRlsDir=rls" )
14601472 . arg ( "-dAnalysisDir=rust-analysis" )
14611473 . arg ( "-arch" ) . arg ( & arch)
14621474 . arg ( "-out" ) . arg ( & output)
14631475 . arg ( & input) ;
14641476 add_env ( build, & mut cmd, target) ;
14651477
1478+ if rls_installer. is_some ( ) {
1479+ cmd. arg ( "-dRlsDir=rls" ) ;
1480+ }
14661481 if target. contains ( "windows-gnu" ) {
14671482 cmd. arg ( "-dGccDir=rust-mingw" ) ;
14681483 }
14691484 build. run ( & mut cmd) ;
14701485 } ;
1471- candle ( & etc. join ( "msi/rust.wxs" ) ) ;
1486+ candle ( & xform ( & etc. join ( "msi/rust.wxs" ) ) ) ;
14721487 candle ( & etc. join ( "msi/ui.wxs" ) ) ;
14731488 candle ( & etc. join ( "msi/rustwelcomedlg.wxs" ) ) ;
14741489 candle ( "RustcGroup.wxs" . as_ref ( ) ) ;
14751490 candle ( "DocsGroup.wxs" . as_ref ( ) ) ;
14761491 candle ( "CargoGroup.wxs" . as_ref ( ) ) ;
14771492 candle ( "StdGroup.wxs" . as_ref ( ) ) ;
1478- candle ( "RlsGroup.wxs" . as_ref ( ) ) ;
1493+ if rls_installer. is_some ( ) {
1494+ candle ( "RlsGroup.wxs" . as_ref ( ) ) ;
1495+ }
14791496 candle ( "AnalysisGroup.wxs" . as_ref ( ) ) ;
14801497
14811498 if target. contains ( "windows-gnu" ) {
@@ -1499,10 +1516,13 @@ impl Step for Extended {
14991516 . arg ( "DocsGroup.wixobj" )
15001517 . arg ( "CargoGroup.wixobj" )
15011518 . arg ( "StdGroup.wixobj" )
1502- . arg ( "RlsGroup.wixobj" )
15031519 . arg ( "AnalysisGroup.wixobj" )
15041520 . current_dir ( & exe) ;
15051521
1522+ if rls_installer. is_some ( ) {
1523+ cmd. arg ( "RlsGroup.wixobj" ) ;
1524+ }
1525+
15061526 if target. contains ( "windows-gnu" ) {
15071527 cmd. arg ( "GccGroup.wixobj" ) ;
15081528 }
0 commit comments