summaryrefslogtreecommitdiffstats
path: root/ci/script.sh
blob: 521150758faa2f5e67171940984d6b53bf18f669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
set -exo pipefail

main() {
    if [ ! -z $COVERAGE ] && [ $TRAVIS_RUST_VERSION = nightly ]; then
        export CARGO_INCREMENTAL=0;
        export RUSTFLAGS="-Zprofile -Ccodegen-units=1";
    fi

    if [[ ! $TARGET =~ .*linux.* ]]; then
        sed -i "s/linux-embedded-hal/#linux-embedded-hal/g" Cargo.toml
        sed -i "s/embedded-hal-mock/#embedded-hal-mock/g" Cargo.toml
    fi

    if [ ! -z $FEATURES ]; then
       export FEATURES="--features $FEATURES"
    fi

    cargo check --target $TARGET $FEATURES
    cargo build --target $TARGET --release $FEATURES
    if [ -z $DISABLE_EXAMPLES ] && [[ $TARGET =~ .*linux.* ]]; then
        cargo build --target $TARGET $FEATURES --examples
    fi

    if [ -z $DISABLE_TESTS ] && [ $TRAVIS_RUST_VERSION = nightly ] && [[ $TARGET =~ .*linux.* ]]; then
        cargo test --target $TARGET $FEATURES
        if [ ! -z $COVERAGE ]; then
            find . -name "*.gc*" -print
            zip -0 ccov.zip `find . \( -name "ads1x1x*.gc*" -o -name "llvmgcov.gc*" \) -print`;
            grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore-dir "/*" > lcov.info;
            bash <(curl -s https://codecov.io/bash) -f lcov.info;
        fi
    fi


}

main