aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/ci/script.sh
blob: 2941e484d4ef7b55a4b87f09915afbcd5e8eb08f (plain) (blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash

set -euxo pipefail

main() {
    cargo check --target "$TARGET"

    cargo check --target "$TARGET" --features device

    # A `critical_section` implementation is always needed.
    needed_features=cortex-m/critical-section-single-core

    if [ "$TARGET" = x86_64-unknown-linux-gnu ] && [ "$TRAVIS_RUST_VERSION" = stable ]; then
        ( cd macros && cargo check && cargo test )

        cargo test --features "device,${needed_features}" --test compiletest
    fi

    local examples=(
        alignment
        divergent-default-handler
        divergent-exception
        entry-static
        main
        minimal
        override-exception
        pre_init
        qemu
        state
        unsafe-default-handler
        unsafe-entry
        unsafe-exception
        unsafe-hard-fault
    )
    local fail_examples=(
        data_overflow
    )
    local linkers=(
        # Link with arm-none-eabi-ld
        "-C linker=arm-none-eabi-ld"
        # Link with arm-none-eabi-gcc, requires -nostartfiles
        "-C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles"
        # Link with rust-lld (default)
        ""
    )
    if [ "$TARGET" != x86_64-unknown-linux-gnu ]; then
        # Only test on stable and nightly, not MSRV.
        if [ "$TRAVIS_RUST_VERSION" = stable ] || [ "$TRAVIS_RUST_VERSION" = nightly ]; then
            RUSTDOCFLAGS="-Cpanic=abort" cargo test --features "${needed_features}" --doc
        fi

        for linker in "${linkers[@]}"; do
            for ex in "${examples[@]}"; do
                cargo rustc --target "$TARGET" --example "$ex" --features "${needed_features}" -- $linker
                cargo rustc --target "$TARGET" --example "$ex" --features "${needed_features}" --release -- $linker
            done
            for ex in "${fail_examples[@]}"; do
                ! cargo rustc --target "$TARGET" --example "$ex" --features "${needed_features}" -- $linker
                ! cargo rustc --target "$TARGET" --example "$ex" --features "${needed_features}" --release -- $linker
            done
            cargo rustc --target "$TARGET" --example device --features "device,${needed_features}" -- $linker
            cargo rustc --target "$TARGET" --example device --features "device,${needed_features}" --release -- $linker

            cargo rustc --target "$TARGET" --example minimal --features "set-sp,${needed_features}" -- $linker
            cargo rustc --target "$TARGET" --example minimal --features "set-sp,${needed_features}" --release -- $linker
            cargo rustc --target "$TARGET" --example minimal --features "set-vtor,${needed_features}" -- $linker
            cargo rustc --target "$TARGET" --example minimal --features "set-vtor,${needed_features}" --release -- $linker
        done
    fi

    case $TARGET in
        thumbv6m-none-eabi|thumbv7m-none-eabi)
            for linker in "${linkers[@]}"; do
                env RUSTFLAGS="$linker -C link-arg=-Tlink.x" cargo run \
                    --target "$TARGET" --features "${needed_features}" --example qemu | grep "x = 42"
                env RUSTFLAGS="$linker -C link-arg=-Tlink.x" cargo run \
                    --target "$TARGET" --features "${needed_features}" --example qemu --release | grep "x = 42"
            done

            ;;
    esac
}

main