diff --git a/Cargo.toml b/Cargo.toml index 5ce3990..14e4281 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ lto = "fat" codegen-units = 1 [dependencies] -mimalloc = { version = "0.1.29" } clap = { version = "3.2.8", features = ["derive", "suggestions"] } toml = { version = "0.5.9", default-features = false } serde = { version = "1.0.139", default-features = false } @@ -31,3 +30,6 @@ tabled = { version = "0.8.0", default-features = false, features = ["derive", "c crossterm = { version = "0.24.0", default-features = false } regex = { version = "1.6.0", default-features = false, features = ["std"] } spinoff = { version = "0.4.0", default-features = false } + +[target.'cfg(target_os = "linux")'.dependencies] +mimalloc = { version = "0.1.29" } diff --git a/src/internal/exit_codes.rs b/src/internal/exit_codes.rs index ba53a67..5b04209 100644 --- a/src/internal/exit_codes.rs +++ b/src/internal/exit_codes.rs @@ -1,4 +1,5 @@ pub enum AppExitCode { + #[cfg(target_os = "linux")] RunAsRoot = 1, BuildInWorkspace = 2, PkgNotFound = 3, diff --git a/src/main.rs b/src/main.rs index 8bc5eb7..55143fc 100755 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ use crate::args::{Args, Operation}; use crate::internal::parse_cfg; use crate::internal::AppExitCode; +#[cfg(target_os = "linux")] #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; diff --git a/src/operations/clean.rs b/src/operations/clean.rs index 1d4ef86..c92c984 100644 --- a/src/operations/clean.rs +++ b/src/operations/clean.rs @@ -3,15 +3,15 @@ use crate::{crash, info, internal::AppExitCode, log}; pub fn clean(verbose: bool, force: bool) { info!("Resetting mlc repo, deleting all directories"); // Get a vec of all files/dirs in the current directory - let dir_paths = std::fs::read_dir("./").unwrap(); + let dir_paths = std::fs::read_dir(".").unwrap(); log!(verbose, "Paths: {:?}", dir_paths); let mut dirs = dir_paths .map(|x| x.unwrap().path().display().to_string()) .collect::>(); // Remove mlc.toml and .git from output - dirs.retain(|x| *x != "./mlc.toml"); - dirs.retain(|x| *x != "./.git"); + dirs.retain(|x| *x != "./mlc.toml" && *x != ".\\mlc.toml"); + dirs.retain(|x| *x != "./.git" && *x != ".\\.git"); // Enter each directory and check git status @@ -44,7 +44,7 @@ pub fn clean(verbose: bool, force: bool) { AppExitCode::NotClean, "The following directories are not clean: \n {}\n\ If you are sure no important changes are staged, run `mlc clean` with the `--force` flag to delete them.", - unclean_dirs.iter().map(|x| (*x).to_string().replace("./", "")).collect::>().join(", ") + unclean_dirs.iter().map(|x| (*x).to_string().replace("./", "").replace(".\\", "")).collect::>().join(", ") ); } @@ -56,7 +56,7 @@ pub fn clean(verbose: bool, force: bool) { "Reset complete, dirs removed: \n \ {}", dirs.iter() - .map(|x| x.replace("./", "")) + .map(|x| x.replace("./", "").replace(".\\", "")) .collect::>() .join("\n ") ); diff --git a/src/operations/clone.rs b/src/operations/clone.rs index 75db48b..097b38b 100644 --- a/src/operations/clone.rs +++ b/src/operations/clone.rs @@ -11,14 +11,14 @@ pub fn clone(verbose: bool) { log!(verbose, "Repos: {:?}", repos); // Get a vector of all files/dirs in the current directory, excluding config file - let dir_paths = std::fs::read_dir("./").unwrap(); + let dir_paths = std::fs::read_dir(".").unwrap(); let mut dirs = dir_paths .map(|x| x.unwrap().path().display().to_string()) .collect::>(); - dirs.retain(|x| *x != "./mlc.toml"); - dirs.retain(|x| *x != "./out"); + dirs.retain(|x| *x != "./mlc.toml" && *x != ".\\mlc.toml"); + dirs.retain(|x| *x != "./out" && *x != ".\\out"); if config.mode.repository.is_some() { - dirs.retain(|x| *x != format!("./{}", config.mode.repository.as_ref().unwrap().name)); + dirs.retain(|x| *x != format!("./{}", config.mode.repository.as_ref().unwrap().name) && *x != format!(".\\{}", config.mode.repository.as_ref().unwrap().name)); } log!(verbose, "Paths with mlc.toml excluded: {:?}", dirs); @@ -26,7 +26,7 @@ pub fn clone(verbose: bool) { let mut repo_diff = vec![]; for repo in repos { let name = &repo.name; - if !dirs.contains(&format!("./{}", name)) { + if !dirs.contains(&format!("./{}", name)) || !dirs.contains(&format!(".\\{}", name)) { repo_diff.push(repo); } } diff --git a/src/operations/prune.rs b/src/operations/prune.rs index cc17e04..fe38a68 100644 --- a/src/operations/prune.rs +++ b/src/operations/prune.rs @@ -28,9 +28,9 @@ pub fn prune(verbose: bool) { env::set_current_dir("out").unwrap(); log!(verbose, "Current dir: {:?}", env::current_dir().unwrap()); - // Read all files from ./ into a Vec, except for .sig files + // Read all files from . into a Vec, except for .sig files let mut files: Vec = vec![]; - for entry in fs::read_dir("./").unwrap() { + for entry in fs::read_dir(".").unwrap() { let entry = entry.unwrap(); let path = entry.path(); if path.extension().unwrap() != "sig" { @@ -120,7 +120,7 @@ pub fn prune(verbose: bool) { for p in &mut packages_to_delete { println!( "{}", - format!(" {}-{}", p.name.replace("./", ""), p.ver).bold() + format!(" {}-{}", p.name.replace("./", "").replace(".\\", ""), p.ver).bold() ); } } diff --git a/src/repository/repo.rs b/src/repository/repo.rs index 8fab7c8..d410edc 100644 --- a/src/repository/repo.rs +++ b/src/repository/repo.rs @@ -43,7 +43,7 @@ pub fn generate(verbose: bool) { && config.mode.repository.as_ref().unwrap().signing.on_gen { // Get a list of all .tar.* files in repository - let files = fs::read_dir("./").unwrap(); + let files = fs::read_dir(".").unwrap(); for file in files { let file = file.unwrap(); let path = file.path();