@@ -19,6 +19,7 @@ use std::{
1919 collections:: { BTreeMap , BTreeSet , HashSet } ,
2020 fs:: File ,
2121 io:: { Read , Write } ,
22+ path:: { Path , PathBuf } ,
2223} ;
2324
2425const PLAYGROUND_TARGET_PLATFORM : & str = "x86_64-unknown-linux-gnu" ;
@@ -267,7 +268,7 @@ fn playground_metadata_features(pkg: &Package) -> Option<(Vec<String>, bool)> {
267268 }
268269}
269270
270- fn write_manifest ( manifest : TomlManifest , path : & str ) {
271+ fn write_manifest ( manifest : TomlManifest , path : impl AsRef < Path > ) {
271272 let mut f = File :: create ( path) . expect ( "Unable to create Cargo.toml" ) ;
272273 let content = toml:: to_vec ( & manifest) . expect ( "Couldn't serialize TOML" ) ;
273274 f. write_all ( & content) . expect ( "Couldn't write Cargo.toml" ) ;
@@ -463,13 +464,19 @@ fn main() {
463464 } ;
464465
465466 // Write manifest file.
466- let cargo_toml = "../compiler/base/Cargo.toml" ;
467- write_manifest ( manifest, cargo_toml) ;
468- println ! ( "wrote {}" , cargo_toml) ;
469-
470- let path = "../compiler/base/crate-information.json" ;
471- let mut f = File :: create ( path) . unwrap_or_else ( |e| panic ! ( "Unable to create {}: {}" , path, e) ) ;
467+ let base_directory: PathBuf = std:: env:: args_os ( )
468+ . nth ( 1 )
469+ . unwrap_or_else ( || "../compiler/base" . into ( ) )
470+ . into ( ) ;
471+
472+ let cargo_toml = base_directory. join ( "Cargo.toml" ) ;
473+ write_manifest ( manifest, & cargo_toml) ;
474+ println ! ( "wrote {}" , cargo_toml. display( ) ) ;
475+
476+ let path = base_directory. join ( "crate-information.json" ) ;
477+ let mut f = File :: create ( & path)
478+ . unwrap_or_else ( |e| panic ! ( "Unable to create {}: {}" , path. display( ) , e) ) ;
472479 serde_json:: to_writer_pretty ( & mut f, & infos)
473- . unwrap_or_else ( |e| panic ! ( "Unable to write {}: {}" , path, e) ) ;
474- println ! ( "Wrote {}" , path) ;
480+ . unwrap_or_else ( |e| panic ! ( "Unable to write {}: {}" , path. display ( ) , e) ) ;
481+ println ! ( "Wrote {}" , path. display ( ) ) ;
475482}
0 commit comments