File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,11 @@ extern crate syn;
5
5
#[ macro_use]
6
6
extern crate failure;
7
7
8
- use std:: env;
8
+ use std:: { env, fs , io :: ErrorKind , path :: PathBuf } ;
9
9
10
10
fn main ( ) {
11
11
let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
12
+ let mut manifest_dir: PathBuf = env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) . into ( ) ;
12
13
13
14
// Dummy declarations for RLS.
14
15
if std:: env:: var ( "CARGO" ) . unwrap_or_default ( ) . ends_with ( "rls" ) {
@@ -26,6 +27,15 @@ fn main() {
26
27
. expect ( "Unable to parse 'llvm-sys' crate" )
27
28
. write_declarations ( & format ! ( "{}/llvm_gen.rs" , out_dir) )
28
29
. 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
+ }
29
39
}
30
40
31
41
#[ derive( Debug ) ]
You can’t perform that action at this time.
0 commit comments