Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions program/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
//to reflect the current status of oracle.h
mod c_oracle_header;

//do not link with C during unit tests (which are built in native architecture, unlike libpyth.o)
#[cfg(target_arch = "bpf")]
#[link(name = "cpyth")]
extern "C" {
fn c_entrypoint(input: *mut u8) -> u64;
}

//make the C entrypoint a no-op when running cargo test
#[cfg(not(target_arch = "bpf"))]
pub extern "C" fn c_entrypoint(input: *mut u8) -> u64{
0//SUCCESS value
}


#[no_mangle]
pub extern "C" fn entrypoint(input: *mut u8) -> u64 {
let c_ret_val = unsafe{c_entrypoint(input)};
Expand Down
5 changes: 5 additions & 0 deletions scripts/build-bpf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ cd "${RUST_DIR}"
cargo install bindgen
bindgen ./src/bindings.h -o ./src/c_oracle_header.rs
cargo clean
cargo test
cargo clean
cargo build-bpf

sha256sum ./target/**/*.so
rm ./target/**/*-keypair.json
rm -r $PYTH_DIR/target || true
Expand All @@ -52,3 +55,5 @@ mv ./target $PYTH_DIR/target