diff --git a/Cargo.toml b/Cargo.toml index bbe2c79..eb8148e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,8 @@ name = "cynthiaweb" path = "./source/Main/main.rs" [features] -default = ["js_runtime"] +default = ["js_runtime", "selfinit"] +selfinit = ["dep:rust-lzma"] js_runtime = [] @@ -34,13 +35,14 @@ lto = true panic = 'abort' [dependencies] +rust-lzma = { version = "0.6.0", optional = true } +chrono = "0.4.38" futures = "0.3.30" actix-web = "4" actix-files = "0.6" serde = { version = "1.0.104", features = ["derive"] } serde_yaml = "0.9.29" # colored = "2.0.4" // No longer needed, Cynthia uses its own color module -chrono = "0.4.38" simplelog = "0.12.2" indicatif = "0.17.8" log = "0.4.21" @@ -75,8 +77,7 @@ reqwest = { version = "0.12.5" } interactive_process = "0.1.3" serde_dhall = "0.12.1" regex = "1.10.3" -rust-lzma = "0.6.0" [build-dependencies] -rust-lzma = "0.6.0" +rust-lzma = { version = "0.6.0", optional = true } tar = "0.4.40" diff --git a/README.MD b/README.MD index cfb4fcb..6c2b03c 100644 --- a/README.MD +++ b/README.MD @@ -10,7 +10,8 @@ Cynthia is currently in development, and is not yet ready for use. Cynthia is se > [!WARNING] > Windows support is not yet available. Cynthia is currently only supported on Linux and MacOS. > As I don't run servers on Windows, it doesn't make sense for me to support it. If you want to run Cynthia on Windows, you can try using WSL2. -> This might be fixed in the future, but it's not something I'm actively working on. +> +>> UPDATE: If you _need_ Windows support timely, disable the `selfinit` feature while compiling Cynthia. This will remove the need for the lzma crate, which is not yet supported on Windows. ## usage diff --git a/build.rs b/build.rs index 85bc181..5f0f47b 100644 --- a/build.rs +++ b/build.rs @@ -8,33 +8,35 @@ const FILES: [&str; 1] = ["cleansheet"]; fn main() { { - let packed_folder = { - let mut pkd = Vec::new(); - let mut archive = tar::Builder::new(&mut pkd); - archive.append_dir_all("", "cleansheet").unwrap(); - archive.finish().unwrap(); - drop(archive); - pkd - }; - - let compressed_file = lzma::compress(&packed_folder, 9).unwrap(); - std::fs::write("./target/cleansheet.tar.xz", compressed_file).unwrap(); + #[cfg(feature = "selfinit")] { - let mut filelist: String = String::new(); - let paths = std::fs::read_dir("./cleansheet/").unwrap(); + let packed_folder = { + let mut pkd = Vec::new(); + let mut archive = tar::Builder::new(&mut pkd); + archive.append_dir_all("", "cleansheet").unwrap(); + archive.finish().unwrap(); + drop(archive); + pkd + }; + + let compressed_file = lzma::compress(&packed_folder, 9).unwrap(); + std::fs::write("./target/cleansheet.tar.xz", compressed_file).unwrap(); + { + let mut filelist: String = String::new(); + let paths = std::fs::read_dir("./cleansheet/").unwrap(); - for path in paths { - filelist.push_str( - format!("{}\n", path.unwrap().path().display()) - .as_str() - .replace("./cleansheet/", "") - .as_str(), - ); + for path in paths { + filelist.push_str( + format!("{}\n", path.unwrap().path().display()) + .as_str() + .replace("./cleansheet/", "") + .as_str(), + ); + } + std::fs::write("./target/cleansheet.filelist.txt", filelist).unwrap(); } - std::fs::write("./target/cleansheet.filelist.txt", filelist).unwrap(); } } - #[cfg(not(feature = "js_runtime"))] println!("cargo:warning=Node features are disabled. This means you won't need a node runtime to build or run Cynthia. It also means that some features are disabled."); diff --git a/source/Main/helpers.rs b/source/Main/helpers.rs index 3e72717..daae3f6 100644 --- a/source/Main/helpers.rs +++ b/source/Main/helpers.rs @@ -1,5 +1,6 @@ use std::path::PathBuf; +#[cfg(feature = "selfinit")] /// Decompresses a folder from the bits of a .tar.xz file pub(crate) fn decompress_folder(compressed_folder: &[u8], output_folder: PathBuf) { let decompressed_folder = lzma::decompress(compressed_folder).unwrap(); diff --git a/source/Main/main.rs b/source/Main/main.rs index b8914d0..ffd732d 100644 --- a/source/Main/main.rs +++ b/source/Main/main.rs @@ -119,6 +119,7 @@ async fn main() { .to_ascii_lowercase() .as_str() { + #[cfg(feature = "selfinit")] "init" => { interactive_initialiser().await; } @@ -201,6 +202,7 @@ async fn main() { } } +#[cfg(feature = "selfinit")] async fn interactive_initialiser() { // Steps for the initialiser: // 1. Check if over a config already exists. diff --git a/win.cmd b/win.cmd new file mode 100644 index 0000000..f7c1d2a --- /dev/null +++ b/win.cmd @@ -0,0 +1 @@ +cargo b --no-default-features --features js_runtime