Files
solana/programs/bpf/build.rs

105 lines
3.2 KiB
Rust
Raw Normal View History

extern crate walkdir;
2020-01-28 17:03:37 -08:00
use std::{env, path::Path, process::Command};
use walkdir::WalkDir;
fn rerun_if_changed(files: &[&str], directories: &[&str], excludes: &[&str]) {
let mut all_files: Vec<_> = files.iter().map(|f| f.to_string()).collect();
for directory in directories {
let files_in_directory: Vec<_> = WalkDir::new(directory)
.into_iter()
.map(|entry| entry.unwrap())
.filter(|entry| {
if !entry.file_type().is_file() {
return false;
}
for exclude in excludes.iter() {
if entry.path().to_str().unwrap().contains(exclude) {
return false;
}
}
true
})
.map(|f| f.path().to_str().unwrap().to_owned())
.collect();
all_files.extend_from_slice(&files_in_directory[..]);
}
for file in all_files {
if !Path::new(&file).is_file() {
panic!("{} is not a file", file);
}
println!("cargo:rerun-if-changed={}", file);
}
}
2018-11-14 12:06:06 -08:00
fn main() {
let bpf_c = env::var("CARGO_FEATURE_BPF_C").is_ok();
2018-11-14 12:06:06 -08:00
if bpf_c {
let install_dir =
"OUT_DIR=../target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
2018-11-14 12:06:06 -08:00
println!("cargo:warning=(not a warning) Building C-based BPF programs");
assert!(Command::new("make")
.current_dir("c")
.arg("programs")
.arg(&install_dir)
2018-11-14 12:06:06 -08:00
.status()
.expect("Failed to build C-based BPF programs")
.success());
rerun_if_changed(&["c/makefile"], &["c/src", "../../sdk"], &["/target/"]);
2018-11-14 12:06:06 -08:00
}
let bpf_rust = env::var("CARGO_FEATURE_BPF_RUST").is_ok();
if bpf_rust {
let install_dir =
"target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
2019-06-18 15:56:24 -07:00
let rust_programs = [
"128bit",
2019-06-18 15:56:24 -07:00
"alloc",
Separate the "program" feature of `solana-sdk` into a new crate called `solana-program` (bp #12989) (#13131) * Add solana-program-sdk boilerplate (cherry picked from commit 3718771ffb9caad0bc1c180e488f699ce895a10e) # Conflicts: # sdk/Cargo.toml * Initial population of solana-program-sdk (cherry picked from commit 63db3242043602c7b9765a066b6f8d01ef20454e) # Conflicts: # Cargo.lock * Port programs to solana-program-sdk (cherry picked from commit fe68f7f786acf13e5b1f1fe4c54eb7af7b549391) # Conflicts: # programs/bpf/Cargo.lock # programs/bpf/rust/128bit/Cargo.toml # programs/bpf/rust/128bit_dep/Cargo.toml # programs/bpf/rust/alloc/Cargo.toml # programs/bpf/rust/call_depth/Cargo.toml # programs/bpf/rust/custom_heap/Cargo.toml # programs/bpf/rust/dep_crate/Cargo.toml # programs/bpf/rust/deprecated_loader/Cargo.toml # programs/bpf/rust/dup_accounts/Cargo.toml # programs/bpf/rust/error_handling/Cargo.toml # programs/bpf/rust/external_spend/Cargo.toml # programs/bpf/rust/instruction_introspection/Cargo.toml # programs/bpf/rust/invoke/Cargo.toml # programs/bpf/rust/invoked/Cargo.toml # programs/bpf/rust/iter/Cargo.toml # programs/bpf/rust/many_args/Cargo.toml # programs/bpf/rust/many_args_dep/Cargo.toml # programs/bpf/rust/noop/Cargo.toml # programs/bpf/rust/panic/Cargo.toml # programs/bpf/rust/param_passing/Cargo.toml # programs/bpf/rust/param_passing_dep/Cargo.toml # programs/bpf/rust/rand/Cargo.toml # programs/bpf/rust/ristretto/Cargo.toml # programs/bpf/rust/sanity/Cargo.toml # programs/bpf/rust/sha256/Cargo.toml # programs/bpf/rust/sysval/Cargo.toml * Only activate legacy program feature for the solana-sdk crate (cherry picked from commit 85c51f5787895c97220d3a2f8ce9be6b9cbdd6c6) * Run serum-dex unit tests (cherry picked from commit 92ce381d60d65a73973fc20cdd4772334f973b96) * Rename solana-program-sdk to solana-program (cherry picked from commit dd711ab5fbf96c1efcfdf9488397e8af2568182a) # Conflicts: # programs/bpf/rust/128bit/Cargo.toml # programs/bpf/rust/128bit_dep/Cargo.toml # programs/bpf/rust/alloc/Cargo.toml # programs/bpf/rust/call_depth/Cargo.toml # programs/bpf/rust/custom_heap/Cargo.toml # programs/bpf/rust/dep_crate/Cargo.toml # programs/bpf/rust/deprecated_loader/Cargo.toml # programs/bpf/rust/dup_accounts/Cargo.toml # programs/bpf/rust/error_handling/Cargo.toml # programs/bpf/rust/external_spend/Cargo.toml # programs/bpf/rust/instruction_introspection/Cargo.toml # programs/bpf/rust/invoke/Cargo.toml # programs/bpf/rust/invoked/Cargo.toml # programs/bpf/rust/iter/Cargo.toml # programs/bpf/rust/many_args/Cargo.toml # programs/bpf/rust/many_args_dep/Cargo.toml # programs/bpf/rust/noop/Cargo.toml # programs/bpf/rust/panic/Cargo.toml # programs/bpf/rust/param_passing/Cargo.toml # programs/bpf/rust/param_passing_dep/Cargo.toml # programs/bpf/rust/rand/Cargo.toml # programs/bpf/rust/ristretto/Cargo.toml # programs/bpf/rust/sanity/Cargo.toml # programs/bpf/rust/sha256/Cargo.toml # programs/bpf/rust/sysval/Cargo.toml * Update frozen_abi hashes The movement of files in sdk/ caused ABI hashes to change (cherry picked from commit a4956844bdd081e7b90508066c579f29be306ce7) * Resolve merge conflicts Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-24 17:25:22 +00:00
"call_depth",
2020-10-06 11:03:51 -07:00
"custom_heap",
2019-06-18 15:56:24 -07:00
"dep_crate",
"deprecated_loader",
"dup_accounts",
"error_handling",
"external_spend",
"instruction_introspection",
2020-04-28 14:33:56 -07:00
"invoke",
"invoked",
2019-06-18 15:56:24 -07:00
"iter",
"many_args",
"noop",
"panic",
"param_passing",
"rand",
"ristretto",
"sanity",
2020-09-29 23:29:20 -07:00
"sha256",
"call_depth",
"sysval",
2019-06-18 15:56:24 -07:00
];
for program in rust_programs.iter() {
println!(
2019-05-21 11:22:33 -07:00
"cargo:warning=(not a warning) Building Rust-based BPF programs: solana_bpf_rust_{}",
program
);
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());
}
rerun_if_changed(&[], &["rust", "../../sdk", &install_dir], &["/target/"]);
}
2018-11-14 12:06:06 -08:00
}