Use required-features for bin tools.
This commit is contained in:
parent
2cfd426aaf
commit
0378c822e1
70
Cargo.toml
70
Cargo.toml
@ -15,22 +15,21 @@ include = ["**/*.rs", "scripts/*.rhai", "**/*.md", "Cargo.toml"]
|
|||||||
keywords = ["scripting", "scripting-engine", "scripting-language", "embedded"]
|
keywords = ["scripting", "scripting-engine", "scripting-language", "embedded"]
|
||||||
categories = ["no-std", "embedded", "wasm", "parser-implementations"]
|
categories = ["no-std", "embedded", "wasm", "parser-implementations"]
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "rhai"
|
|
||||||
path = "src/lib.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "rhai-repl"
|
|
||||||
path = "src/bin/rhai-repl.rs"
|
|
||||||
required-features = ["rustyline"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
smallvec = { version = "1.7", default-features = false, features = ["union", "const_new" ] }
|
smallvec = { version = "1.7", default-features = false, features = ["union", "const_new" ] }
|
||||||
ahash = { version = "0.7", default-features = false }
|
ahash = { version = "0.7", default-features = false }
|
||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
smartstring = { version = "0.2.8", default-features = false }
|
smartstring = { version = "0.2.8", default-features = false }
|
||||||
rhai_codegen = { version = "1.2", path = "codegen", default-features = false }
|
rhai_codegen = { version = "1.2", path = "codegen", default-features = false }
|
||||||
rustyline = { versoin = "9", optional = true }
|
|
||||||
|
no-std-compat = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
|
||||||
|
libm = { version = "0.2", default-features = false, optional = true }
|
||||||
|
core-error = { version = "0.0", default-features = false, features = ["alloc"], optional = true }
|
||||||
|
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"], optional = true }
|
||||||
|
serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true }
|
||||||
|
unicode-xid = { version = "0.2", default-features = false, optional = true }
|
||||||
|
rust_decimal = { version = "1.16", default-features = false, features = ["maths"], optional = true }
|
||||||
|
rustyline = { version = "9", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_bytes = "0.11"
|
serde_bytes = "0.11"
|
||||||
@ -62,52 +61,23 @@ no_std = ["no-std-compat", "num-traits/libm", "core-error", "libm", "ahash/compi
|
|||||||
wasm-bindgen = ["instant/wasm-bindgen"]
|
wasm-bindgen = ["instant/wasm-bindgen"]
|
||||||
stdweb = ["instant/stdweb"]
|
stdweb = ["instant/stdweb"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "rhai-repl"
|
||||||
|
required-features = ["rustyline"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "rhai-run"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "rhai-dbg"
|
||||||
|
required-features = ["debugging"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
#opt-level = "z" # optimize for size
|
#opt-level = "z" # optimize for size
|
||||||
#panic = 'abort' # remove stack backtrace for no-std
|
#panic = 'abort' # remove stack backtrace for no-std
|
||||||
|
|
||||||
[dependencies.no-std-compat]
|
|
||||||
version = "0.4"
|
|
||||||
default-features = false
|
|
||||||
features = ["alloc"]
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dependencies.libm]
|
|
||||||
version = "0.2"
|
|
||||||
default-features = false
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dependencies.core-error]
|
|
||||||
version = "0.0"
|
|
||||||
default-features = false
|
|
||||||
features = ["alloc"]
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dependencies.serde]
|
|
||||||
version = "1.0"
|
|
||||||
default-features = false
|
|
||||||
features = ["derive", "alloc"]
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dependencies.serde_json]
|
|
||||||
version = "1.0"
|
|
||||||
default-features = false
|
|
||||||
features = ["alloc"]
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dependencies.unicode-xid]
|
|
||||||
version = "0.2"
|
|
||||||
default-features = false
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dependencies.rust_decimal]
|
|
||||||
version = "1.16"
|
|
||||||
default-features = false
|
|
||||||
features = ["maths"]
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||||
instant = { version = "0.1.10" } # WASM implementation of std::time::Instant
|
instant = { version = "0.1.10" } # WASM implementation of std::time::Instant
|
||||||
|
|
||||||
|
@ -3,10 +3,38 @@ Rhai Tools
|
|||||||
|
|
||||||
Tools for running Rhai scripts.
|
Tools for running Rhai scripts.
|
||||||
|
|
||||||
|
| Tool | Required feature(s) | Description |
|
||||||
|
| -------------------------------------------------------------------------------- | :-----------------: | --------------------------------------------------- |
|
||||||
|
| [`rhai-run`](https://github.com/rhaiscript/rhai/blob/main/src/bin/rhai-run.rs) | | runs each filename passed to it as a Rhai script |
|
||||||
|
| [`rhai-repl`](https://github.com/rhaiscript/rhai/blob/main/src/bin/rhai-repl.rs) | `rustyline` | simple REPL that interactively evaluates statements |
|
||||||
|
| [`rhai-dbg`](https://github.com/rhaiscript/rhai/blob/main/src/bin/rhai-dbg.rs) | `debugging` | the _Rhai Debugger_ |
|
||||||
|
|
||||||
|
|
||||||
How to Run
|
How to Run
|
||||||
----------
|
----------
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
cargo run --bin sample_app_to_run
|
cargo run --bin sample_app_to_run
|
||||||
```
|
```
|
||||||
|
|
||||||
|
or with required features
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cargo run --bin sample_app_to_run --features feature1,feature2,feature3
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
How to Install
|
||||||
|
--------------
|
||||||
|
|
||||||
|
To install these all tools (with [`decimal`] and [`metadata`] support), use the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cargo install --path . --bins --features decimal,metadata,debugging,rustyline
|
||||||
|
```
|
||||||
|
|
||||||
|
or specifically:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cargo install --path . --bin rhai-run --features decimal,metadata,debugging,rustyline
|
||||||
|
```
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#![cfg(not(feature = "no_std"))]
|
use rhai::debugger::DebuggerCommand;
|
||||||
|
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
use rhai::{Dynamic, Engine, EvalAltResult, ImmutableString, Position, Scope};
|
use rhai::{Dynamic, Engine, EvalAltResult, ImmutableString, Position, Scope};
|
||||||
|
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
use rhai::debugger::DebuggerCommand;
|
|
||||||
|
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
fs::File,
|
fs::File,
|
||||||
@ -16,7 +10,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Pretty-print source line.
|
/// Pretty-print source line.
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
fn print_source(lines: &[String], pos: Position, offset: usize) {
|
fn print_source(lines: &[String], pos: Position, offset: usize) {
|
||||||
let line_no = if lines.len() > 1 {
|
let line_no = if lines.len() > 1 {
|
||||||
if pos.is_none() {
|
if pos.is_none() {
|
||||||
@ -44,7 +37,6 @@ fn print_source(lines: &[String], pos: Position, offset: usize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pretty-print error.
|
/// Pretty-print error.
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
fn print_error(input: &str, mut err: EvalAltResult) {
|
fn print_error(input: &str, mut err: EvalAltResult) {
|
||||||
let lines: Vec<_> = input.trim().split('\n').collect();
|
let lines: Vec<_> = input.trim().split('\n').collect();
|
||||||
let pos = err.take_position();
|
let pos = err.take_position();
|
||||||
@ -78,7 +70,6 @@ fn print_error(input: &str, mut err: EvalAltResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Print debug help.
|
/// Print debug help.
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
fn print_debug_help() {
|
fn print_debug_help() {
|
||||||
println!("help => print this help");
|
println!("help => print this help");
|
||||||
println!("quit, exit, kill => quit");
|
println!("quit, exit, kill => quit");
|
||||||
@ -114,7 +105,6 @@ fn print_debug_help() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Display the scope.
|
/// Display the scope.
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
fn print_scope(scope: &Scope, dedup: bool) {
|
fn print_scope(scope: &Scope, dedup: bool) {
|
||||||
let flattened_clone;
|
let flattened_clone;
|
||||||
let scope = if dedup {
|
let scope = if dedup {
|
||||||
@ -153,7 +143,6 @@ fn print_scope(scope: &Scope, dedup: bool) {
|
|||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let title = format!("Rhai Debugger (version {})", env!("CARGO_PKG_VERSION"));
|
let title = format!("Rhai Debugger (version {})", env!("CARGO_PKG_VERSION"));
|
||||||
println!("{}", title);
|
println!("{}", title);
|
||||||
@ -552,8 +541,3 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "debugging"))]
|
|
||||||
fn main() {
|
|
||||||
panic!("rhai-dbg requires the 'debugging' feature.")
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user