diff --git a/CHANGELOG.md b/CHANGELOG.md index 51ec97c..9177e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Add `malloc` feature flag. It allows `littlefs` to link to `malloc` and `free` instead of relying on the caller to allocate memory ([#9]) + ## [0.1.7] - 2022-01-26 ### Fixed @@ -13,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed compilation issue caused by other crates also using `bindgen` by selecting the `runtime` feature ([#5]) [#5]: https://github.com/trussed-dev/littlefs2-sys/pull/5 +[#9]: https://github.com/trussed-dev/littlefs2-sys/pull/9 [Unreleased]: https://github.com/trussed-dev/littlefs2-sys/compare/0.1.7...HEAD [0.1.7]: https://github.com/trussed-dev/littlefs2-sys/compare/0.1.6...0.1.7 diff --git a/Cargo.toml b/Cargo.toml index 981a91e..88bb905 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,3 +19,4 @@ cc = "1" [features] assertions = [] trace = [] +malloc = [] \ No newline at end of file diff --git a/build.rs b/build.rs index bf2bc7c..192c6cc 100644 --- a/build.rs +++ b/build.rs @@ -6,7 +6,6 @@ fn main() -> Result<(), Box> { let target = env::var("TARGET")?; let builder = builder .flag("-std=c11") - .flag("-DLFS_NO_MALLOC") .flag("-DLFS_NO_DEBUG") .flag("-DLFS_NO_WARN") .flag("-DLFS_NO_ERROR") @@ -21,6 +20,9 @@ fn main() -> Result<(), Box> { #[cfg(feature = "trace")] let builder = builder.flag("-DLFS_YES_TRACE"); + #[cfg(not(feature = "malloc"))] + builder.flag("-DLFS_NO_MALLOC"); + builder.compile("lfs-sys"); let bindings = bindgen::Builder::default()