diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3d79cb9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: rust + +services: + - docker + +os: + - linux + +script: +- bash ./test-image + +notifications: + email: + on_success: never + on_failure: always diff --git a/Dockerfile b/Dockerfile index 1ba2150..493e2cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/examples/linking-with-git2/.dockerignore b/examples/linking-with-git2/.dockerignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/examples/linking-with-git2/.dockerignore @@ -0,0 +1 @@ +target diff --git a/examples/linking-with-git2/Cargo.toml b/examples/linking-with-git2/Cargo.toml new file mode 100644 index 0000000..c5de545 --- /dev/null +++ b/examples/linking-with-git2/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "linking-with-git2" +version = "0.1.0" +authors = ["Eric Kidd "] + +[dependencies] +git2 = "0.6" diff --git a/examples/linking-with-git2/Dockerfile b/examples/linking-with-git2/Dockerfile new file mode 100644 index 0000000..114a594 --- /dev/null +++ b/examples/linking-with-git2/Dockerfile @@ -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 diff --git a/examples/linking-with-git2/src/main.rs b/examples/linking-with-git2/src/main.rs new file mode 100644 index 0000000..5e0561e --- /dev/null +++ b/examples/linking-with-git2/src/main.rs @@ -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!"); +} diff --git a/test-image b/test-image index 378e7ca..19542cc 100755 --- a/test-image +++ b/test-image @@ -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