Add --bpf-out-dir argument to control where the final build products land

This commit is contained in:
Michael Vines
2020-10-22 17:10:42 -07:00
committed by mergify[bot]
parent 4669fa0f98
commit b169d9cfbe
5 changed files with 47 additions and 25 deletions

View File

@ -57,13 +57,6 @@ fn main() {
let install_dir =
"target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
assert!(Command::new("mkdir")
.arg("-p")
.arg(&install_dir)
.status()
.expect("Unable to create BPF install directory")
.success());
let rust_programs = [
"128bit",
"alloc",
@ -93,22 +86,16 @@ fn main() {
"cargo:warning=(not a warning) Building Rust-based BPF programs: solana_bpf_rust_{}",
program
);
assert!(Command::new("bash")
.current_dir(format!("rust/{}", program))
.args(&["../../../../cargo-build-bpf"])
assert!(Command::new("../../cargo-build-bpf")
.args(&[
"--manifest-path",
&format!("rust/{}/Cargo.toml", program),
"--bpf-out-dir",
&install_dir
])
.status()
.expect("Error calling cargo-build-bpf from build.rs")
.success());
let src = format!(
"rust/{0}/solana_bpf_rust_{0}.so",
program,
);
assert!(Command::new("mv")
.arg(&src)
.arg(&install_dir)
.status()
.unwrap_or_else(|_| panic!("Failed to cp {} to {}", src, install_dir))
.success());
}
rerun_if_changed(&[], &["rust", "../../sdk", &install_dir], &["/target/"]);

View File

@ -54,7 +54,9 @@ fn load_bpf_program(
name: &str,
) -> Pubkey {
let path = create_bpf_path(name);
let mut file = File::open(path).unwrap();
let mut file = File::open(&path).unwrap_or_else(|err| {
panic!("Failed to open {}: {}", path.display(), err);
});
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
load_program(bank_client, payer_keypair, loader_id, elf)