2016-03-18 03:18:16 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2016-10-02 08:18:37 +00:00
|
|
|
# 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
|
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-09-30 03:50:06 +00:00
|
|
|
# Builds and tests the Cargo project at $1
|
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-10-12 07:14:42 +00:00
|
|
|
RUST_BACKTRACE=1 cargo build --all-features
|
2016-03-18 03:18:16 +00:00
|
|
|
|
|
|
|
echo ":: Running unit tests in '${PWD}'..."
|
2016-10-12 07:14:42 +00:00
|
|
|
RUST_BACKTRACE=1 cargo test --all-features
|
2016-03-18 03:18:16 +00:00
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
2016-09-30 03:50:06 +00:00
|
|
|
# Checks that the versions for Cargo projects $@ all match
|
|
|
|
function check_versions_match() {
|
|
|
|
local last_version=""
|
|
|
|
for dir in $@; do
|
|
|
|
local cargo_toml="${dir}/Cargo.toml"
|
|
|
|
if ! [ -f "${cargo_toml}" ]; then
|
|
|
|
echo "Cargo configuration file '${cargo_toml}' does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
local version=$(grep version ${cargo_toml} | head -n 1 | cut -d' ' -f3)
|
|
|
|
if [ -z "${last_version}" ]; then
|
|
|
|
last_version="${version}"
|
|
|
|
elif ! [ "${version}" = "${last_version}" ]; then
|
|
|
|
echo "Versions differ in '${cargo_toml}'. ${version} != ${last_version}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-09-30 22:39:55 +00:00
|
|
|
# Update dependencies first.
|
|
|
|
cargo update
|
|
|
|
|
2016-09-30 03:50:06 +00:00
|
|
|
build_and_test "${LIB_DIR}"
|
|
|
|
build_and_test "${CODEGEN_DIR}"
|
|
|
|
build_and_test "${CONTRIB_DIR}"
|
|
|
|
|
|
|
|
check_versions_match "${LIB_DIR}" "${CODEGEN_DIR}" "${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}..."
|
|
|
|
|
2016-10-02 08:18:37 +00:00
|
|
|
if ! ${bootstrap_script}; then
|
2016-08-07 02:57:44 +00:00
|
|
|
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
|