diff --git a/templates/lib/before_deploy.sh b/templates/lib/before_deploy.sh index d6dca4d..b84b6d1 100644 --- a/templates/lib/before_deploy.sh +++ b/templates/lib/before_deploy.sh @@ -5,22 +5,38 @@ PKG_NAME="{{PKG_NAME}}" set -ex main() { - local src=$(pwd) \ - stage= + local src=$(pwd) stage case $TRAVIS_OS_NAME in - linux) - stage=$(mktemp -d) - ;; - osx) - stage=$(mktemp -d -t tmp) - ;; + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; esac test -f Cargo.lock || cargo generate-lockfile - cross rustc --bin $PKG_NAME --target $TARGET --release -- -C lto - cp target/$TARGET/release/$PKG_NAME $stage/ + if [[ "$TYPE" == "static" ]]; then + cargo crate-type static + else + cargo crate-type dynamic + fi + + cross rustc --lib --target $TARGET --release -- -C lto + + case $TYPE-$TRAVIS_OS_NAME in + static-*) + cp target/$TARGET/release/lib$PKG_NAME.a $stage/ + ;; + *-osx) + cp target/$TARGET/release/lib$PKG_NAME.dylib $stage/ + ;; + *) + cp target/$TARGET/release/lib$PKG_NAME.so $stage/ + ;; + esac cd $stage tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * diff --git a/templates/lib/install.sh b/templates/lib/install.sh index a5e8415..4ae5759 100644 --- a/templates/lib/install.sh +++ b/templates/lib/install.sh @@ -38,6 +38,9 @@ main() { # Install test dependencies rustup component add rustfmt-preview rustup component add clippy-preview + + # For defining the type of lib to produce: dynamic OR static + cargo install --force cargo-crate-type } main diff --git a/templates/lib/travis.yml b/templates/lib/travis.yml index 9d15fba..3ac23b1 100644 --- a/templates/lib/travis.yml +++ b/templates/lib/travis.yml @@ -12,7 +12,7 @@ matrix: include: - env: TARGET=armv7-unknown-linux-gnueabihf rust: nightly - - env: TARGET=x86_64-unknown-linux-musl + - env: TARGET=x86_64-unknown-linux-musl TYPE=static rust: nightly - env: TARGET=x86_64-apple-darwin rust: nightly