Skip to content

Commit

Permalink
jobs=None now uses all available hardware threads
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencilcaseman committed Oct 20, 2024
1 parent 1068bbe commit c080abe
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
24 changes: 19 additions & 5 deletions src/builders/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum CMakeBuildType {
#[derive(Debug, Clone)]
pub struct CMake {
pub build_type: CMakeBuildType,
pub jobs: usize,
pub jobs: Option<usize>,
pub prefix_args: Option<Vec<String>>,
pub configure_flags: Option<Vec<String>>,
pub cmake_root: Option<String>,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<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")?;
.map_err(|_| {
"Failed to convert attribute 'jobs' to Rust Option<usize>"
})?;

let prefix_args: Option<Vec<String>> = object
.getattr("prefix_args")
Expand Down
27 changes: 21 additions & 6 deletions src/builders/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
#[derive(Debug, Clone)]
pub struct Make {
pub configure: bool,
pub jobs: usize,
pub jobs: Option<usize>,
pub prefix_args: Option<Vec<String>>,
pub configure_flags: Option<Vec<String>>,
pub make_root: Option<String>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")?;
Expand Down Expand Up @@ -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<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")?;
.map_err(|_| {
"Failed to convert attribute 'jobs' to Rust Option<usize>"
})?;

let prefix_args: Option<Vec<String>> = object
.getattr("prefix_args")
Expand Down

0 comments on commit c080abe

Please sign in to comment.