diff --git a/Cargo.lock b/Cargo.lock index 67aa6d3..d079217 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "sccmod" -version = "0.6.2" +version = "0.6.3" dependencies = [ "anstyle", "clap", diff --git a/Cargo.toml b/Cargo.toml index 2179dbc..340037f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sccmod" authors = ["Toby Davis \"Pencilcaseman\""] -version = "0.6.2" +version = "0.6.3" edition = "2021" readme = "README.md" license = "MIT OR Apache-2.0" diff --git a/src/builders/cmake.rs b/src/builders/cmake.rs index a5648f4..33474fe 100644 --- a/src/builders/cmake.rs +++ b/src/builders/cmake.rs @@ -18,7 +18,7 @@ pub enum CMakeBuildType { #[derive(Debug, Clone)] pub struct CMake { pub build_type: CMakeBuildType, - pub jobs: usize, + pub jobs: Option, pub prefix_args: Option>, pub configure_flags: Option>, pub cmake_root: Option, @@ -101,8 +101,13 @@ impl CMake { } shell.add_command(&format!( - "cmake --build . --config {:?} --parallel {:?}", - self.build_type, self.jobs + "cmake --build . --config {:?} --parallel {}", + self.build_type, + if let Some(jobs) = &self.jobs { + format!("{jobs}") + } else { + "".to_string() + } )); let (result, stdout, stderr) = shell.exec(); @@ -142,11 +147,20 @@ impl BuilderImpl for CMake { other => log::error(&format!("Unknown CMake build type {other}")), }; - let jobs: usize = object + // let jobs: usize = object + // .getattr("jobs") + // .map_err(|_| "Failed to read attribute 'jobs' of Builder + // object")? .extract() + // .map_err(|_| "Failed to convert attribute 'jobs' to Rust + // usize")?; + + let jobs: Option = object .getattr("jobs") .map_err(|_| "Failed to read attribute 'jobs' of Builder object")? .extract() - .map_err(|_| "Failed to convert attribute 'jobs' to Rust usize")?; + .map_err(|_| { + "Failed to convert attribute 'jobs' to Rust Option" + })?; let prefix_args: Option> = object .getattr("prefix_args") diff --git a/src/builders/make.rs b/src/builders/make.rs index c1a6f71..1a03506 100644 --- a/src/builders/make.rs +++ b/src/builders/make.rs @@ -10,7 +10,7 @@ use crate::{ #[derive(Debug, Clone)] pub struct Make { pub configure: bool, - pub jobs: usize, + pub jobs: Option, pub prefix_args: Option>, pub configure_flags: Option>, pub make_root: Option, @@ -50,8 +50,6 @@ impl Make { shell.add_command(&format!("module load {dep}")); } - // let mut configure_cmd = format!("{source_path:?}/configure"); - // Apply prefix args let mut configure_cmd = String::new(); if let Some(args) = &self.prefix_args { @@ -101,7 +99,15 @@ impl Make { } shell.set_current_dir(&path.as_ref().to_str().unwrap()); - shell.add_command(&format!("make -j {}", self.jobs)); + + shell.add_command(&format!( + "make -j {}", + if let Some(jobs) = &self.jobs { + format!("{jobs}") + } else { + "".to_string() + } + )); let (result, stdout, stderr) = shell.exec(); let result = result.map_err(|_| "Failed to run make")?; @@ -130,11 +136,20 @@ impl BuilderImpl for Make { "Failed to convert attribute 'configure' to Rust bool" })?; - let jobs: usize = object + // let jobs: usize = object + // .getattr("jobs") + // .map_err(|_| "Failed to read attribute 'jobs' of Builder + // object")? .extract() + // .map_err(|_| "Failed to convert attribute 'jobs' to Rust + // usize")?; + + let jobs: Option = object .getattr("jobs") .map_err(|_| "Failed to read attribute 'jobs' of Builder object")? .extract() - .map_err(|_| "Failed to convert attribute 'jobs' to Rust usize")?; + .map_err(|_| { + "Failed to convert attribute 'jobs' to Rust Option" + })?; let prefix_args: Option> = object .getattr("prefix_args")