diff --git a/templates/lib/before_deploy.sh b/templates/lib/before_deploy.sh index d6dca4d..a869279 100644 --- a/templates/lib/before_deploy.sh +++ b/templates/lib/before_deploy.sh @@ -6,7 +6,8 @@ set -ex main() { local src=$(pwd) \ - stage= + stage= \ + linking_args= case $TRAVIS_OS_NAME in linux) @@ -19,8 +20,29 @@ main() { test -f Cargo.lock || cargo generate-lockfile - cross rustc --bin $PKG_NAME --target $TARGET --release -- -C lto - cp target/$TARGET/release/$PKG_NAME $stage/ + # TODO: combine with -C lto + case $TYPE in + static) + linking_args="--crate-type staticlib" + ;; + *) + linking_args="--crate-type cdylib" + ;; + esac + + cross rustc --lib --target $TARGET --release -- $linking_args + + 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/travis.yml b/templates/lib/travis.yml index 2aa845e..e363ad2 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