diff --git a/.travis.yml b/.travis.yml index 34c6163..a982432 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,134 @@ +sudo: false language: rust -os: - - linux - - osx +cache: cargo + +env: + global: + # this will be part of the release tarball + - PROJECT_NAME=colonize + - RUST_BACKTRACE=1 + # override the default '--features unstable' used for the nightly branch + - TRAVIS_CARGO_NIGHTLY_FEATURE="nightly-testing" + # encrypted Github token for doc upload + - secure: "OtcCEFBniy4i89KaFKEOct+JsTQF3W3+6SYWlcB4FEvljRwwpAMWzpqoHQhfNLPQiX07Da+IlKrhM5wt2PPF80dEzyIxiK6Y/fJFgd0peAkbKYwqrgoS80WoqSHYBR8STb+X6JlhxxX+/pma+ILBBFQ6UH01KEHGISlHq4ARw58=" +# the following are necessary for `travis-cargo coveralls --no-sudo` +addons: + apt: + packages: + - libcurl4-openssl-dev + - libelf-dev + - libdw-dev + - binutils-dev # optional: only required for the --verify flag of coveralls + +matrix: + fast_finish: true + allow_failures: + - rust: nightly + include: + # stable channel + - os: osx + rust: stable + env: TARGET=i686-apple-darwin + - os: linux + rust: stable + env: TARGET=i686-unknown-linux-gnu + addons: + apt: + packages: &i686_unknown_linux_gnu + # Cross compiler and cross compiled C libraries + - gcc-multilib + # freetype library + - libfreetype6-dev:i386 + - os: linux + rust: stable + env: TARGET=x86_64-unknown-linux-gnu + # beta channel + - os: osx + rust: beta + env: TARGET=i686-apple-darwin + - os: linux + rust: beta + env: TARGET=i686-unknown-linux-gnu + addons: + apt: + packages: *i686_unknown_linux_gnu + - os: linux + rust: beta + env: TARGET=x86_64-unknown-linux-gnu + # nightly channel + - os: osx + rust: nightly + env: TARGET=i686-apple-darwin + - os: linux + rust: nightly + env: TARGET=i686-unknown-linux-gnu + addons: + apt: + packages: *i686_unknown_linux_gnu + - os: linux + rust: nightly + env: TARGET=x86_64-unknown-linux-gnu + +before_install: + - | + export PATH="$PATH:$HOME/.cargo/bin" + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + brew update && + brew install freetype + fi + install: - - sudo apt-get update - - sudo apt-get install gcc g++ make upx electric-fence libsdl1.2-dev mercurial + - bash ci/install.sh + +before_script: + # load travis-cargo + - | + pip install 'travis-cargo<0.2' --user && + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + export PATH=$HOME/.local/bin/:$PATH + else + export PATH=$HOME/Library/Python/2.7/bin:$PATH + fi + +# the main build script: - - cargo build -v + - bash ci/script.sh + +after_success: + # upload the documentation from the build with stable (automatically only + # actually runs from the master branch, not individual PRs) + - travis-cargo --only stable doc-upload + # measure code coverage and upload to coveralls.io (the verify argument + # mitigates kcov crashes due to malformed debuginfo, at the cost of some + # speed. ) + - travis-cargo coveralls --no-sudo --verify + +before_deploy: + - bash ci/before_deploy.sh + +deploy: + provider: releases + api_key: + # secure Github token for release upload + secure: "OtcCEFBniy4i89KaFKEOct+JsTQF3W3+6SYWlcB4FEvljRwwpAMWzpqoHQhfNLPQiX07Da+IlKrhM5wt2PPF80dEzyIxiK6Y/fJFgd0peAkbKYwqrgoS80WoqSHYBR8STb+X6JlhxxX+/pma+ILBBFQ6UH01KEHGISlHq4ARw58=" + file_glob: true + file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.* + # don't delete the artifacts from previous phases + skip_cleanup: true + on: + # channel to use to produce the release artifacts + condition: $TRAVIS_RUST_VERSION = stable + tags: true + +branches: + only: + - master + - auto + # Ruby regex to match tags. Required to Travis won't trigger deploys when a + # new tag is pushed. This regex matches semantic versions like + # v1.2.3-rc4+2016.02.22 + - /^v\d+\.\d+\.\d+.*$/ + +notifications: + email: + on_success: never diff --git a/README.md b/README.md index ce390b1..d510da3 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,38 @@ -# colonize [![Build Status](https://travis-ci.org/indiv0/colonize.svg?branch=master)](https://travis-ci.org/indiv0/colonize) +# colonize -A Dwarf-Fortress/Rogue-like game written in Rust. + + + + + + + + +
Linux / OS Xtravis-badge
+ api-docs-badge + crates-io + coveralls-badge +
-## Prerequisites +A Dwarf-Fortress/Rimworld-like game written in Rust. + +# Table of Contents + +* [Running Precompiled Binaries](#running-precompiled-binaries) +* [Compiling & Running From Source](#compiling-and-running-from-source) +* [Configuration](#configuration) + +## Running Precompiled Binaries + +Pre-compiled binaries for each of the major targets can be found on the releases +page, [here][latest-release]. + +## Compiling & Running From Source +### Prerequisites * [rust](https://www.rust-lang.org) -* [libtcod](http://roguecentral.org/doryen/libtcod/) -## Compiling +### Compiling Compiling on Rustc stable: @@ -21,7 +46,7 @@ Compiling on Rustc nightly: cargo build --no-default-features --features nightly ``` -## Running +### Running Running on Rustc stable: @@ -47,4 +72,5 @@ the root of this repo as [`colonize.json.example`][colonize-json-example]. In the future, the capability to define the config directory might be added. -[colonize-json-example]: https://github.com/indiv0/colonize/blob/master/colonize.json.example +[colonize-json-example]: https://github.com/indiv0/colonize/blob/master/colonize.json.example "Example configuration" +[latest-release]: https://github.com/indiv0/colonize/releases/latest "Latest release" diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh new file mode 100755 index 0000000..5883d49 --- /dev/null +++ b/ci/before_deploy.sh @@ -0,0 +1,67 @@ +# `before_deploy` phase: here we package the build artifacts + +set -ex + +. $(dirname $0)/utils.sh + +# Generate artifacts for release +mk_artifacts() { + cargo rustc --target $TARGET --release -- -C link_args="-s" -C opt-level=3 +} + +mk_tarball() { + # create a "staging" directory + local td=$(mktempd) + local out_dir=$(pwd) + + # NOTE All Cargo build artifacts will be under the 'target/$TARGET/{debug,release}' + cp target/$TARGET/release/colonize $td + + pushd $td + + # release tarball will look like 'rust-everywhere-v1.2.3-x86_64-unknown-linux-gnu.tar.gz' + tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz * + + popd + rm -r $td +} + +# Package your artifacts in a .deb file +# NOTE right now you can only package binaries using the `dobin` command. Simply call +# `dobin [file..]` to include one or more binaries in your .deb package. I'll add more commands to +# install other things like manpages (`doman`) as the needs arise. +# XXX This .deb packaging is minimal -- just to make your app installable via `dpkg` -- and doesn't +# fully conform to Debian packaging guideliens (`lintian` raises a few warnings/errors) +mk_deb() { + # TODO update this part to package the artifacts that make sense for your project + dobin target/$TARGET/release/colonize +} + +main() { + mk_artifacts + mk_tarball + + if [ $TRAVIS_OS_NAME = linux ]; then + if [ ! -z $MAKE_DEB ]; then + dtd=$(mktempd) + mkdir -p $dtd/debian/usr/bin + + mk_deb + + mkdir -p $dtd/debian/DEBIAN + cat >$dtd/debian/DEBIAN/control <>.cargo/config </dev/null || mktemp -d -t tmp) +} + +host() { + case "$TRAVIS_OS_NAME" in + linux) + echo x86_64-unknown-linux-gnu + ;; + osx) + echo x86_64-apple-darwin + ;; + esac +} + +gcc_prefix() { + case "$TARGET" in + aarch64-unknown-linux-gnu) + echo aarch64-linux-gnu- + ;; + arm*-gnueabihf) + echo arm-linux-gnueabihf- + ;; + *) + return + ;; + esac +} + +dobin() { + [ -z $MAKE_DEB ] && die 'dobin: $MAKE_DEB not set' + [ $# -lt 1 ] && die "dobin: at least one argument needed" + + local f prefix=$(gcc_prefix) + for f in "$@"; do + install -m0755 $f $dtd/debian/usr/bin/ + ${prefix}strip -s $dtd/debian/usr/bin/$(basename $f) + done +} + +architecture() { + case $1 in + x86_64-unknown-linux-gnu|x86_64-unknown-linux-musl) + echo amd64 + ;; + i686-unknown-linux-gnu) + echo i386 + ;; + arm*-unknown-linux-gnueabihf) + echo armhf + ;; + *) + die "architecture: unexpected target $TARGET" + ;; + esac +}