Merge branch 'fix/link_zlib_with_test' of https://github.com/mriehl/rust-musl-builder

Merge libgit2 support, but heavily overhaul the tests.
This commit is contained in:
Eric Kidd 2018-04-08 13:42:02 -04:00
commit 7b30114420
7 changed files with 70 additions and 5 deletions

15
.travis.yml Normal file
View file

@ -0,0 +1,15 @@
language: rust
services:
- docker
os:
- linux
script:
- bash ./test-image
notifications:
email:
on_success: never
on_failure: always

View file

@ -98,7 +98,9 @@ ENV OPENSSL_DIR=/usr/local/musl/ \
PQ_LIB_STATIC_X86_64_UNKNOWN_LINUX_MUSL=1 \
PG_CONFIG_X86_64_UNKNOWN_LINUX_GNU=/usr/bin/pg_config \
PKG_CONFIG_ALLOW_CROSS=true \
PKG_CONFIG_ALL_STATIC=true
PKG_CONFIG_ALL_STATIC=true \
LIBZ_SYS_STATIC=1 \
TARGET=musl
# (Please feel free to submit pull requests for musl-libc builds of other C
# libraries needed by the most popular and common Rust crates, to avoid

View file

@ -0,0 +1 @@
target

View file

@ -0,0 +1,7 @@
[package]
name = "linking-with-git2"
version = "0.1.0"
authors = ["Eric Kidd <git@randomhacks.net>"]
[dependencies]
git2 = "0.6"

View file

@ -0,0 +1,16 @@
# -*- mode: dockerfile -*-
#
# An example Dockerfile showing how to add new static C libraries using
# musl-gcc.
# Our first FROM statement declares the build environment.
FROM ekidd/rust-musl-builder AS builder
# Add our source code.
ADD . ./
# Fix permissions on source code.
RUN sudo chown -R rust:rust /home/rust
# Build our application.
RUN cargo build

View file

@ -0,0 +1,11 @@
// A useless example application using `git2`, to make sure that we link it
// correctly.
extern crate git2;
use git2::Repository;
fn main() {
let _ = Repository::init("test-repo");
println!("Hello, world!");
}

View file

@ -13,6 +13,8 @@ docker build -t rust-musl-zlib examples/adding-a-library
docker build -t rust-musl-builder-using-diesel examples/using-diesel
docker run --rm rust-musl-builder-using-diesel
echo "==== Verifying static linking"
# Make sure we can build a static executable.
docker run --rm ekidd/rust-musl-builder bash -c "
set -euo pipefail
@ -20,10 +22,6 @@ export USER=rust
cargo new --vcs none --bin testme
cd testme
# Add test cases here
echo -e '\nRunning tests...\n'
echo -e '--- Test case for x86_64:'
cargo build
echo 'ldd says:'
@ -43,5 +41,20 @@ fi
echo -e '[PASS] ARMhf binary is statically linked.\n'
"
# 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
exit 1
fi
echo -e '[PASS] libgit2 binary is statically linked.\n'
"
# We're good.
echo 'OK. ALL TESTS PASSED.' 1>&2