solana/web3.js/examples/bpf-rust-noop/do.sh

69 lines
1.2 KiB
Bash
Raw Normal View History

2019-07-16 15:52:22 -07:00
#!/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
}
2019-09-13 12:36:08 -07:00
sdkDir=../../bpf-sdk
targetDir="$PWD"/target
profile=bpfel-unknown-unknown/release
2019-07-16 15:52:22 -07:00
perform_action() {
set -e
case "$1" in
build)
2019-09-13 12:36:08 -07:00
"$sdkDir"/rust/build.sh "$PWD"
so_path="$targetDir/$profile"
so_name="solana_bpf_rust_noop"
if [ -f "$so_path/${so_name}.so" ]; then
cp "$so_path/${so_name}.so" "$so_path/${so_name}_debug.so"
"$sdkDir"/dependencies/llvm-native/bin/llvm-objcopy --strip-all "$so_path/${so_name}.so" "$so_path/$so_name.so"
fi
2019-07-16 15:52:22 -07:00
;;
clean)
2019-09-13 12:36:08 -07:00
"$sdkDir"/rust/clean.sh "$PWD"
2019-07-16 15:52:22 -07:00
;;
test)
2019-09-13 12:36:08 -07:00
echo "test"
cargo +nightly test
2019-07-16 15:52:22 -07:00
;;
clippy)
2019-09-13 12:36:08 -07:00
echo "clippy"
cargo +nightly clippy
2019-07-16 15:52:22 -07:00
;;
fmt)
2019-09-13 12:36:08 -07:00
echo "formatting"
cargo fmt
2019-07-16 15:52:22 -07:00
;;
help)
usage
exit
;;
*)
echo "Error: Unknown command"
usage
exit
;;
esac
}
set -e
perform_action "$1"