2016-04-17 11:41:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Make bash fail much more aggressively on errors.
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Make sure we can build our main container.
|
|
|
|
docker build -t ekidd/rust-musl-builder .
|
|
|
|
|
|
|
|
# Make sure we can build our example derived container.
|
2017-10-24 12:40:12 +00:00
|
|
|
docker build -t rust-musl-zlib examples/adding-a-library
|
2016-04-17 11:41:55 +00:00
|
|
|
|
2017-10-13 11:13:10 +00:00
|
|
|
# Make sure we can build a multi-stage container.
|
2017-10-24 12:40:12 +00:00
|
|
|
docker build -t rust-musl-builder-using-diesel examples/using-diesel
|
|
|
|
docker run --rm rust-musl-builder-using-diesel
|
2017-10-13 11:13:10 +00:00
|
|
|
|
2018-04-08 17:42:02 +00:00
|
|
|
echo "==== Verifying static linking"
|
|
|
|
|
2016-04-17 11:41:55 +00:00
|
|
|
# Make sure we can build a static executable.
|
|
|
|
docker run --rm ekidd/rust-musl-builder bash -c "
|
|
|
|
set -euo pipefail
|
|
|
|
export USER=rust
|
2016-09-12 10:43:11 +00:00
|
|
|
cargo new --vcs none --bin testme
|
|
|
|
cd testme
|
2018-03-27 12:27:15 +00:00
|
|
|
|
|
|
|
echo -e '--- Test case for x86_64:'
|
2016-04-17 11:41:55 +00:00
|
|
|
cargo build
|
2018-03-27 12:27:15 +00:00
|
|
|
echo 'ldd says:'
|
2016-09-12 10:43:11 +00:00
|
|
|
if ldd target/x86_64-unknown-linux-musl/debug/testme; then
|
2018-03-27 12:27:15 +00:00
|
|
|
echo '[FAIL] Executable is not static!' 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo -e '[PASS] x86_64 binary is statically linked.\n'
|
|
|
|
|
|
|
|
echo -e '--- Test case for ARMhf:'
|
|
|
|
cargo build --target=armv7-unknown-linux-musleabihf
|
|
|
|
echo 'ldd says:'
|
|
|
|
if ldd target/armv7-unknown-linux-musleabihf/debug/testme; then
|
|
|
|
echo '[FAIL] Executable is not static!' 1>&2
|
2016-04-17 11:41:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-03-27 12:27:15 +00:00
|
|
|
echo -e '[PASS] ARMhf binary is statically linked.\n'
|
2016-04-17 11:41:55 +00:00
|
|
|
"
|
|
|
|
|
2018-04-08 17:42:02 +00:00
|
|
|
# Make sure we can build a static executable using `git2`.
|
|
|
|
docker build -t rust-musl-builder-linking-with-git2 examples/linking-with-git2
|
|
|
|
docker run --rm rust-musl-builder-linking-with-git2 bash -c "
|
|
|
|
set -euo pipefail
|
|
|
|
cd /home/rust/src
|
|
|
|
|
|
|
|
echo -e '--- Test case for libgit2:'
|
|
|
|
echo 'ldd says:'
|
|
|
|
if ldd target/x86_64-unknown-linux-musl/debug/linking-with-git2; then
|
|
|
|
echo '[FAIL] Executable is not static!' 1>&2
|
2016-04-17 11:41:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-04-08 17:42:02 +00:00
|
|
|
echo -e '[PASS] libgit2 binary is statically linked.\n'
|
2016-04-17 11:41:55 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
# We're good.
|
2018-03-27 12:27:15 +00:00
|
|
|
echo 'OK. ALL TESTS PASSED.' 1>&2
|