Skip to content

Commit bb4e3fa

Browse files
committed
zephyr: provide a CONFIG_USERSPACE constant
1 parent e8a1d6d commit bb4e3fa

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

rust-app/zephyr/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ compiler_builtins = { version = '0.1.2', optional = true }
1414
derive_more = { version = '0.14.1', default-features = false, features = ['no_std'] }
1515

1616
[features]
17-
defaults = [ 'usermode', 'rustc-dep-of-std' ]
18-
usermode = []
17+
defaults = [ 'rustc-dep-of-std' ]
1918
rustc-dep-of-std = ['core', 'compiler_builtins', 'zephyr-sys/rustc-dep-of-std']
2019
have_std = []

rust-app/zephyr/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
if std::env::var("CONFIG_USERSPACE").expect("CONFIG_USERSPACE must be set") == "y" {
3+
println!("cargo:rustc-cfg=usermode");
4+
}
5+
}

rust-app/zephyr/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pub mod uart;
1414

1515
pub use time::*;
1616

17+
// Set from environment from build.rs
18+
pub const CONFIG_USERSPACE: bool = cfg!(usermode);
19+
1720
/// Convert a negative error code to a Result
1821
trait NegErr {
1922
fn neg_err(&self) -> Result<u32, u32>;

0 commit comments

Comments
 (0)