@@ -19,6 +19,7 @@ use std::{
19
19
collections:: { BTreeMap , BTreeSet , HashSet } ,
20
20
fs:: File ,
21
21
io:: { Read , Write } ,
22
+ path:: { Path , PathBuf } ,
22
23
} ;
23
24
24
25
const PLAYGROUND_TARGET_PLATFORM : & str = "x86_64-unknown-linux-gnu" ;
@@ -267,7 +268,7 @@ fn playground_metadata_features(pkg: &Package) -> Option<(Vec<String>, bool)> {
267
268
}
268
269
}
269
270
270
- fn write_manifest ( manifest : TomlManifest , path : & str ) {
271
+ fn write_manifest ( manifest : TomlManifest , path : impl AsRef < Path > ) {
271
272
let mut f = File :: create ( path) . expect ( "Unable to create Cargo.toml" ) ;
272
273
let content = toml:: to_vec ( & manifest) . expect ( "Couldn't serialize TOML" ) ;
273
274
f. write_all ( & content) . expect ( "Couldn't write Cargo.toml" ) ;
@@ -463,13 +464,19 @@ fn main() {
463
464
} ;
464
465
465
466
// 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) ) ;
472
479
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 ( ) ) ;
475
482
}
0 commit comments