Skip to content

Commit

Permalink
Make in separate build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencilcaseman committed May 30, 2024
1 parent db21693 commit 1823431
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 49 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.3.1"
version = "0.3.2"
edition = "2021"
readme = "README.md"
license = "MIT OR Apache-2.0"
Expand Down
59 changes: 13 additions & 46 deletions src/builders/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,26 @@ impl Make {
>(
&self,
source_path: &P0,
_: &P1,
build_path: &P1,
install_path: &P2,
dependencies: &[String],
) -> Result<(), String> {
log::status("Configuring");

fs::create_dir_all(build_path).map_err(|e| e.to_string())?;

let source_path = path::absolute(source_path).map_err(|err| err.to_string())?;
let build_path = path::absolute(build_path).map_err(|err| err.to_string())?;
let install_path = path::absolute(install_path).map_err(|err| err.to_string())?;

// let mut configure = Command::new("./configure");
// configure.current_dir(&source_path);

// if let Some(flags) = &self.configure_flags {
// for flag in flags {
// configure.arg(flag);
// }
// }

// // Set prefix to the install directory
// configure.arg(format!(
// "--prefix={}",
// install_path
// .to_str()
// .ok_or("Failed to convert install path to string")?
// ));

let mut shell = Shell::default();
shell.set_current_dir(&source_path.to_str().unwrap());
shell.set_current_dir(&build_path);

for dep in dependencies {
shell.add_command(&format!("module load {dep}"));
}

// shell.add_command(&format!("./configure --prefix={install_path:?}"));

let mut configure_cmd = format!("./configure --prefix={install_path:?}");
let mut configure_cmd = format!("{source_path:?}/configure --prefix={install_path:?}");

if let Some(flags) = &self.configure_flags {
for flag in flags {
Expand Down Expand Up @@ -95,18 +79,6 @@ impl Make {
) -> Result<(), String> {
log::status("Running make");

// let mut make = Command::new("make");
// make.current_dir(path);
// make.arg("-j");
// make.arg(format!("{}", self.jobs));
// make.stdout(std::process::Stdio::piped());
// make.stderr(std::process::Stdio::piped());

// println!("Command: {make:?}");

// let spawn = make.spawn().map_err(|e| e.to_string())?;
// let (result, stdout, stderr) = child_logger(spawn);

let mut shell = Shell::default();

for dep in dependencies {
Expand All @@ -119,11 +91,6 @@ impl Make {
let (result, stdout, stderr) = shell.exec();
let result = result.map_err(|_| "Failed to run make")?;

// if result.is_err() {
// return Err("Failed to run make".to_string());
// }
// let result = result.unwrap();

if !result.success() {
return Err(format!(
"Failed to execute make. Output:\n{}\n{}",
Expand Down Expand Up @@ -175,28 +142,28 @@ impl BuilderImpl for Make {
dependencies: &[String],
) -> Result<(), String> {
self.configure(source_path, build_path, install_path, dependencies)?;
self.compile(source_path, dependencies)?;
self.compile(build_path, dependencies)?;
Ok(())
}

fn install<P0: AsRef<Path>, P1: AsRef<Path>, P2: AsRef<Path>>(
&self,
source_path: &P0,
_: &P1, // Build path is the source path
_: &P0,
build_path: &P1, // Build path is the source path
install_path: &P2,
_: &[String], // Dependencies are not necessary for installing
) -> Result<(), String> {
let source_path = path::absolute(source_path).map_err(|err| err.to_string())?;
let build_path = path::absolute(build_path).map_err(|err| err.to_string())?;
let install_path = path::absolute(install_path).map_err(|err| err.to_string())?;

fs::create_dir_all(install_path).map_err(|e| e.to_string())?;

if !source_path.exists() {
return Err(format!("Source directory {source_path:?} does not exist"));
if !build_path.exists() {
return Err(format!("Source directory {build_path:?} does not exist"));
}

let mut make = Command::new("make");
make.current_dir(source_path);
make.current_dir(build_path);
make.arg("install");

make.stdout(std::process::Stdio::piped());
Expand Down
2 changes: 1 addition & 1 deletion src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Module {
}
}

let build_path = self.build_path.clone() + &flavour_str;
let build_path = self.build_path.clone() + "sccmod_build" + &flavour_str;
let install_path = self.install_path.clone() + &flavour_str;

// let modules: Vec<String> = flavour
Expand Down

0 comments on commit 1823431

Please sign in to comment.