-## How to setup openssl on windows\r
+# Setup\r
+\r
+## Openssl on windows\r
\r
* Install vcpkg\r
* PS> git clone https://github.com/Microsoft/vcpkg.git\r
* Add this path to $env:PATH:\r
* <path to vcpkg installation>\installed\x64-windows\bin\r
\r
+## Sass\r
+\r
+Sass is needed to generate the CSS file (backend/static/style.css) from the SASS file (backend/style.scss).\r
+\r
+\r
+## Run backend\r
+\r
+* use the command 'Cargo run' in the backend directory (not in the root directory).\r
\r
## Autoreload\r
\r
+* Good understanding of Rust module system: http://www.sheshbabu.com/posts/rust-module-system/\r
+* Add a prototype Rust crate: frontent (WASM)\r
+ * Be able to interact with the DOM\r
+ * Be able to handle user event (key press for instance)\r
+ * Be able to share a common crate between client and server\r
+ * Be able to communicate between client and server with websocket+serde, structs are shared in the common crate\r
+* Create a SQLite database and store all key events\r
* Enable Logging.\r
+* Use of crate clap to parse command line?\r
\r
[ok] Accept an argument to encrypt a message\r
[ok] Use a setting file.
\ No newline at end of file
- Compile the SASS file to CSS file.
*/
-use std::process::Command;
+use std::{ env, process::{ Command, Output }, path::Path };
+
+fn exists_in_path<P>(filename: P) -> bool
+ where P: AsRef<Path> {
+ 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);
}