Split out Rust BPF no-std stuff (#4968)
This commit is contained in:
@ -13,6 +13,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
solana-bpf-rust-128bit-dep = { path = "../128bit_dep", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
|
@ -3,6 +3,8 @@
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use solana_sdk_bpf_utils::info;
|
||||
|
@ -15,5 +15,4 @@ edition = "2018"
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
||||
members = []
|
@ -7,3 +7,14 @@ extern crate solana_sdk_bpf_utils;
|
||||
pub fn work(x: u128, y: u128) -> u128 {
|
||||
x + y
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
extern crate std;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_work() {
|
||||
assert_eq!(3, work(1, 2));
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
|
@ -14,6 +14,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
byteorder = { version = "1", default-features = false }
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
@ -3,6 +3,8 @@
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
|
@ -12,6 +12,7 @@ usage() {
|
||||
echo " Supported actions:"
|
||||
echo " build"
|
||||
echo " clean"
|
||||
echo " test"
|
||||
echo " clippy"
|
||||
echo " fmt"
|
||||
echo ""
|
||||
@ -26,6 +27,13 @@ perform_action() {
|
||||
clean)
|
||||
./../../../sdk/bpf/rust/clean.sh "$2"
|
||||
;;
|
||||
test)
|
||||
(
|
||||
cd "$2"
|
||||
echo "test $2"
|
||||
cargo +nightly test
|
||||
)
|
||||
;;
|
||||
clippy)
|
||||
(
|
||||
cd "$2"
|
||||
|
@ -13,6 +13,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
@ -4,6 +4,8 @@
|
||||
#![allow(unreachable_code)]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use solana_sdk_bpf_utils::entrypoint::*;
|
||||
|
@ -13,6 +13,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
@ -3,6 +3,8 @@
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use solana_sdk_bpf_utils::info;
|
||||
|
@ -13,6 +13,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
solana-bpf-rust-many-args-dep = { path = "../many_args_dep", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
mod helper;
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use solana_sdk_bpf_utils::info;
|
||||
|
@ -14,6 +14,8 @@ edition = "2018"
|
||||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/rust-test", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
@ -22,3 +22,27 @@ pub fn many_args(
|
||||
info!(arg6, arg7, arg8, arg9, 0);
|
||||
arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
extern crate solana_sdk_bpf_test;
|
||||
extern crate std;
|
||||
use super::*;
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe fn sol_log_(message: *const u8, length: u64) {
|
||||
let slice = std::slice::from_raw_parts(message, length as usize);
|
||||
let string = std::str::from_utf8(&slice).unwrap();
|
||||
std::println!("{}", string);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) {
|
||||
std::println!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_many_args() {
|
||||
assert_eq!(45, many_args(1, 2, 3, 4, 5, 6, 7, 8, 9));
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
@ -4,12 +4,15 @@
|
||||
#![allow(unreachable_code)]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use solana_sdk_bpf_utils::entrypoint::*;
|
||||
use solana_sdk_bpf_utils::log::*;
|
||||
use solana_sdk_bpf_utils::{entrypoint, info};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct SStruct {
|
||||
x: u64,
|
||||
y: u64,
|
||||
@ -59,3 +62,13 @@ fn process_instruction(ka: &mut [SolKeyedAccount], info: &SolClusterInfo, data:
|
||||
info!("Success");
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_return_sstruct() {
|
||||
assert_eq!(SStruct { x: 1, y: 2, z: 3 }, return_sstruct());
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
@ -3,6 +3,8 @@
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -13,8 +13,8 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
byteorder = { version = "1", default-features = false }
|
||||
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
@ -3,6 +3,8 @@
|
||||
#![no_std]
|
||||
#![allow(unreachable_code)]
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
|
Reference in New Issue
Block a user