@@ -23,7 +23,7 @@ use std::io::Write;
23
23
use std:: path:: { PathBuf , Path } ;
24
24
use std:: process:: Command ;
25
25
26
- use { Build , Compiler } ;
26
+ use { Build , Compiler , Mode } ;
27
27
use util:: { cp_r, libdir, is_dylib, cp_filtered, copy} ;
28
28
29
29
pub fn package_vers ( build : & Build ) -> & str {
@@ -289,6 +289,50 @@ pub fn rust_src_location(build: &Build) -> PathBuf {
289
289
distdir ( build) . join ( & format ! ( "{}.tar.gz" , plain_name) )
290
290
}
291
291
292
+ /// Creates a tarball of save-analysis metadata, if available.
293
+ pub fn analysis ( build : & Build , compiler : & Compiler , target : & str ) {
294
+ println ! ( "Dist analysis" ) ;
295
+
296
+ if build. config . channel != "nightly" {
297
+ println ! ( "Skipping dist-analysis - not on nightly channel" ) ;
298
+ return ;
299
+ }
300
+ if compiler. stage != 2 {
301
+ return
302
+ }
303
+
304
+ let name = format ! ( "rust-analysis-{}" , package_vers( build) ) ;
305
+ let image = tmpdir ( build) . join ( format ! ( "{}-{}-image" , name, target) ) ;
306
+
307
+ let src = build. stage_out ( compiler, Mode :: Libstd ) . join ( target) . join ( "release" ) . join ( "deps" ) ;
308
+
309
+ let image_src = src. join ( "save-analysis" ) ;
310
+ let dst = image. join ( "lib/rustlib" ) . join ( target) . join ( "analysis" ) ;
311
+ t ! ( fs:: create_dir_all( & dst) ) ;
312
+ cp_r ( & image_src, & dst) ;
313
+
314
+ let mut cmd = Command :: new ( "sh" ) ;
315
+ cmd. arg ( sanitize_sh ( & build. src . join ( "src/rust-installer/gen-installer.sh" ) ) )
316
+ . arg ( "--product-name=Rust" )
317
+ . arg ( "--rel-manifest-dir=rustlib" )
318
+ . arg ( "--success-message=save-analysis-saved." )
319
+ . arg ( format ! ( "--image-dir={}" , sanitize_sh( & image) ) )
320
+ . arg ( format ! ( "--work-dir={}" , sanitize_sh( & tmpdir( build) ) ) )
321
+ . arg ( format ! ( "--output-dir={}" , sanitize_sh( & distdir( build) ) ) )
322
+ . arg ( format ! ( "--package-name={}-{}" , name, target) )
323
+ . arg ( format ! ( "--component-name=rust-analysis-{}" , target) )
324
+ . arg ( "--legacy-manifest-dirs=rustlib,cargo" ) ;
325
+ build. run ( & mut cmd) ;
326
+ t ! ( fs:: remove_dir_all( & image) ) ;
327
+
328
+ // Create plain source tarball
329
+ let mut cmd = Command :: new ( "tar" ) ;
330
+ cmd. arg ( "-czf" ) . arg ( sanitize_sh ( & distdir ( build) . join ( & format ! ( "{}.tar.gz" , name) ) ) )
331
+ . arg ( "analysis" )
332
+ . current_dir ( & src) ;
333
+ build. run ( & mut cmd) ;
334
+ }
335
+
292
336
/// Creates the `rust-src` installer component and the plain source tarball
293
337
pub fn rust_src ( build : & Build ) {
294
338
println ! ( "Dist src" ) ;
0 commit comments