aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/ci/script.sh
blob: bab3dc9640c111606d0e5a3f73852c74a66fc000 (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
85
86
87
88
89
set -euxo pipefail

main() {
    cargo check --target $TARGET

    cargo check --target $TARGET --features device

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

        cargo test --test compiletest
    fi

    local examples=(
        alignment
        divergent-default-handler
        divergent-exception
        entry-static
        main
        minimal
        override-exception
        pre_init
        qemu
        rand
        state
        unsafe-default-handler
        unsafe-entry
        unsafe-exception
        unsafe-hard-fault
    )
    local fail_examples=(
        data_overflow
    )
    if [ $TARGET != x86_64-unknown-linux-gnu ]; then
        # linking with GNU LD
        for ex in "${examples[@]}"; do
            cargo rustc --target $TARGET --example $ex -- \
                  -C linker=arm-none-eabi-ld

            cargo rustc --target $TARGET --example $ex --release -- \
                  -C linker=arm-none-eabi-ld
        done
        for ex in "${fail_examples[@]}"; do
            ! cargo rustc --target $TARGET --example $ex -- \
                  -C linker=arm-none-eabi-ld

            ! cargo rustc --target $TARGET --example $ex --release -- \
                  -C linker=arm-none-eabi-ld
        done

        cargo rustc --target $TARGET --example device --features device -- \
              -C linker=arm-none-eabi-ld

        cargo rustc --target $TARGET --example device --features device --release -- \
              -C linker=arm-none-eabi-ld

        # linking with rustc's LLD
        for ex in "${examples[@]}"; do
            cargo rustc --target $TARGET --example $ex
            cargo rustc --target $TARGET --example $ex --release
        done
        for ex in "${fail_examples[@]}"; do
            ! cargo rustc --target $TARGET --example $ex
            ! cargo rustc --target $TARGET --example $ex --release
        done

        cargo rustc --target $TARGET --example device --features device
        cargo rustc --target $TARGET --example device --features device --release
    fi

    case $TARGET in
        thumbv6m-none-eabi|thumbv7m-none-eabi)
            # linking with GNU LD
            cargo run --target $TARGET --example qemu \
                  -C linker=arm-none-eabi-ld | grep "x = 42"
            cargo run --target $TARGET --example qemu --release \
                  -C linker=arm-none-eabi-ld | grep "x = 42"
            # linking with rustc's LLD
            cargo run --target $TARGET --example qemu | grep "x = 42"
            cargo run --target $TARGET --example qemu --release | grep "x = 42"
            ;;
    esac

    if [ $TARGET = x86_64-unknown-linux-gnu ]; then
        ./check-blobs.sh
    fi
}

main