diff --git a/.travis.yml b/.travis.yml index ed343ec337..6b4b0c11ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,46 +34,40 @@ addons: packages: - zmq -# Docs are only built and deployed in "cron" builds - so only prepare that when needed +# Doc building tools are needed on linux with stable rust before_install: - make no-book-config - | - if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == "stable" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then + if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == "stable" ]]; then make book-config fi -# Docs are only built and deployed in "cron" builds on linux with rust stable +# Docs are only built on linux with stable rust script: - | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - if [[ "$TRAVIS_EVENT_TYPE" == "cron" ]]; then - # Build the docs nightly - travis_wait 50 make docs - else - travis_wait 50 make clippy build test - fi + if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == "stable" ]]; then + travis_wait 50 make clippy build test docs else - if [[ "$TRAVIS_EVENT_TYPE" != "cron" ]]; then - travis_wait 50 make clippy test - fi + travis_wait 50 make clippy test fi -# Docs are only built and deployed in "cron" builds on linux with rust stable +# Docs are only on linux builds of master branch with stable rust deploy: provider: pages skip_cleanup: true github-token: $GITHUB_PAGES_TOKEN local-dir: target/html keep_history: true - allow_empty_commit: true # Avoid deploy fail on empty commit if nothing has changed in CRON deploy + allow_empty_commit: true # Avoid deploy fail on empty commit if nothing has changed (CRON builds) on: branch: master - condition: $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_EVENT_TYPE == "cron" + condition: $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "stable" notifications: email: - andrew@mackenzie-serres.net +# avoid measuring coverage on CRON builds, only measure on non-CRON linux builds with stable rust after_success: | if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == "stable" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then FLOW_LIB_PATH=$TRAVIS_BUILD_DIR,$TRAVIS_BUILD_DIR/flowr/src/lib make coverage diff --git a/Makefile b/Makefile index d3b8808142..9e5f93e857 100644 --- a/Makefile +++ b/Makefile @@ -285,7 +285,10 @@ copy: clean: @find . -name \*.dot.svg -type f -exec rm -rf {} + ; true @find . -name \*.dot -type f -exec rm -rf {} + ; true + @find . -name manifest.json -type f -exec rm -rf {} + ; true + @find . -name test.output -type f -exec rm -rf {} + ; true + @find . -name test.err -type f -exec rm -rf {} + ; true + @find . -name \*.wasm -type f -exec rm -rf {} + ; true @rm -rf target/html @find . -name \*.dump -type f -exec rm -rf {} + ; true - @find . -name \*.dot -type f -exec rm -rf {} + ; true @cargo clean \ No newline at end of file diff --git a/flowc/src/lib/compiler/compile_wasm.rs b/flowc/src/lib/compiler/compile_wasm.rs index c3e5af6049..6e5824fc08 100644 --- a/flowc/src/lib/compiler/compile_wasm.rs +++ b/flowc/src/lib/compiler/compile_wasm.rs @@ -155,6 +155,7 @@ fn run_cargo_build(manifest_path: &Path, target_dir: &Path) -> Result { let mut command_args = vec![ "build", "--quiet", + // "--verbose", "--lib", "--target=wasm32-unknown-unknown", ]; @@ -169,7 +170,7 @@ fn run_cargo_build(manifest_path: &Path, target_dir: &Path) -> Result { ); let output = Command::new(&command) - .args(command_args) + .args(&command_args) .stdin(Stdio::inherit()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) @@ -179,11 +180,20 @@ fn run_cargo_build(manifest_path: &Path, target_dir: &Path) -> Result { match output.status.code() { Some(0) => Ok("Cargo Build of supplied function to wasm succeeded".to_string()), Some(code) => { + error!( + "Process STDOUT:\n{}", + String::from_utf8_lossy(&output.stdout) + ); error!( "Process STDERR:\n{}", String::from_utf8_lossy(&output.stderr) ); - bail!("Exited with status code: {}", code) + bail!( + "cargo exited with status code: {}\nCommand Line: {} {:?}", + code, + command, + command_args + ) } None => Ok("No return code - ignoring".to_string()), } diff --git a/flowc/src/lib/dumper/dump_dot.rs b/flowc/src/lib/dumper/dump_dot.rs index 974df440de..c8f9e1df9d 100644 --- a/flowc/src/lib/dumper/dump_dot.rs +++ b/flowc/src/lib/dumper/dump_dot.rs @@ -4,12 +4,9 @@ use std::io::prelude::*; use std::path::Path; use serde_json::Value; -use url::Url; use flowcore::input::InputInitializer::{Always, Once}; -use provider::lib_provider::LibProvider; -use crate::deserializers::deserializer_helper::get_file_extension; use crate::errors::*; use crate::generator::generate::GenerationTables; use crate::model::connection::Connection; @@ -37,11 +34,19 @@ fn absolute_to_relative(absolute: &str, current_dir: &Path) -> Result { Ok(absolute.replace(&format!("file://{}/", root_path.display()), &path_to_root)) } +fn remove_file_extension(file_path: &str) -> String { + let splits: Vec<&str> = file_path.split('.').collect(); + if splits.len() > 1 { + splits[0..splits.len() - 1].join(".") + } else { + file_path.to_owned() + } +} + pub fn write_flow_to_dot( flow: &Flow, dot_file: &mut dyn Write, output_dir: &Path, - provider: &dyn LibProvider, ) -> std::io::Result<()> { dot_file.write_all(digraph_wrapper_start(flow).as_bytes())?; @@ -64,29 +69,9 @@ pub fn write_flow_to_dot( })?; match process { FlowProcess(ref flow) => { - let (flow_source, _) = provider - .resolve_url( - &Url::parse(&process_ref.source).map_err(|_| { - std::io::Error::new( - std::io::ErrorKind::Other, - "Could not parse Url from flow_source", - ) - })?, - "", - &[""], - ) - .map_err(|_| { - std::io::Error::new( - std::io::ErrorKind::Other, - "Could not resolve Url of flow_source", - ) - })?; + // TODO convert lib reference to a file path or url reference to the actual resource - // remove file extension when forming URL as is of form {file_stem}.dot.svg - let mut flow_source_str = flow_source.to_string(); - if let Some(extension) = get_file_extension(&flow_source) { - flow_source_str.truncate(flow_source_str.len() - (extension.len() + 1)) - } + let flow_source_str = remove_file_extension(&process_ref.source); let relative_path = absolute_to_relative(&flow_source_str, output_dir).map_err(|_| { @@ -444,3 +429,31 @@ pub fn process_refs_to_dot( Ok(output) } + +#[cfg(test)] +mod test { + use super::remove_file_extension; + + #[test] + fn strip_extension() { + assert_eq!("file", remove_file_extension("file.toml")); + } + + #[test] + fn strip_last_extension_only() { + assert_eq!("file.my.file", remove_file_extension("file.my.file.toml")); + } + + #[test] + fn strip_extension_in_path() { + assert_eq!( + "/root/home/file", + remove_file_extension("/root/home/file.toml") + ); + } + + #[test] + fn strip_no_extension() { + assert_eq!("file", remove_file_extension("file")); + } +} diff --git a/flowc/src/lib/dumper/dump_flow.rs b/flowc/src/lib/dumper/dump_flow.rs index 098376dd57..832af463c6 100644 --- a/flowc/src/lib/dumper/dump_flow.rs +++ b/flowc/src/lib/dumper/dump_flow.rs @@ -93,7 +93,7 @@ fn _dump_flow( writer = dump_tables::create_output_file(&output_dir, filename, "dot")?; info!("\tGenerating {}.dot, Use \"dotty\" to view it", filename); - dump_dot::write_flow_to_dot(flow, &mut writer, output_dir, provider)?; + dump_dot::write_flow_to_dot(flow, &mut writer, output_dir)?; // Dump sub-flows for subprocess in &flow.subprocesses { diff --git a/flowcore/Cargo.toml b/flowcore/Cargo.toml index ecccf170f2..19caf8288b 100644 --- a/flowcore/Cargo.toml +++ b/flowcore/Cargo.toml @@ -17,16 +17,21 @@ exclude = [".gitignore", "Cargo.lock"] name = "flowcore" path = "src/lib.rs" -[features] -default = [] # Don't include any features by default -debugger = [] # feature to add the debugger - [dependencies] -provider = {path = "../provider", version = "0.34.4" } +serde_json = "1.0" # Needed for Implementation trait and must compile for wasm32-unknown-unknown -url = { version = "2.2", features = ["serde"] } -serde = "~1.0.27" -serde_derive = "~1.0.27" -serde_json = "1.0" -error-chain = "0.12.2" -log = "0.4.6" +# All other dependencies below are optional and can be turned off using "default-features false" removing any +# dependency that won't compile for wasm32 +serde = { version = "~1.0.27", optional = true } +serde_derive = { version = "~1.0.27", optional = true } +provider = {path = "../provider", version = "0.34.4", optional = true} +url = { version = "2.2", features = ["serde"], optional = true } +error-chain = {version = "0.12.2", optional = true} +log = {version = "0.4.6", optional = true} + +[features] +default = ["code"] # by default include code not just the trait definition +debugger = ["code"] # feature to add the debugger, depends on code feature +# Enable the "code" feature to compile the crate with dependencies for code not just trait +# It brings in the following optional dependencies, some of which do not compile for wasm32 +code = ["serde", "serde_derive", "provider", "url", "error-chain", "log"] diff --git a/flowcore/src/lib.rs b/flowcore/src/lib.rs index 3f0fb02c71..4d559ab680 100644 --- a/flowcore/src/lib.rs +++ b/flowcore/src/lib.rs @@ -1,29 +1,38 @@ #![warn(clippy::unwrap_used)] -//! `flowcore` create defined some core structs and traits used by other flow libraries +//! `flowcore` defines some core structs and traits used by other flow libraries and implementations +#[cfg(feature = "code")] #[macro_use] +#[cfg(feature = "code")] extern crate error_chain; use std::panic::{RefUnwindSafe, UnwindSafe}; use serde_json::Value; +#[cfg(feature = "code")] /// `function` defines functions that form part of a flow pub mod function; +#[cfg(feature = "code")] /// `input` defines the struct for inputs to functions in a flow pub mod input; +#[cfg(feature = "code")] /// `lib_manifest` defines the structs for specifying a Library's manifest and methods to load it pub mod lib_manifest; +#[cfg(feature = "code")] /// `manifest` is the struct that specifies the manifest of functions in a flow pub mod manifest; +#[cfg(feature = "code")] /// `output_connection` defines a struct for a function's output connection pub mod output_connection; +#[cfg(feature = "code")] /// Utility functions related to Urls pub mod url_helper; /// We'll put our errors in an `errors` module, and other modules in this crate will `use errors::*;` /// to get access to everything `error_chain!` creates. +#[cfg(feature = "code")] #[doc(hidden)] pub mod errors { // Create the Error, ErrorKind, ResultExt, and Result types @@ -39,6 +48,7 @@ pub const RUN_AGAIN: RunAgain = true; pub const DONT_RUN_AGAIN: RunAgain = false; #[doc(hidden)] +#[cfg(feature = "code")] error_chain! { types { Error, ErrorKind, ResultExt, Result; diff --git a/flowr/src/lib/coordinator.rs b/flowr/src/lib/coordinator.rs index c2c76d1073..15693a689e 100644 --- a/flowr/src/lib/coordinator.rs +++ b/flowr/src/lib/coordinator.rs @@ -444,7 +444,7 @@ impl Coordinator { server_context: Arc>, native: bool, ) -> Result { - let native_url = + let flowruntimelib_url = Url::parse("lib://flowruntime").chain_err(|| "Could not parse lib_manifest_url")?; // Load this run-time's library of native (statically linked) implementations @@ -452,17 +452,19 @@ impl Coordinator { .add_lib( provider, flowruntime::get_manifest(server_context)?, - &native_url, + &flowruntimelib_url, ) .chain_err(|| "Could not add 'flowruntime' library to loader")?; // If the "native" feature is enabled then load the native flowstdlib if command line arg to do so if cfg!(feature = "native") && native { + let flowstdlib_url = + Url::parse("lib://flowstdlib").chain_err(|| "Could not parse flowstdlib_url")?; loader .add_lib( provider, flowstdlib::get_manifest().chain_err(|| "Could not get flowstdlib manifest")?, - &native_url, + &flowstdlib_url, ) .chain_err(|| "Could not add 'flowstdlib' library to loader")?; } diff --git a/flowstdlib/control/compare_switch/flow.toml b/flowstdlib/control/compare_switch/flow.toml index 301581678d..ea5a54207a 100644 --- a/flowstdlib/control/compare_switch/flow.toml +++ b/flowstdlib/control/compare_switch/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" diff --git a/flowstdlib/control/index/flow.toml b/flowstdlib/control/index/flow.toml index f8072a5ec8..14ea0b31be 100644 --- a/flowstdlib/control/index/flow.toml +++ b/flowstdlib/control/index/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/control/join/flow.toml b/flowstdlib/control/join/flow.toml index 90ba0f7f6b..e52d0ab6c3 100644 --- a/flowstdlib/control/join/flow.toml +++ b/flowstdlib/control/join/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" diff --git a/flowstdlib/control/route/flow.toml b/flowstdlib/control/route/flow.toml index 918192bf8c..0c1565e237 100644 --- a/flowstdlib/control/route/flow.toml +++ b/flowstdlib/control/route/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/control/select/flow.toml b/flowstdlib/control/select/flow.toml index 5db2f9e217..3048de95b9 100644 --- a/flowstdlib/control/select/flow.toml +++ b/flowstdlib/control/select/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/control/tap/flow.toml b/flowstdlib/control/tap/flow.toml index f8434ceb00..711bcd0876 100644 --- a/flowstdlib/control/tap/flow.toml +++ b/flowstdlib/control/tap/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/accumulate/flow.toml b/flowstdlib/data/accumulate/flow.toml index 2857e46efc..9ebadce08f 100644 --- a/flowstdlib/data/accumulate/flow.toml +++ b/flowstdlib/data/accumulate/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/append/flow.toml b/flowstdlib/data/append/flow.toml index cb91597591..0956543034 100644 --- a/flowstdlib/data/append/flow.toml +++ b/flowstdlib/data/append/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/buffer/flow.toml b/flowstdlib/data/buffer/flow.toml index 09b68acc96..a71312b1de 100644 --- a/flowstdlib/data/buffer/flow.toml +++ b/flowstdlib/data/buffer/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/count/flow.toml b/flowstdlib/data/count/flow.toml index 8f3dc866c1..f19fb4319e 100644 --- a/flowstdlib/data/count/flow.toml +++ b/flowstdlib/data/count/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/duplicate/flow.toml b/flowstdlib/data/duplicate/flow.toml index a151bf71e7..4db3adbda4 100644 --- a/flowstdlib/data/duplicate/flow.toml +++ b/flowstdlib/data/duplicate/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/duplicate_rows/flow.toml b/flowstdlib/data/duplicate_rows/flow.toml index 1f105f478b..f52b6278d2 100644 --- a/flowstdlib/data/duplicate_rows/flow.toml +++ b/flowstdlib/data/duplicate_rows/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/enumerate/flow.toml b/flowstdlib/data/enumerate/flow.toml index 149fc7eedf..5f9dcf94f8 100644 --- a/flowstdlib/data/enumerate/flow.toml +++ b/flowstdlib/data/enumerate/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/info/flow.toml b/flowstdlib/data/info/flow.toml index 11a7b8c8ab..888e505168 100644 --- a/flowstdlib/data/info/flow.toml +++ b/flowstdlib/data/info/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/multiply_row/flow.toml b/flowstdlib/data/multiply_row/flow.toml index c675fa5513..1b170cbb7a 100644 --- a/flowstdlib/data/multiply_row/flow.toml +++ b/flowstdlib/data/multiply_row/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/ordered_split/flow.toml b/flowstdlib/data/ordered_split/flow.toml index 80deb6936d..97aab75a82 100644 --- a/flowstdlib/data/ordered_split/flow.toml +++ b/flowstdlib/data/ordered_split/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/remove/flow.toml b/flowstdlib/data/remove/flow.toml index 4cc4b8167e..39049bfc08 100644 --- a/flowstdlib/data/remove/flow.toml +++ b/flowstdlib/data/remove/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/sort/flow.toml b/flowstdlib/data/sort/flow.toml index 5c91cd2093..b9ca118e5d 100644 --- a/flowstdlib/data/sort/flow.toml +++ b/flowstdlib/data/sort/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/split/flow.toml b/flowstdlib/data/split/flow.toml index a538c7a0ab..f8e49c9a91 100644 --- a/flowstdlib/data/split/flow.toml +++ b/flowstdlib/data/split/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/transpose/flow.toml b/flowstdlib/data/transpose/flow.toml index c9fb56118f..d29c792b24 100644 --- a/flowstdlib/data/transpose/flow.toml +++ b/flowstdlib/data/transpose/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/data/zip/flow.toml b/flowstdlib/data/zip/flow.toml index 411c1b512f..5b59807637 100644 --- a/flowstdlib/data/zip/flow.toml +++ b/flowstdlib/data/zip/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/fmt/reverse/flow.toml b/flowstdlib/fmt/reverse/flow.toml index 16209f86d9..4825fe2401 100644 --- a/flowstdlib/fmt/reverse/flow.toml +++ b/flowstdlib/fmt/reverse/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/fmt/to_json/flow.toml b/flowstdlib/fmt/to_json/flow.toml index 84db0642ba..7bd2f717b7 100644 --- a/flowstdlib/fmt/to_json/flow.toml +++ b/flowstdlib/fmt/to_json/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/fmt/to_string/flow.toml b/flowstdlib/fmt/to_string/flow.toml index 49148d2ac8..080b362acf 100644 --- a/flowstdlib/fmt/to_string/flow.toml +++ b/flowstdlib/fmt/to_string/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/img/format_png/flow.toml b/flowstdlib/img/format_png/flow.toml index ee299e4b1a..b765737412 100644 --- a/flowstdlib/img/format_png/flow.toml +++ b/flowstdlib/img/format_png/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" image = "=0.23.10" diff --git a/flowstdlib/math/add/flow.toml b/flowstdlib/math/add/flow.toml index 4ee01874ca..126add3d84 100644 --- a/flowstdlib/math/add/flow.toml +++ b/flowstdlib/math/add/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/math/compare/flow.toml b/flowstdlib/math/compare/flow.toml index 2c25bb6fd3..8ef5fb8d25 100644 --- a/flowstdlib/math/compare/flow.toml +++ b/flowstdlib/math/compare/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" diff --git a/flowstdlib/math/divide/flow.toml b/flowstdlib/math/divide/flow.toml index c169f5d8cb..dce971236c 100644 --- a/flowstdlib/math/divide/flow.toml +++ b/flowstdlib/math/divide/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/math/multiply/flow.toml b/flowstdlib/math/multiply/flow.toml index 08094799ac..45947b3895 100644 --- a/flowstdlib/math/multiply/flow.toml +++ b/flowstdlib/math/multiply/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/math/sqrt/flow.toml b/flowstdlib/math/sqrt/flow.toml index e5174f5ec0..c8735f0e93 100644 --- a/flowstdlib/math/sqrt/flow.toml +++ b/flowstdlib/math/sqrt/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/flowstdlib/math/subtract/flow.toml b/flowstdlib/math/subtract/flow.toml index 0c532923a9..e946cf0aa4 100644 --- a/flowstdlib/math/subtract/flow.toml +++ b/flowstdlib/math/subtract/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" [workspace] diff --git a/samples/build.rs b/samples/build.rs index 0d7cc7b68d..cb27b96773 100644 --- a/samples/build.rs +++ b/samples/build.rs @@ -1,76 +1,91 @@ -// Build script to compile the flow samples in the crate -use std::{fs, io}; -use std::io::ErrorKind; -use std::path::Path; +//! Build script to compile the flow samples in the crate +use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; +use std::{fs, io}; -use simpath::{FileType, Simpath}; +use simpath::{FileType, FoundType, Simpath}; fn main() -> io::Result<()> { + let samples_root = env!("CARGO_MANIFEST_DIR"); + + println!("cargo:rerun-if-env-changed=FLOW_LIB_PATH"); + // Tell Cargo that if any file in the samples directory changes it should rerun this build script + println!("cargo:rerun-if-changed={}", samples_root); + + println!("`flowsample` version {}", env!("CARGO_PKG_VERSION")); + println!( + "Current Working Directory: `{}`", + std::env::current_dir().unwrap().display() + ); + println!("Samples Root Directory: `{}`", env!("CARGO_MANIFEST_DIR")); + let flowc = get_flowc()?; + println!( + "Using 'flowc' compiler found at: `{}`", + flowc.to_str().unwrap() + ); + // find all sample sub-folders - for entry in fs::read_dir(env!("CARGO_MANIFEST_DIR"))? { - if let Ok(e) = entry { - if let Ok(ft) = e.file_type() { - if ft.is_dir() { - compile_sample(&e.path(), &flowc)?; - } + for entry in fs::read_dir(samples_root)? { + let e = entry?; + if e.file_type()?.is_dir() { + println!( + "\nBuilding sample in directory: `{}`", + e.path().to_str().unwrap() + ); + if compile_sample(&e.path(), &flowc).is_err() { + std::process::exit(1); } } - }; + } - println!("cargo:rerun-if-env-changed=FLOW_LIB_PATH"); Ok(()) } -fn get_flowc() -> io::Result { - let dev = Path::new(env!("CARGO_MANIFEST_DIR")).join("../target/debug/flowc"); +fn get_flowc() -> io::Result { + let root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap(); + + let dev = root.join("target/debug/flowc"); if dev.exists() { - return Ok(dev.into_os_string().to_str().unwrap().to_string()); + return Ok(dev); } - let dev = Path::new(env!("CARGO_MANIFEST_DIR")).join("../target/release/flowc"); + let dev = root.join("target/release/flowc"); if dev.exists() { - return Ok(dev.into_os_string().to_str().unwrap().to_string()); + return Ok(dev); } - if Simpath::new("PATH").find_type("flowr", FileType::File).is_ok() { - return Ok("flowc".into()); + if let Ok(FoundType::File(flowc)) = Simpath::new("PATH").find_type("flowc", FileType::File) { + return Ok(flowc); } - Err(io::Error::new(io::ErrorKind::Other, - "`flowc` could not be found in `$PATH` or `target/`")) + Err(io::Error::new( + io::ErrorKind::Other, + "`flowc` could not be found in `$PATH` or `target/`", + )) } -fn compile_sample(sample_dir: &Path, flowc: &str) -> io::Result<()> { - // Tell Cargo that if the given file changes, to rerun this build script. - println!("cargo:rerun-if-changed={}/context.toml", sample_dir.display()); - +fn compile_sample(sample_dir: &Path, flowc: &Path) -> io::Result<()> { let mut command = Command::new(flowc); - // -g for debug symbols, -d to dump compiler structs, -s to skip running, only compile the flow - let command_args = vec!("-g", "-d", "-s", sample_dir.to_str().unwrap()); + // -g for debug symbols, -d to dump compiler structs, -s to skip running and only compile the flow + let command_args = vec!["-g", "-d", "-s", sample_dir.to_str().unwrap()]; - match command.args(command_args) + let flowc_child = command + .args(command_args) .stdin(Stdio::inherit()) .stdout(Stdio::inherit()) .stderr(Stdio::inherit()) - .spawn() { - Ok(flowc_child) => { - match flowc_child.wait_with_output() { - Ok(_) => Ok(()), - Err(e) => Err(io::Error::new(io::ErrorKind::Other, - format!("Error running `flowc`: {}", e))) - } - } - Err(e) => { - match e.kind() { - ErrorKind::NotFound => - Err(io::Error::new(io::ErrorKind::Other, - format!("`flowc` was not found! Check your $PATH. {}", e))), - _ => Err(io::Error::new(io::ErrorKind::Other, - format!("Unexpected error occurred spawning `flowc`: {}", e))) - } - } + .spawn()?; + + let flowc_output = flowc_child.wait_with_output()?; + + match flowc_output.status.code() { + Some(0) => Ok(()), + Some(_) => Err(io::Error::new( + io::ErrorKind::Other, + "`flowc` exited with non-zero status code", + )), + None => Ok(()), } } diff --git a/samples/main.rs b/samples/main.rs index cd36db40f2..19aaf95448 100644 --- a/samples/main.rs +++ b/samples/main.rs @@ -13,7 +13,7 @@ fn main() -> io::Result<()> { "Current Working Directory: `{}`", std::env::current_dir().unwrap().display() ); - println!("Manifest Directory: `{}`", env!("CARGO_MANIFEST_DIR")); + println!("Samples Root Directory: `{}`", env!("CARGO_MANIFEST_DIR")); let flowr = get_flowr()?; @@ -72,7 +72,8 @@ fn run_sample(sample_dir: &Path, flowr_path: &str) -> io::Result<()> { let mut flowr_command = Command::new(flowr_path); let manifest = sample_dir.join("manifest.json"); - println!("\tRunning Sample: {:?}", sample_dir.file_name().unwrap()); + println!("\n\tRunning Sample: {:?}", sample_dir.file_name().unwrap()); + assert!(manifest.exists(), "Manifest file does not exist"); println!("\tReading STDIN from test.input, Arguments read from test.arguments"); println!("\tOutput sent to STDOUT/STDERR and file output to test.file"); @@ -152,7 +153,7 @@ mod test { println!("\tSample: {:?}", sample_dir.file_name().unwrap()); let manifest = sample_dir.join("manifest.json"); - + assert!(manifest.exists(), "manifest.json does not exist"); let mut command_args: Vec = vec!["--native".into(), manifest.display().to_string()]; command_args.append(&mut super::args(&sample_dir).unwrap()); @@ -209,7 +210,7 @@ mod test { sample_dir.file_name().unwrap(), error.display() ); - std::process::exit(-1); + std::process::exit(1); } } @@ -224,7 +225,6 @@ mod test { test_run_sample(&sample, &super::get_flowr().unwrap()); } - #[ignore] #[test] #[serial] fn test_arrays() { diff --git a/samples/mandlebrot/Cargo.toml b/samples/mandlebrot/Cargo.toml index 1fa51a1032..2b91173772 100644 --- a/samples/mandlebrot/Cargo.toml +++ b/samples/mandlebrot/Cargo.toml @@ -10,8 +10,8 @@ name="mandlebrot" path = "main.rs" [dependencies] -flowcore = "=0.34.6" -flow_impl_derive = "=0.10.0" +flowcore = "=0.34.7" +flow_impl_derive = "=0.34.7" serde_json = "1.0" num = "0.3.0" image = "=0.23.10" diff --git a/samples/mandlebrot/pixel_to_point/flow.toml b/samples/mandlebrot/pixel_to_point/flow.toml index 34866e4f82..494de28eb6 100644 --- a/samples/mandlebrot/pixel_to_point/flow.toml +++ b/samples/mandlebrot/pixel_to_point/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" serde_json = "1.0" num = "0.3.0" diff --git a/samples/mandlebrot/render_pixel/flow.toml b/samples/mandlebrot/render_pixel/flow.toml index fc668c3378..153266955f 100644 --- a/samples/mandlebrot/render_pixel/flow.toml +++ b/samples/mandlebrot/render_pixel/flow.toml @@ -15,8 +15,8 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" num = "0.3.0" serde_json = "1.0" diff --git a/samples/reverse-echo/reverse/flow.toml b/samples/reverse-echo/reverse/flow.toml index 7bf2be14e1..58f7a6a051 100644 --- a/samples/reverse-echo/reverse/flow.toml +++ b/samples/reverse-echo/reverse/flow.toml @@ -15,10 +15,9 @@ lto = true opt-level = 's' [dependencies] -flow_impl = "=0.10.0" -flow_impl_derive = "=0.10.0" - -serde_json = "1.0" +flowcore = {path = "../../../flowcore", version = "=0.34.7", default-features = false} +flow_impl_derive = "=0.34.7" +serde_json = {version = "1.0" } [workspace] exclude = ["../../../"] diff --git a/samples/router/DESCRIPTION.md b/samples/router/DESCRIPTION.md index a3f1c7dca2..9eb24d2ee4 100644 --- a/samples/router/DESCRIPTION.md +++ b/samples/router/DESCRIPTION.md @@ -1,13 +1,13 @@ router == -Descriptiopn +Description === This sample implements the algorithm (as described here https://github.com/andrewdavidmackenzie/router) for calculating the shortest route from a start-point to an end-point through a simplified road network. -![Road route London Heathrow to City Center]("LHR_to_LON.png") +![Road route London Heathrow to City Center](LHR_to_LON.png) Context Diagram ===