Finalize no_std support.

This commit is contained in:
Stephen Chung 2020-03-18 10:50:51 +08:00
parent ca20faf170
commit ecded729ad
3 changed files with 27 additions and 20 deletions

View File

@ -18,6 +18,27 @@ keywords = [ "scripting" ]
[dependencies]
num-traits = "0.2.11"
[features]
#default = ["no_function", "no_index", "no_float", "only_i32", "no_stdlib", "unchecked", "no_optimize"]
default = [ "optimize_full" ]
debug_msgs = [] # print debug messages on function registrations and calls
unchecked = [] # unchecked arithmetic
no_index = [] # no arrays and indexing
no_float = [] # no floating-point
no_function = [] # no script-defined functions
no_optimize = [] # no script optimizer
optimize_full = [] # set optimization level to Full (default is Simple)
only_i32 = [] # set INT=i32 (useful for 32-bit systems)
only_i64 = [] # set INT=i64 (default) and disable support for all other integer types
# no standard library of utility functions
no_stdlib = [ "num-traits/libm", "hashbrown", "core-error", "libm" ]
[profile.release]
lto = "fat"
codegen-units = 1
#opt-level = "z" # optimize for size
[dependencies.libm]
version = "0.2.1"
optional = true
@ -37,22 +58,3 @@ optional = true
version = "0.3.2"
default-features = false
optional = true
[features]
#default = ["no_function", "no_index", "no_float", "only_i32", "no_stdlib", "unchecked", "no_optimize"]
default = [ "optimize_full" ]
debug_msgs = [] # print debug messages on function registrations and calls
unchecked = [] # unchecked arithmetic
no_stdlib = ["num-traits/libm", "hashbrown", "core-error", "libm"] # no standard library of utility functions
no_index = [] # no arrays and indexing
no_float = [] # no floating-point
no_function = [] # no script-defined functions
no_optimize = [] # no script optimizer
optimize_full = [] # set optimization level to Full (default is Simple)
only_i32 = [] # set INT=i32 (useful for 32-bit systems)
only_i64 = [] # set INT=i64 (default) and disable support for all other integer types
[profile.release]
lto = "fat"
codegen-units = 1
#opt-level = "z" # optimize for size

View File

@ -3,8 +3,9 @@ Rhai - Embedded Scripting for Rust
Rhai is an embedded scripting language and evaluation engine for Rust that gives a safe and easy way to add scripting to any application.
Rhai's current feature set:
Rhai's current features set:
* `no-std` support
* Easy integration with Rust functions and data types, supporting getter/setter methods
* Easily call a script-defined function from Rust
* Fairly efficient (1 million iterations in 0.75 sec on my 5 year old laptop)
@ -52,6 +53,7 @@ Optional features
| `no_optimize` | Disable the script optimizer. |
| `only_i32` | Set the system integer type to `i32` and disable all other integer types. `INT` is set to `i32`. |
| `only_i64` | Set the system integer type to `i64` and disable all other integer types. `INT` is set to `i64`. |
| `no_std` | Build for `no-std`. Notice that additional dependencies will be pulled in to replace `std` features. |
By default, Rhai includes all the standard functionalities in a small, tight package. Most features are here to opt-**out** of certain functionalities that are not needed.
Excluding unneeded functionalities can result in smaller, faster builds as well as less bugs due to a more restricted language.
@ -1477,6 +1479,7 @@ engine.set_optimization_level(rhai::OptimizationLevel::None);
[`no_optimize`]: #optional-features
[`only_i32`]: #optional-features
[`only_i64`]: #optional-features
[`no_std`]: #optional-features
[`Engine`]: #hello-world
[`Scope`]: #initializing-and-maintaining-state

View File

@ -1,3 +1,5 @@
//! Helper module which defines most of the needed features from `std` for `no-std` builds.
#[cfg(feature = "no_stdlib")]
mod inner {
pub use core::{