From 2f89688ca974944781878a74873801597c0b1f11 Mon Sep 17 00:00:00 2001 From: Hugo van der Wijst Date: Tue, 15 Jan 2019 22:42:50 -0800 Subject: Make builds reproducible This is done by using `BTreeMap`s and `BTreeSet`s to get deterministic ordering. Also updated the CI job to check reproducibility of all examples. --- ci/script.sh | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'ci') diff --git a/ci/script.sh b/ci/script.sh index 645db3a..ab7f34b 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -81,20 +81,45 @@ main() { continue fi - if [ $ex != types ]; then - cargo run --example $ex --target $T | \ - diff -u ci/expected/$ex.run - + test_arm_example() { + local EXAMPLE=$1 + local TARGET=$2 + local BUILD_MODE=$3 + local FEATURES=$4 + + if [ $BUILD_MODE = "release" ]; then + local RELEASE_FLAG="--release" + else + local RELEASE_FLAG="" + fi + + if [ -n "$FEATURES" ]; then + local FEATURES_FLAG="--features $FEATURES" + else + local FEATURES_FLAG="" + fi + local CARGO_FLAGS="--example $EXAMPLE --target $TARGET $RELEASE_FLAG $FEATURES_FLAG" + + cargo run $CARGO_FLAGS | diff -u ci/expected/$EXAMPLE.run - + arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_1.hex + + # build again to ensure that the build is reproducable + cargo clean + cargo build $CARGO_FLAGS + arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_2.hex + + # compare results of both builds + cmp ${EXAMPLE}_1.hex ${EXAMPLE}_2.hex + } - cargo run --example $ex --target $T --release | \ - diff -u ci/expected/$ex.run - + if [ $ex != types ]; then + test_arm_example $ex $T "debug" "" + test_arm_example $ex $T "release" "" fi if [ $TARGET != thumbv6m-none-eabi ]; then - cargo run --features timer-queue --example $ex --target $T | \ - diff -u ci/expected/$ex.run - - - cargo run --features timer-queue --example $ex --target $T --release | \ - diff -u ci/expected/$ex.run - + test_arm_example $ex $T "debug" "timer-queue" + test_arm_example $ex $T "release" "timer-queue" fi done esac -- cgit v1.2.3