Skip to content

Commit 1125cfc

Browse files
committed
build.rs: Remove Cargo.lock
This causes cargo package to complain Signed-off-by: Dave Tucker <[email protected]>
1 parent 44d267e commit 1125cfc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

build.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ extern crate syn;
55
#[macro_use]
66
extern crate failure;
77

8-
use std::env;
8+
use std::{env, fs, io::ErrorKind, path::PathBuf};
99

1010
fn main() {
1111
let out_dir = env::var("OUT_DIR").unwrap();
12+
let mut manifest_dir: PathBuf = env::var("CARGO_MANIFEST_DIR").unwrap().into();
1213

1314
// Dummy declarations for RLS.
1415
if std::env::var("CARGO").unwrap_or_default().ends_with("rls") {
@@ -26,6 +27,15 @@ fn main() {
2627
.expect("Unable to parse 'llvm-sys' crate")
2728
.write_declarations(&format!("{}/llvm_gen.rs", out_dir))
2829
.expect("Unable to write generated LLVM declarations");
30+
31+
// Workaround for `cargo package`
32+
// `cargo metadata` creates a new Cargo.lock file, which needs removing
33+
manifest_dir.push("Cargo.lock");
34+
if let Err(e) = fs::remove_file(&manifest_dir) {
35+
if e.kind() != ErrorKind::NotFound {
36+
panic!("unexpected error clearing local Cargo.lock: {}", e);
37+
}
38+
}
2939
}
3040

3141
#[derive(Debug)]

0 commit comments

Comments
 (0)