Add an explicit std feature so that features are purely additive.
This commit is contained in:
@@ -17,14 +17,19 @@ name = "cretonne"
|
||||
# Please don't add any unless they are essential to the task of creating binary
|
||||
# machine code. Integration tests that need external dependencies can be
|
||||
# accomodated in `tests`.
|
||||
|
||||
[dependencies.hashmap_core]
|
||||
version = "0.1.1"
|
||||
optional = true
|
||||
|
||||
[dependencies.error_core]
|
||||
version = "0.1.0"
|
||||
optional = true
|
||||
|
||||
[features]
|
||||
# Currently, the only feature is the `no_std` feature.
|
||||
# Enabling this disables use of `stdlib`.
|
||||
no_std = ["hashmap_core", "error_core"]
|
||||
# The "std" feature enables use of libstd. The "no_std" feature enables use
|
||||
# of some minimal std-like replacement libraries. At least one of these two
|
||||
# features to be enabled.
|
||||
default = ["std"]
|
||||
std = []
|
||||
no_std = ["hashmap_core", "error_core"]
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
//! Cretonne code generation library.
|
||||
#![cfg_attr(feature = "no_std", no_std)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
// Turns on alloc feature if no_std
|
||||
#![cfg_attr(feature = "no_std", feature(alloc))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||
|
||||
// Include the `hashmap_core` crate if no_std
|
||||
#[cfg(feature = "no_std")]
|
||||
extern crate hashmap_core;
|
||||
#[cfg(feature = "no_std")]
|
||||
extern crate error_core;
|
||||
#[cfg(feature = "no_std")]
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
|
||||
@@ -60,7 +60,7 @@ mod unreachable_code;
|
||||
mod write;
|
||||
|
||||
/// This replaces `std` in builds with no_std.
|
||||
#[cfg(feature = "no_std")]
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod std {
|
||||
pub use core::*;
|
||||
pub use alloc::{boxed, vec, string};
|
||||
|
||||
Reference in New Issue
Block a user