From: Grégory Burri Date: Fri, 11 Sep 2020 10:32:27 +0000 (+0200) Subject: Be able to use 'sass.bat' on Windows. X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=4ed820a37e320b727221cbdd541c63a0b90d11a6;p=rup.git Be able to use 'sass.bat' on Windows. --- diff --git a/README.md b/README.md index 6802a75..b72b710 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -## How to setup openssl on windows +# Setup + +## Openssl on windows * Install vcpkg * PS> git clone https://github.com/Microsoft/vcpkg.git @@ -12,6 +14,14 @@ * Add this path to $env:PATH: * \installed\x64-windows\bin +## Sass + +Sass is needed to generate the CSS file (backend/static/style.css) from the SASS file (backend/style.scss). + + +## Run backend + +* use the command 'Cargo run' in the backend directory (not in the root directory). ## Autoreload diff --git a/TODO.md b/TODO.md index fd7f80d..207c4b3 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,12 @@ +* Good understanding of Rust module system: http://www.sheshbabu.com/posts/rust-module-system/ +* Add a prototype Rust crate: frontent (WASM) + * Be able to interact with the DOM + * Be able to handle user event (key press for instance) + * Be able to share a common crate between client and server + * Be able to communicate between client and server with websocket+serde, structs are shared in the common crate +* Create a SQLite database and store all key events * Enable Logging. +* Use of crate clap to parse command line? [ok] Accept an argument to encrypt a message [ok] Use a setting file. \ No newline at end of file diff --git a/backend/build.rs b/backend/build.rs index ba5da7e..8837cfc 100644 --- a/backend/build.rs +++ b/backend/build.rs @@ -5,20 +5,36 @@ What is build here: - Compile the SASS file to CSS file. */ -use std::process::Command; +use std::{ env, process::{ Command, Output }, path::Path }; + +fn exists_in_path

(filename: P) -> bool + where P: AsRef { + for path in env::split_paths(&env::var_os("PATH").unwrap()) { + if path.join(&filename).is_file() { return true; } + } + false +} fn main() { println!("cargo:rerun-if-changed=style.scss"); - let output = - Command::new("sass") - .arg("./style.scss") - .arg("./static/style.css") + fn run_sass(command: &mut Command) -> Output { + command + .arg("style.scss") + .arg("static/style.css") .output() - .expect("Unable to compile SASS file, install SASS, see https://sass-lang.com/"); + .expect("Unable to compile SASS file, install SASS, see https://sass-lang.com/") + } + + let output = + if exists_in_path("sass.bat") { + run_sass(Command::new("cmd").args(&["/C", "sass.bat"])) + } else { + run_sass(&mut Command::new("sass")) + }; if !output.status.success() { - //panic!("Unable to compile SASS file, install SASS, see https://sass-lang.com/") + // SASS will put the error in the file. let error = std::fs::read_to_string("./static/style.css").expect("unable to read style.css"); panic!(error); } diff --git a/common/src/lib.rs b/common/src/lib.rs index 7216967..d257341 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,4 +1,9 @@ -mod rup { + + + +mod tests { + use super::*; + #[test] fn it_works() { assert_eq!(2 + 2, 4);