Skip to content

Commit

Permalink
Allow specification of make_root for Make builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencilcaseman committed Oct 6, 2024
1 parent ae90509 commit ae56b01
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 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 src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn extract<P: AsRef<Path>>(
archive_type: &str,
) -> Result<(), String> {
let mut command = match archive_type.to_lowercase().as_ref() {
"tar" | "tar.gz" | "targz" | "tgz" => {
"tar" | "tar.gz" | "targz" | "tgz" | "tar.xz" | "txz" | "tarxz" => {
let mut cmd = Command::new("tar");
cmd.arg("-xvf"); // Extract verbose file
cmd.arg(name); // File name
Expand Down
28 changes: 26 additions & 2 deletions src/builders/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct Make {
pub jobs: usize,
pub prefix_args: Option<Vec<String>>,
pub configure_flags: Option<Vec<String>>,
pub make_root: Option<String>,
}

impl Make {
Expand Down Expand Up @@ -150,7 +151,17 @@ impl BuilderImpl for Make {
.extract()
.map_err(|_| "Failed to convert attribute 'configure_flags' to Rust Vec<String>")?;

Ok(Self { configure, jobs, prefix_args, configure_flags })
let make_root: Option<String> = object
.getattr("make_root")
.map_err(|_| {
"Failed to read attribute 'make_root' of Builder object"
})?
.extract()
.map_err(|_| {
"Failed to convert attribute 'make_root' to Rust String"
})?;

Ok(Self { configure, jobs, prefix_args, configure_flags, make_root })
}

fn build<
Expand All @@ -164,7 +175,20 @@ impl BuilderImpl for Make {
install_path: &P2,
dependencies: &[String],
) -> Result<(), String> {
self.configure(source_path, build_path, install_path, dependencies)?;
let make_source_path = if let Some(root) = &self.make_root {
source_path.as_ref().to_str().unwrap().to_owned()
+ PATH_SEP.to_string().as_ref()
+ root
} else {
source_path.as_ref().to_str().unwrap().to_owned()
};

self.configure(
&make_source_path,
build_path,
install_path,
dependencies,
)?;
self.compile(build_path, dependencies)?;
Ok(())
}
Expand Down
10 changes: 9 additions & 1 deletion src/sccmod/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ def __init__(


class Make:
def __init__(self, configure=True, jobs=8, prefix_args=None, configure_flags=None):
def __init__(
self,
configure=True,
jobs=8,
prefix_args=None,
configure_flags=None,
make_root=None,
):
self.configure = configure
self.jobs = jobs
self.prefix_args = prefix_args or []
self.configure_flags = configure_flags or []
self.make_root = make_root

0 comments on commit ae56b01

Please sign in to comment.