Add optional deploy of custom programs (#2817)

* Add optional deploy of custom programs

* Review comments
This commit is contained in:
Tyera Eulberg 2019-02-18 11:43:36 -07:00 committed by GitHub
parent 0317583489
commit 760a82cb08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -36,6 +36,7 @@ Operate a configured testnet
(ignored if -s or -S is specified)
-r - Reuse existing node/ledger configuration from a
previous |start| (ie, don't run ./multinode-demo/setup.sh).
-D /path/to/programs - Deploy custom programs from this location
sanity/start/update-specific options:
-o noLedgerVerify - Skip ledger verification
@ -62,12 +63,13 @@ sanityExtraArgs=
cargoFeatures=
skipSetup=false
updateNodes=false
customPrograms=
command=$1
[[ -n $command ]] || usage
shift
while getopts "h?S:s:T:t:o:f:r" opt; do
while getopts "h?S:s:T:t:o:f:r:D:" opt; do
case $opt in
h | \?)
usage
@ -110,6 +112,9 @@ while getopts "h?S:s:T:t:o:f:r" opt; do
r)
skipSetup=true
;;
D)
customPrograms=$OPTARG
;;
o)
case $OPTARG in
noLedgerVerify|noValidatorSanity|rejectExtraNodes)
@ -149,6 +154,9 @@ build() {
$MAYBE_DOCKER bash -c "
set -ex
scripts/cargo-install-all.sh farf \"$cargoFeatures\"
if [[ -n $customPrograms ]]; then
scripts/cargo-install-custom-programs.sh farf $customPrograms
fi
"
)
echo "Build took $SECONDS seconds"

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# This script will install all cargo workspace libraries found in
# `programDir` as native programs.
set -e
# Directory to install libraries into
installDir="$(mkdir -p "$1"; cd "$1"; pwd)"
# Where to find custom programs
programDir="$2"
(
set -x
cd "$programDir"
cargo build --all --release
)
for dir in "$programDir"/*; do
for program in $programDir/target/release/deps/lib"$(basename "$dir")".{so,dylib,dll}; do
if [[ -f $program ]]; then
(
set -x
mkdir -p "$installDir/bin/deps"
rm -f "$installDir/bin/deps/$(basename "$program")"
cp -v "$program" "$installDir"/bin/deps
)
fi
done
done