-
Notifications
You must be signed in to change notification settings - Fork 391
/
Copy pathscript.sh
183 lines (141 loc) · 3.97 KB
/
script.sh
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
set -ex
main() {
local td=
if [ "$TRAVIS_OS_NAME" = linux ]; then
./build-docker-image.sh $TARGET
fi
if [ "$TRAVIS_BRANCH" = master ] || [ ! -z "$TRAVIS_TAG" ]; then
return
fi
cargo install --force --path .
export QEMU_STRACE=1
# test `cross check`
if [ ! -z $STD ]; then
td=$(mktemp -d)
cargo init --lib --name foo $td
pushd $td
echo '#![no_std]' > src/lib.rs
cross check --target $TARGET
popd
rm -rf $td
fi
# `cross run` test for thumb targets
case $TARGET in
thumb*-none-eabi*)
td=$(mktemp -d)
git clone \
--depth 1 \
--recursive \
https://github.com/japaric/cortest $td
pushd $td
cross run --target $TARGET --example hello --release
popd
rm -rf $td
;;
esac
# `cross build` test for targets where `std` is not available
if [ -z "$STD" ]; then
td=$(mktemp -d)
git clone \
--depth 1 \
--recursive \
https://github.com/rust-lang-nursery/compiler-builtins $td
pushd $td
cat > Cross.toml <<EOF
[build]
xargo = true
EOF
cross build --features c --lib --target $TARGET
popd
rm -rf $td
return
fi
# `cross build` test for the other targets
if [ $OPENSSL ]; then
td=$(mktemp -d)
git clone --depth 1 https://github.com/rust-lang/cargo $td
pushd $td
cross build --target $TARGET
popd
rm -rf $td
elif [ "$TARGET" = "asmjs-unknown-emscripten" -o \
"$TARGET" = "wasm32-unknown-emscripten" ]; then
td=$(mktemp -d)
git clone --depth 1 https://github.com/bluss/rust-itertools $td
pushd $td
cross build --target $TARGET
popd
rm -rf $td
else
td=$(mktemp -d)
git clone --depth 1 https://github.com/japaric/xargo $td
pushd $td
cross build --target $TARGET
popd
rm -rf $td
fi
if [ $RUN ]; then
# `cross test` test
if [ $DYLIB ]; then
td=$(mktemp -d)
git clone \
--depth 1 \
--recursive \
https://github.com/rust-lang-nursery/compiler-builtins \
$td
pushd $td
cross test \
--no-default-features \
--features "gen-tests mangled-names" \
--target $TARGET
popd
rm -rf $td
fi
# `cross run` test
td=$(mktemp -d)
cargo init --bin --name hello $td
pushd $td
mkdir examples tests
echo "fn main() { println!(\"Example!\"); }" > examples/e.rs
echo "#[test] fn t() {}" > tests/t.rs
cross run --target $TARGET
cross run --target $TARGET --example e
cross test --target $TARGET
popd
rm -rf $td
fi
# Test C++ support
if [ $CPP ]; then
td=$(mktemp -d)
git clone --depth 1 https://github.com/japaric/hellopp $td
pushd $td
cargo update -p gcc
if [ $RUN ]; then
cross run --target $TARGET
else
cross build --target $TARGET
fi
popd
rm -rf $td
fi
# Test openssl compatibility
if [ $OPENSSL ]; then
td=$(mktemp -d)
# If tag name v$OPENSSL fails we try openssl-sys-v$OPENSSL
git clone \
--depth 1 \
--branch v$OPENSSL \
https://github.com/sfackler/rust-openssl $td || \
git clone \
--depth 1 \
--branch openssl-sys-v$OPENSSL \
https://github.com/sfackler/rust-openssl $td
pushd $td
# avoid problems building openssl-sys in a virtual workspace
rm -f Cargo.toml
cd openssl-sys && cross build --target $TARGET
popd
rm -rf $td
fi
}
main