Skip to content

Commit e44d1a4

Browse files
Manishearthniondir
authored andcommitted
Split into features
1 parent 10a5cb8 commit e44d1a4

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

freertos-rust/Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ links = "freertos"
1515

1616
[lib]
1717
name = "freertos_rust"
18-
path = "src/lib.rs"
18+
path = "src/lib.rs"
19+
20+
[features]
21+
default = ["allocator", "sync", "time", "hooks", "interrupt"]
22+
allocator = []
23+
sync = ["interrupt"]
24+
time = ["interrupt"]
25+
hooks = []
26+
interrupt = []

freertos-rust/src/lib.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,44 +58,67 @@
5858
#![allow(non_camel_case_types)]
5959
#![allow(non_snake_case)]
6060

61-
#[macro_use]
61+
#[cfg_attr(any(feature = "time", feature = "sync"), macro_use)]
6262
extern crate alloc;
6363

64+
#[cfg(feature = "hooks")]
6465
mod hooks;
6566
mod prelude;
6667
mod shim;
6768

69+
#[cfg(feature = "allocator")]
6870
mod allocator;
6971
mod base;
72+
#[cfg(feature = "sync")]
7073
mod critical;
74+
#[cfg(feature = "time")]
7175
mod delays;
76+
#[cfg(feature = "interrupt")]
7277
mod isr;
78+
#[cfg(feature = "sync")]
7379
mod mutex;
80+
#[cfg(feature = "sync")]
7481
mod queue;
82+
#[cfg(feature = "sync")]
7583
mod semaphore;
84+
#[cfg(any(feature = "time", feature = "sync"))]
7685
mod task;
86+
#[cfg(feature = "time")]
7787
mod timers;
88+
#[cfg(any(feature = "time", feature = "sync"))]
7889
mod units;
7990
mod utils;
8091

92+
#[cfg(feature = "sync")]
8193
pub mod patterns;
8294

8395
// Internal stuff that is only public for first Proof of Concept
8496
pub use crate::base::*;
8597
pub use crate::shim::*;
8698
// ----------
8799

100+
#[cfg(feature = "allocator")]
88101
pub use crate::allocator::*;
89102
pub use crate::base::FreeRtosError;
103+
#[cfg(feature = "sync")]
90104
pub use crate::critical::*;
105+
#[cfg(feature = "time")]
91106
pub use crate::delays::*;
107+
#[cfg(feature = "hooks")]
92108
pub use crate::hooks::*;
109+
#[cfg(feature = "interrupt")]
93110
pub use crate::isr::*;
111+
#[cfg(feature = "sync")]
94112
pub use crate::mutex::*;
113+
#[cfg(feature = "sync")]
95114
pub use crate::queue::*;
115+
#[cfg(feature = "sync")]
96116
pub use crate::semaphore::*;
117+
#[cfg(any(feature = "time", feature = "sync"))]
97118
pub use crate::task::*;
119+
#[cfg(feature = "time")]
98120
pub use crate::timers::*;
121+
#[cfg(any(feature = "time", feature = "sync"))]
99122
pub use crate::units::*;
100123

101124
pub use crate::utils::shim_sanity_check;

freertos-rust/src/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub fn shim_sanity_check() -> Result<(), TypeSizeError> {
4545
Ok(())
4646
}
4747

48+
#[cfg(any(feature = "time", feature = "hooks", feature = "sync"))]
4849
pub unsafe fn str_from_c_string(str: *const u8) -> Result<String, FreeRtosError> {
4950
let mut buf = Vec::new();
5051

0 commit comments

Comments
 (0)