Skip to content

Commit

Permalink
Better attempt to fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Jan 9, 2025
1 parent c6dba7b commit 0729291
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::env;
use std::path::PathBuf;
use std::{env, fs};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut builder = cc::Build::new();
Expand Down Expand Up @@ -31,12 +31,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());

println!("cargo:rerun-if-changed=littlefs/lfs.h");
let lfs_h = fs::read_to_string("littlefs/lfs.h").unwrap();
// Avoid having to bring in newlib for the types that are only ever used in lfs_utils.h
let corrected_lfs_h = lfs_h.replace(
r#"#include "lfs_util.h""#,
r#"#include <stdint.h>
#include <stdbool.h>"#,
);
let out_path_corrected_lfs_h = out_path.join("corrected_lfs.h");
fs::write(&out_path_corrected_lfs_h, corrected_lfs_h).unwrap();

let bindgen = bindgen::Builder::default()
.header("littlefs/lfs.h")
.header(
out_path_corrected_lfs_h
.to_str()
.expect("Path must be utf-8"),
)
.clang_arg("-std=c99")
.clang_arg("-DLFS_NO_DEBUG")
.clang_arg("-DLFS_NO_WARN")
.clang_arg("-DLFS_NO_ERROR");
.clang_arg("-DLFS_NO_WARN");
#[cfg(feature = "multiversion")]
let bindgen = bindgen.clang_arg("-DLFS_MULTIVERSION");

Expand Down

0 comments on commit 0729291

Please sign in to comment.