File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
- use std:: env;
2
1
use std:: path:: PathBuf ;
2
+ use std:: { env, fs} ;
3
3
4
4
fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
5
5
let mut builder = cc:: Build :: new ( ) ;
@@ -31,12 +31,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
31
31
32
32
let out_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
33
33
34
+ println ! ( "cargo:rerun-if-changed=littlefs/lfs.h" ) ;
35
+ let lfs_h = fs:: read_to_string ( "littlefs/lfs.h" ) . unwrap ( ) ;
36
+ // Avoid having to bring in newlib for the types that are only ever used in lfs_utils.h
37
+ let corrected_lfs_h = lfs_h. replace (
38
+ r#"#include "lfs_util.h""# ,
39
+ r#"#include <stdint.h>
40
+ #include <stdbool.h>"# ,
41
+ ) ;
42
+ let out_path_corrected_lfs_h = out_path. join ( "corrected_lfs.h" ) ;
43
+ fs:: write ( & out_path_corrected_lfs_h, corrected_lfs_h) . unwrap ( ) ;
44
+
34
45
let bindgen = bindgen:: Builder :: default ( )
35
- . header ( "littlefs/lfs.h" )
46
+ . header (
47
+ out_path_corrected_lfs_h
48
+ . to_str ( )
49
+ . expect ( "Path must be utf-8" ) ,
50
+ )
36
51
. clang_arg ( "-std=c99" )
37
52
. clang_arg ( "-DLFS_NO_DEBUG" )
38
- . clang_arg ( "-DLFS_NO_WARN" )
39
- . clang_arg ( "-DLFS_NO_ERROR" ) ;
53
+ . clang_arg ( "-DLFS_NO_WARN" ) ;
40
54
#[ cfg( feature = "multiversion" ) ]
41
55
let bindgen = bindgen. clang_arg ( "-DLFS_MULTIVERSION" ) ;
42
56
You can’t perform that action at this time.
0 commit comments