rtic/ci/script.sh

203 lines
6 KiB
Bash
Raw Permalink Normal View History

2017-07-27 22:02:25 +02:00
set -euxo pipefail
2017-04-12 06:12:06 +02:00
2019-01-16 08:21:40 +01:00
arm_example() {
local COMMAND=$1
local EXAMPLE=$2
local BUILD_MODE=$3
local FEATURES=$4
local BUILD_NUM=$5
if [ $BUILD_MODE = "release" ]; then
local RELEASE_FLAG="--release"
else
local RELEASE_FLAG=""
fi
if [ -n "$FEATURES" ]; then
local FEATURES_FLAG="--features $FEATURES"
local FEATURES_STR=${FEATURES/,/_}_
else
local FEATURES_FLAG=""
local FEATURES_STR=""
fi
local CARGO_FLAGS="--example $EXAMPLE --target $TARGET $RELEASE_FLAG $FEATURES_FLAG"
if [ $COMMAND = "run" ]; then
cargo $COMMAND $CARGO_FLAGS | diff -u ci/expected/$EXAMPLE.run -
else
cargo $COMMAND $CARGO_FLAGS
fi
arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ci/builds/${EXAMPLE}_${FEATURES_STR}${BUILD_MODE}_${BUILD_NUM}.hex
2019-01-16 08:21:40 +01:00
}
2017-04-12 06:12:06 +02:00
main() {
2018-11-03 17:02:41 +01:00
local T=$TARGET
2019-02-15 20:16:45 +01:00
local nightly=""
if [ $TRAVIS_RUST_VERSION = nightly ]; then
nightly="nightly"
fi
2018-11-03 17:02:41 +01:00
mkdir -p ci/builds
2018-11-03 17:02:41 +01:00
if [ $T = x86_64-unknown-linux-gnu ]; then
# compile-fail and compile-pass tests
case $TRAVIS_RUST_VERSION in
nightly*)
# TODO how to run a subset of these tests when timer-queue is disabled?
2019-02-15 20:16:45 +01:00
cargo test --features "$nightly,timer-queue" --test compiletest --target $T
esac
2018-11-03 17:02:41 +01:00
cargo check --target $T
if [ $TARGET != thumbv6m-none-eabi ]; then
2019-02-15 20:16:45 +01:00
cargo check --features "$nightly,timer-queue" --target $T
fi
2018-11-03 19:47:28 +01:00
if [ $TRAVIS_RUST_VERSION != nightly ]; then
2018-11-03 19:47:28 +01:00
rm -f .cargo/config
if [ $TARGET != thumbv6m-none-eabi ]; then
cargo doc --features timer-queue
else
cargo doc
fi
2019-02-11 21:40:53 +01:00
( cd book/en && mdbook build )
( cd book/ru && mdbook build )
2018-11-03 19:47:28 +01:00
local td=$(mktemp -d)
cp -r target/doc $td/api
2019-02-11 21:40:53 +01:00
mkdir $td/book
cp -r book/en/book $td/book/en
cp -r book/ru/book $td/book/ru
cp LICENSE-* $td/book/en
cp LICENSE-* $td/book/ru
linkchecker $td/book/en/
linkchecker $td/book/ru/
2018-11-03 19:47:28 +01:00
linkchecker $td/api/rtfm/
linkchecker $td/api/cortex_m_rtfm_macros/
fi
2017-04-12 06:12:06 +02:00
return
fi
2019-02-15 20:16:45 +01:00
cargo check --features "$nightly" --target $T --examples
if [ $TARGET != thumbv6m-none-eabi ]; then
2019-02-15 20:16:45 +01:00
cargo check --features "$nightly,timer-queue" --target $T --examples
fi
2018-11-03 17:02:41 +01:00
# run-pass tests
case $T in
thumbv6m-none-eabi | thumbv7m-none-eabi)
local exs=(
idle
init
interrupt
2019-02-23 22:20:30 +01:00
binds
2018-11-03 17:02:41 +01:00
resource
lock
late
static
task
message
capacity
singleton
types
not-send
not-sync
generics
2018-11-03 17:02:41 +01:00
ramfunc
)
for ex in ${exs[@]}; do
if [ $ex = ramfunc ] && [ $T = thumbv6m-none-eabi ]; then
# LLD doesn't support this at the moment
continue
fi
2019-01-16 08:21:40 +01:00
if [ $ex != types ]; then
2019-02-15 20:16:45 +01:00
arm_example "run" $ex "debug" "$nightly" "1"
arm_example "run" $ex "release" "$nightly" "1"
2019-01-16 08:21:40 +01:00
fi
2019-01-16 08:21:40 +01:00
if [ $TARGET != thumbv6m-none-eabi ]; then
2019-02-15 20:16:45 +01:00
arm_example "run" $ex "debug" "$nightly,timer-queue" "1"
arm_example "run" $ex "release" "$nightly,timer-queue" "1"
2019-01-16 08:21:40 +01:00
fi
done
2019-02-15 20:37:06 +01:00
local built=()
2019-01-16 08:21:40 +01:00
cargo clean
for ex in ${exs[@]}; do
2019-01-17 02:57:54 +01:00
if [ $ex = ramfunc ] && [ $T = thumbv6m-none-eabi ]; then
# LLD doesn't support this at the moment
continue
fi
2019-01-17 02:36:55 +01:00
if [ $ex = singleton ]; then
# singleton build is currently not reproducible due to
# https://github.com/japaric/owned-singleton/issues/2
continue
fi
if [ $ex != types ]; then
2019-02-15 20:16:45 +01:00
arm_example "build" $ex "debug" "$nightly" "2"
2019-02-23 20:35:54 +01:00
cmp ci/builds/${ex}_${nightly/nightly/nightly_}debug_1.hex \
ci/builds/${ex}_${nightly/nightly/nightly_}debug_2.hex
2019-02-15 20:16:45 +01:00
arm_example "build" $ex "release" "$nightly" "2"
2019-02-23 20:35:54 +01:00
cmp ci/builds/${ex}_${nightly/nightly/nightly_}release_1.hex \
ci/builds/${ex}_${nightly/nightly/nightly_}release_2.hex
2019-02-15 20:37:06 +01:00
built+=( $ex )
2018-11-03 17:02:41 +01:00
fi
if [ $TARGET != thumbv6m-none-eabi ]; then
2019-02-15 20:16:45 +01:00
arm_example "build" $ex "debug" "$nightly,timer-queue" "2"
2019-02-23 20:35:54 +01:00
cmp ci/builds/${ex}_${nightly}_timer-queue_debug_1.hex \
ci/builds/${ex}_${nightly}_timer-queue_debug_2.hex
2019-02-15 20:16:45 +01:00
arm_example "build" $ex "release" "$nightly,timer-queue" "2"
2019-02-23 20:35:54 +01:00
cmp ci/builds/${ex}_${nightly}_timer-queue_release_1.hex \
ci/builds/${ex}_${nightly}_timer-queue_release_2.hex
fi
2018-11-03 17:02:41 +01:00
done
2019-02-15 20:37:06 +01:00
( cd target/$TARGET/release/examples/ && size ${built[@]} )
2018-11-03 17:02:41 +01:00
esac
2017-04-12 06:12:06 +02:00
}
2018-11-03 17:02:41 +01:00
# fake Travis variables to be able to run this on a local machine
if [ -z ${TRAVIS_BRANCH-} ]; then
TRAVIS_BRANCH=auto
fi
if [ -z ${TRAVIS_PULL_REQUEST-} ]; then
TRAVIS_PULL_REQUEST=false
fi
if [ -z ${TRAVIS_RUST_VERSION-} ]; then
case $(rustc -V) in
*nightly*)
TRAVIS_RUST_VERSION=nightly
;;
*beta*)
TRAVIS_RUST_VERSION=beta
;;
*)
TRAVIS_RUST_VERSION=stable
;;
esac
fi
2019-02-08 11:54:41 +01:00
if [ -z ${TARGET-} ]; then
TARGET=$(rustc -Vv | grep host | cut -d ' ' -f2)
fi
2018-11-03 17:23:04 +01:00
if [ $TRAVIS_BRANCH != master ] || [ $TRAVIS_PULL_REQUEST != false ]; then
2018-08-27 14:45:43 +02:00
main
fi