Skip to content

Commit

Permalink
Handle newer versions of Rhai in build.
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Oct 25, 2023
1 parent 5193cb6 commit dab3be4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rhai-sci"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
authors = ["Chris McComb <[email protected]>"]
description = "Scientific computing in the Rhai scripting language"
Expand All @@ -22,23 +22,23 @@ rand = ["randlib"]

[dependencies]
rhai = ">=1.8.0"
nalgebralib = {version = "0.32.1", optional = true, package = "nalgebra" }
polars = {version = "0.27.2", optional = true }
url = {version = "2.2.2", optional = true }
temp-file = {version = "0.1.6", optional = true }
csv-sniffer = {version = "0.3.1", optional = true }
nalgebralib = { version = "0.32.1", optional = true, package = "nalgebra" }
polars = { version = "0.27.2", optional = true }
url = { version = "2.2.2", optional = true }
temp-file = { version = "0.1.6", optional = true }
csv-sniffer = { version = "0.3.1", optional = true }
minreq = { version = "2.6.0", features = ["json-using-serde", "https"], optional = true }
randlib = { version = "0.8", optional = true, package = "rand" }
smartstring = "1.0.1"
linregress = { version = "0.5.0", optional = true }

[build-dependencies]
rhai = ">=1.8.0"
nalgebralib = {version = "0.32.1", optional = true, package = "nalgebra" }
polars = {version = "0.27.2", optional = true }
url = {version = "2.2.2", optional = true }
temp-file = {version = "0.1.6", optional = true }
csv-sniffer = {version = "0.3.1", optional = true }
nalgebralib = { version = "0.32.1", optional = true, package = "nalgebra" }
polars = { version = "0.27.2", optional = true }
url = { version = "2.2.2", optional = true }
temp-file = { version = "0.1.6", optional = true }
csv-sniffer = { version = "0.3.1", optional = true }
minreq = { version = "2.6.0", features = ["json-using-serde", "https"], optional = true }
randlib = { version = "0.8", optional = true, package = "rand" }
serde_json = "1.0.82"
Expand Down
14 changes: 10 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ fn main() {
use std::collections::HashMap;
use std::io::Write;

#[derive(Serialize, Deserialize, Debug, Clone)]
struct Metadata {
#[serde(default)]
pub functions: Vec<Function>,
}
#[allow(non_snake_case)]
#[derive(Serialize, Deserialize, Debug, Clone)]
struct Function {
Expand All @@ -40,7 +45,8 @@ fn main() {
std::fs::File::create(std::env::var("OUT_DIR").unwrap() + "/rhai-sci-docs.md").unwrap();

// Make a file for tests
let mut test_file = std::fs::File::create(std::env::var("OUT_DIR").unwrap() + "/rhai-sci-tests.rs").unwrap();
let mut test_file =
std::fs::File::create(std::env::var("OUT_DIR").unwrap() + "/rhai-sci-tests.rs").unwrap();

// Build an engine for doctests
let mut engine = Engine::new();
Expand All @@ -62,12 +68,12 @@ fn main() {
// Extract metadata
let json_fns = engine.gen_fn_metadata_to_json(false).unwrap();
println!("{json_fns}");
let v: HashMap<String, Vec<Function>> = serde_json::from_str(&json_fns).unwrap();
for function in v["functions"].clone() {
let v: Metadata = serde_json::from_str(&json_fns).unwrap();
for function in v.functions {
println!("{:?}", function);
}

let function_list = v["functions"].clone();
let function_list = v.functions;

// Write functions
write!(doc_file, "\n# API\n This package provides a large variety of functions to help with scientific computing:\n").expect("Cannot write to {doc_file}");
Expand Down

0 comments on commit dab3be4

Please sign in to comment.