2019-01-09 09:56:23 -08:00
|
|
|
extern crate walkdir;
|
|
|
|
|
2020-01-28 17:03:37 -08:00
|
|
|
use std::{env, path::Path, process::Command};
|
2019-01-09 09:56:23 -08:00
|
|
|
use walkdir::WalkDir;
|
|
|
|
|
2019-05-16 17:35:42 -07:00
|
|
|
fn rerun_if_changed(files: &[&str], directories: &[&str], excludes: &[&str]) {
|
2019-01-09 09:56:23 -08:00
|
|
|
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())
|
2019-05-16 17:35:42 -07:00
|
|
|
.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
|
|
|
|
})
|
2019-01-09 09:56:23 -08:00
|
|
|
.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() {
|
2020-09-01 17:25:55 -07:00
|
|
|
let bpf_c = env::var("CARGO_FEATURE_BPF_C").is_ok();
|
2018-11-14 12:06:06 -08:00
|
|
|
if bpf_c {
|
2020-12-09 02:14:53 -08:00
|
|
|
let install_dir =
|
|
|
|
"OUT_DIR=../target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
|
2018-11-14 12:06:06 -08:00
|
|
|
|
2019-05-16 17:35:42 -07:00
|
|
|
println!("cargo:warning=(not a warning) Building C-based BPF programs");
|
2020-12-09 02:14:53 -08:00
|
|
|
assert!(Command::new("make")
|
|
|
|
.current_dir("c")
|
|
|
|
.arg("programs")
|
|
|
|
.arg(&install_dir)
|
|
|
|
.status()
|
|
|
|
.expect("Failed to build C-based BPF programs")
|
|
|
|
.success());
|
2019-05-16 17:35:42 -07:00
|
|
|
|
|
|
|
rerun_if_changed(&["c/makefile"], &["c/src", "../../sdk"], &["/target/"]);
|
2018-11-14 12:06:06 -08:00
|
|
|
}
|
2019-01-02 15:12:42 -08:00
|
|
|
|
2020-09-01 17:25:55 -07:00
|
|
|
let bpf_rust = env::var("CARGO_FEATURE_BPF_RUST").is_ok();
|
2019-01-02 15:12:42 -08:00
|
|
|
if bpf_rust {
|
2019-02-28 22:05:11 -08:00
|
|
|
let install_dir =
|
2019-09-11 14:55:58 -07:00
|
|
|
"target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
|
2019-01-02 15:12:42 -08:00
|
|
|
|
2019-06-18 15:56:24 -07:00
|
|
|
let rust_programs = [
|
2019-06-21 02:43:50 -07:00
|
|
|
"128bit",
|
2019-06-18 15:56:24 -07:00
|
|
|
"alloc",
|
2020-10-22 10:23:50 -07:00
|
|
|
"call_depth",
|
2020-12-01 07:35:07 -08:00
|
|
|
"caller_access",
|
2020-10-06 11:03:51 -07:00
|
|
|
"custom_heap",
|
2019-06-18 15:56:24 -07:00
|
|
|
"dep_crate",
|
2020-08-31 14:06:58 -07:00
|
|
|
"deprecated_loader",
|
2020-01-21 10:59:19 -08:00
|
|
|
"dup_accounts",
|
2020-01-30 09:47:22 -08:00
|
|
|
"error_handling",
|
2021-09-17 01:14:49 -07:00
|
|
|
"log_data",
|
2020-01-30 09:47:22 -08:00
|
|
|
"external_spend",
|
2021-03-04 12:34:36 -08:00
|
|
|
"finalize",
|
2020-09-19 12:17:46 -07:00
|
|
|
"instruction_introspection",
|
2020-04-28 14:33:56 -07:00
|
|
|
"invoke",
|
2020-12-04 21:54:42 -08:00
|
|
|
"invoke_and_error",
|
|
|
|
"invoke_and_ok",
|
2020-12-17 15:39:49 -08:00
|
|
|
"invoke_and_return",
|
2020-04-28 14:33:56 -07:00
|
|
|
"invoked",
|
2019-06-18 15:56:24 -07:00
|
|
|
"iter",
|
|
|
|
"many_args",
|
2020-11-05 22:20:54 -08:00
|
|
|
"mem",
|
2021-06-01 15:33:17 -07:00
|
|
|
"membuiltins",
|
2019-06-18 15:56:24 -07:00
|
|
|
"noop",
|
|
|
|
"panic",
|
2019-08-29 11:25:22 -07:00
|
|
|
"param_passing",
|
2020-09-29 17:25:51 -07:00
|
|
|
"rand",
|
2021-09-28 01:13:03 -07:00
|
|
|
"realloc",
|
|
|
|
"realloc_invoke",
|
2020-12-02 09:05:42 -08:00
|
|
|
"ro_modify",
|
2021-05-28 09:50:25 -07:00
|
|
|
"ro_account_modify",
|
2020-09-11 18:49:00 -07:00
|
|
|
"sanity",
|
2021-07-07 13:15:14 -07:00
|
|
|
"secp256k1_recover",
|
2021-05-10 16:16:58 -07:00
|
|
|
"sha",
|
2022-02-02 16:45:57 -08:00
|
|
|
"sibling_inner_instruction",
|
|
|
|
"sibling_instruction",
|
2022-02-15 04:09:59 -08:00
|
|
|
"simulation",
|
2020-11-30 13:06:11 -08:00
|
|
|
"spoof1",
|
|
|
|
"spoof1_system",
|
2020-12-14 15:35:10 -08:00
|
|
|
"upgradeable",
|
|
|
|
"upgraded",
|
2022-01-04 22:55:26 -08:00
|
|
|
"zk_token_elgamal",
|
2019-06-18 15:56:24 -07:00
|
|
|
];
|
2019-05-16 17:35:42 -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_{}",
|
2019-05-16 17:35:42 -07:00
|
|
|
program
|
|
|
|
);
|
2020-10-22 17:10:42 -07:00
|
|
|
assert!(Command::new("../../cargo-build-bpf")
|
|
|
|
.args(&[
|
|
|
|
"--manifest-path",
|
|
|
|
&format!("rust/{}/Cargo.toml", program),
|
|
|
|
"--bpf-out-dir",
|
|
|
|
&install_dir
|
|
|
|
])
|
2019-05-16 17:35:42 -07:00
|
|
|
.status()
|
2020-10-21 17:32:51 -07:00
|
|
|
.expect("Error calling cargo-build-bpf from build.rs")
|
2019-05-16 17:35:42 -07:00
|
|
|
.success());
|
|
|
|
}
|
|
|
|
|
|
|
|
rerun_if_changed(&[], &["rust", "../../sdk", &install_dir], &["/target/"]);
|
2019-01-02 15:12:42 -08:00
|
|
|
}
|
2018-11-14 12:06:06 -08:00
|
|
|
}
|