feat: Added wrapper crate for including ipxe binaries
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
use build_print::error;
|
||||
|
||||
fn main() {
|
||||
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
.canonicalize()
|
||||
.unwrap();
|
||||
let src_dir = manifest_dir.join("ipxe").join("src");
|
||||
|
||||
let mut command = Command::new("make");
|
||||
command
|
||||
.stdout(Stdio::piped())
|
||||
.current_dir(&src_dir)
|
||||
.env_remove("DEBUG")
|
||||
.env_remove("PROFILE")
|
||||
.args([
|
||||
"-j",
|
||||
&std::thread::available_parallelism()
|
||||
.unwrap()
|
||||
.get()
|
||||
.to_string(),
|
||||
])
|
||||
.arg(format!(
|
||||
"EMBED={}",
|
||||
manifest_dir
|
||||
.join("src")
|
||||
.join("embed.ipxe")
|
||||
.to_string_lossy(),
|
||||
));
|
||||
|
||||
let files = ["bin/ipxe.pxe", "bin-x86_64-efi/ipxe.efi"].map(PathBuf::from);
|
||||
for file in &files {
|
||||
command.arg(file);
|
||||
}
|
||||
|
||||
let output = command.output().unwrap();
|
||||
if !output.status.success() {
|
||||
error!("{}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap())
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.join("ipxe");
|
||||
|
||||
std::fs::remove_dir_all(&out_dir).ok();
|
||||
for file in &files {
|
||||
let input = src_dir.join(file);
|
||||
let output = out_dir.join(file.file_name().unwrap());
|
||||
|
||||
std::fs::create_dir_all(output.parent().unwrap()).unwrap();
|
||||
std::fs::copy(input, output).unwrap();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user