2019-01-09 09:56:23 -08:00
|
|
|
extern crate walkdir;
|
|
|
|
|
2022-02-21 19:59:06 -08:00
|
|
|
use {
|
|
|
|
std::{env, path::Path, process::Command},
|
|
|
|
walkdir::WalkDir,
|
|
|
|
};
|
2019-01-09 09:56:23 -08:00
|
|
|
|
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 {
|
2022-03-11 12:07:06 -08:00
|
|
|
let install_dir = "OUT_DIR=../target/".to_string() + &env::var("PROFILE").unwrap() + "/bpf";
|
2018-11-14 12:06:06 -08:00
|
|
|
|
2022-08-07 18:45:50 -07:00
|
|
|
println!("cargo:warning=(not a warning) Building C-based SBF programs");
|
2020-12-09 02:14:53 -08:00
|
|
|
assert!(Command::new("make")
|
|
|
|
.current_dir("c")
|
|
|
|
.arg("programs")
|
|
|
|
.arg(&install_dir)
|
|
|
|
.status()
|
2022-08-07 18:45:50 -07:00
|
|
|
.expect("Failed to build C-based SBF programs")
|
2020-12-09 02:14:53 -08:00
|
|
|
.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 {
|
2022-03-11 12:07:06 -08:00
|
|
|
let install_dir = "target/".to_string() + &env::var("PROFILE").unwrap() + "/bpf";
|
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",
|
2022-06-11 18:18:51 -07:00
|
|
|
"curve25519",
|
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",
|
2022-04-13 12:41:52 -07:00
|
|
|
"get_minimum_delegation",
|
2022-05-19 15:14:28 -07:00
|
|
|
"inner_instruction_alignment_check",
|
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-04-22 03:32:31 -07:00
|
|
|
"simulation",
|
2020-11-30 13:06:11 -08:00
|
|
|
"spoof1",
|
|
|
|
"spoof1_system",
|
2020-12-14 15:35:10 -08:00
|
|
|
"upgradeable",
|
|
|
|
"upgraded",
|
2019-06-18 15:56:24 -07:00
|
|
|
];
|
2019-05-16 17:35:42 -07:00
|
|
|
for program in rust_programs.iter() {
|
|
|
|
println!(
|
2022-08-07 18:45:50 -07:00
|
|
|
"cargo:warning=(not a warning) Building Rust-based SBF programs: solana_bpf_rust_{}",
|
2019-05-16 17:35:42 -07:00
|
|
|
program
|
|
|
|
);
|
2022-08-07 18:45:50 -07:00
|
|
|
assert!(Command::new("../../cargo-build-sbf")
|
2022-09-22 15:23:03 -07:00
|
|
|
.args([
|
2020-10-22 17:10:42 -07:00
|
|
|
"--manifest-path",
|
|
|
|
&format!("rust/{}/Cargo.toml", program),
|
2022-08-07 18:45:50 -07:00
|
|
|
"--sbf-out-dir",
|
2020-10-22 17:10:42 -07:00
|
|
|
&install_dir
|
|
|
|
])
|
2019-05-16 17:35:42 -07:00
|
|
|
.status()
|
2022-08-07 18:45:50 -07:00
|
|
|
.expect("Error calling cargo-build-sbf 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
|
|
|
}
|