2016-03-18 03:18:16 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2016-08-07 02:57:44 +00:00
|
|
|
EXAMPLES_DIR="examples"
|
|
|
|
LIB_DIR="lib"
|
2016-09-09 03:38:58 +00:00
|
|
|
CODEGEN_DIR="codegen"
|
2016-09-19 23:24:01 +00:00
|
|
|
CONTRIB_DIR="contrib"
|
2016-03-18 03:18:16 +00:00
|
|
|
|
2016-08-07 03:59:51 +00:00
|
|
|
# Add Cargo to PATH.
|
|
|
|
export PATH=${HOME}/.cargo/bin:${PATH}
|
|
|
|
|
2016-03-18 03:18:16 +00:00
|
|
|
function build_and_test() {
|
|
|
|
local dir=$1
|
|
|
|
if [ -z "${dir}" ] || ! [ -d "${dir}" ]; then
|
|
|
|
echo "Tried to build and test inside '${dir}', but it is an invalid path."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
pushd ${dir}
|
|
|
|
echo ":: Building '${PWD}'..."
|
2016-09-09 03:38:58 +00:00
|
|
|
RUST_BACKTRACE=1 cargo build
|
2016-03-18 03:18:16 +00:00
|
|
|
|
|
|
|
echo ":: Running unit tests in '${PWD}'..."
|
2016-09-09 03:38:58 +00:00
|
|
|
RUST_BACKTRACE=1 cargo test
|
2016-03-18 03:18:16 +00:00
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
build_and_test $LIB_DIR
|
2016-09-09 03:38:58 +00:00
|
|
|
build_and_test $CODEGEN_DIR
|
2016-09-19 23:24:01 +00:00
|
|
|
build_and_test $CONTRIB_DIR
|
2016-03-18 03:18:16 +00:00
|
|
|
|
|
|
|
for file in ${EXAMPLES_DIR}/*; do
|
|
|
|
if [ -d "${file}" ]; then
|
2016-08-07 02:57:44 +00:00
|
|
|
bootstrap_script="${file}/bootstrap.sh"
|
|
|
|
if [ -x "${bootstrap_script}" ]; then
|
|
|
|
echo ":: Bootstrapping ${file}..."
|
|
|
|
|
|
|
|
if ! ./${bootstrap_script}; then
|
|
|
|
echo ":: Running bootstrap script (${bootstrap_script}) failed!"
|
|
|
|
echo ":: Skipping ${file}."
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-03-18 03:18:16 +00:00
|
|
|
build_and_test "${file}"
|
|
|
|
fi
|
|
|
|
done
|