Skip to content

Commit

Permalink
fix: Update Rust-BPF example (solana-labs#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored and mvines committed Jun 15, 2020
1 parent b347f5d commit 0a08692
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 3 deletions.
2 changes: 1 addition & 1 deletion web3.js/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ script:
- npm run lint
- npm run codecov
- make -C examples/bpf-c-noop/
- bpf-sdk/rust/build.sh examples/bpf-rust-noop
- examples/bpf-rust-noop/do.sh build
- npm run localnet:update
- npm run localnet:up
- npm run examples || true
Expand Down
6 changes: 5 additions & 1 deletion web3.js/examples/bpf-rust-noop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ edition = "2018"

[dependencies]
solana-sdk-bpf-utils = { path = "../../bpf-sdk/rust/rust-utils" }
solana-sdk-bpf-no-std = { path = "../../bpf-sdk/rust/rust-no-std" }

[dev_dependencies]
solana-sdk-bpf-test = { path = "../../bpf-sdk/rust/rust-test"}

[workspace]
members = []

[lib]
crate-type = ["cdylib"]
name = "solana_bpf_rust_noop"
crate-type = ["cdylib"]
58 changes: 58 additions & 0 deletions web3.js/examples/bpf-rust-noop/do.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash

cd "$(dirname "$0")"

usage() {
cat <<EOF
Usage: do.sh action <project>
If relative_project_path is ommitted then action will
be performed on all projects
Supported actions:
build
clean
test
clippy
fmt
EOF
}

perform_action() {
set -e
case "$1" in
build)
../../bpf-sdk/rust/build.sh "$PWD"
;;
clean)
../../bpf-sdk/rust/clean.sh "$PWD"
;;
test)
echo "test $2"
cargo +nightly test
;;
clippy)
echo "clippy $2"
cargo +nightly clippy
;;
fmt)
echo "formatting $2"
cargo fmt
;;
help)
usage
exit
;;
*)
echo "Error: Unknown command"
usage
exit
;;
esac
}

set -e

perform_action "$1"
2 changes: 2 additions & 0 deletions web3.js/examples/bpf-rust-noop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion web3.js/test/fixtures/noop-rust/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -ex

cd "$(dirname "$0")"

../../../bpf-sdk/rust/build.sh ../../../examples/bpf-rust-noop
../../../examples/bpf-rust-noop/do.sh build
cp ../../../examples/bpf-rust-noop/target/bpfel-unknown-unknown/release/solana_bpf_rust_noop.so .
Binary file modified web3.js/test/fixtures/noop-rust/solana_bpf_rust_noop.so
Binary file not shown.

0 comments on commit 0a08692

Please sign in to comment.