Make running scripts more robust.

This commit is contained in:
Sergio Benitez 2016-10-02 01:18:37 -07:00
parent 7dc6e432b8
commit 4a0984891a
2 changed files with 27 additions and 5 deletions

23
scripts/config.sh Executable file
View File

@ -0,0 +1,23 @@
# Simply sets up a few useful variables.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function relative() {
local full_path="${SCRIPT_DIR}/../${1}"
echo $(realpath "${full_path}")
}
EXAMPLES_DIR=$(relative "examples")
LIB_DIR=$(relative "lib")
CODEGEN_DIR=$(relative "codegen")
CONTRIB_DIR=$(relative "contrib")
DOC_DIR=$(relative "target/doc")
if [ "${1}" = "-p" ]; then
echo $SCRIPT_DIR
echo $EXAMPLES_DIR
echo $LIB_DIR
echo $CODEGEN_DIR
echo $CONTRIB_DIR
echo $DOC_DIR
fi

View File

@ -1,10 +1,9 @@
#!/bin/bash
set -e
EXAMPLES_DIR="examples"
LIB_DIR="lib"
CODEGEN_DIR="codegen"
CONTRIB_DIR="contrib"
# Brings in: EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, and CONTRIB_DIR, DOC_DIR
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/config.sh
# Add Cargo to PATH.
export PATH=${HOME}/.cargo/bin:${PATH}
@ -61,7 +60,7 @@ for file in ${EXAMPLES_DIR}/*; do
if [ -x "${bootstrap_script}" ]; then
echo ":: Bootstrapping ${file}..."
if ! ./${bootstrap_script}; then
if ! ${bootstrap_script}; then
echo ":: Running bootstrap script (${bootstrap_script}) failed!"
echo ":: Skipping ${file}."
continue