Skip to content

Commit

Permalink
Add no_std support with a "std" feature.
Browse files Browse the repository at this point in the history
The "std" feature is enabled by default; disabling it enables no_std
mode.
  • Loading branch information
sunfishcode committed Nov 20, 2023
1 parent 428123d commit 7cd5f80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = ["/.github", "ci"]
keywords = ["linux"]

[dependencies]
c-gull = { version = "0.15.22", default-features = false, features = ["eyra"] }
c-gull = { version = "0.15.25", default-features = false, features = ["eyra"] }

[dev-dependencies]
assert_cmd = "2.0.12"
Expand All @@ -35,6 +35,9 @@ core_simd = { git = "https://github.com/rust-lang/portable-simd" }
[features]
default = ["be-std", "threadsafe-setenv", "use-compiler-builtins"]

# Enable features that depend on std. Disable this for `no_std`.
std = ["c-gull/std"]

# This makes `setenv` and friends thread-safe by leaking memory.
threadsafe-setenv = ["c-gull/threadsafe-setenv"]

Expand All @@ -45,7 +48,7 @@ log = ["c-gull/log"]
atomic-dbg-logger = ["c-gull/atomic-dbg-logger"]

# Install the `env_logger` crate as a logger.
env_logger = ["c-gull/env_logger"]
env_logger = ["c-gull/env_logger", "std"]

# Disable logging.
max_level_off = ["c-gull/max_level_off"]
Expand All @@ -55,7 +58,7 @@ max_level_off = ["c-gull/max_level_off"]
experimental-relocate = ["c-gull/experimental-relocate"]

# Have eyra do `use std::*;` so that it can be used as `std`.
be-std = []
be-std = ["std"]

# Should c-scape's `memcpy` etc. use compiler-builtins?
use-compiler-builtins = ["c-gull/use-compiler-builtins"]
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#![doc = include_str!("../README.md")]
#![no_std]
#![cfg_attr(not(feature = "std"), no_std)]

// If enabled, re-export `std` so that we can be used as `std` to avoid the
// `extern crate eyra;`.
#[cfg(feature = "be-std")]
extern crate std;
#[cfg(feature = "be-std")]
#[doc(hidden)]
pub use std::*;

Expand Down

0 comments on commit 7cd5f80

Please sign in to comment.