1- // Copyright 2020 the Tectonic Project
1+ // Copyright 2020-2021 the Tectonic Project
22// Licensed under the MIT License.
33
4- use std:: { env, fs , io :: ErrorKind , path:: PathBuf } ;
4+ use std:: { env, path:: PathBuf } ;
55
66fn main ( ) {
77 let outdir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
@@ -23,6 +23,15 @@ fn main() {
2323
2424 let mut manifest_dir: PathBuf = env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) . into ( ) ;
2525
26+ // Experimental (2021 June): currently the build of `tectonic` on docs.rs
27+ // fails because cbindgen calls `cargo metadata`, which has to hit the
28+ // network because the standalone crate has not Cargo.lock file -- and
29+ // docs.rs disable network access. We can't control the Cargo command line,
30+ // but hopefully this environment variable will tell Cargo not to try? I
31+ // don't know if Cargo will succeed this way, but I think the only way to
32+ // test is to make a release and see.
33+ std:: env:: set_var ( "CARGO_NET_OFFLINE" , "1" ) ;
34+
2635 cbindgen:: Builder :: new ( )
2736 . with_config ( config)
2837 . with_crate ( & manifest_dir)
@@ -39,9 +48,5 @@ fn main() {
3948 // they occur in a workspace context. Lame but effective solution:
4049 // unconditionally blow away the file.
4150 manifest_dir. push ( "Cargo.lock" ) ;
42- if let Err ( e) = fs:: remove_file ( & manifest_dir) {
43- if e. kind ( ) != ErrorKind :: NotFound {
44- panic ! ( "unexpected error clearing local Cargo.lock: {}" , e) ;
45- }
46- }
51+ let _ignored = std:: fs:: remove_file ( & manifest_dir) ;
4752}
0 commit comments