summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-02-14 17:56:37 +0800
committerErik Larkö <erik@mullvad.net>2017-02-14 17:57:43 +0800
commit34d295949afff7eb04650d3467d3c23457668125 (patch)
treeab62f7ababbc945cd07285d6ef270d2371893711
parent64e6704a7e1c47b71ce4e1312379df06c785eebb (diff)
downloadmullvadvpn-34d295949afff7eb04650d3467d3c23457668125.tar.xz
mullvadvpn-34d295949afff7eb04650d3467d3c23457668125.zip
Build ZMQ on travis
-rw-r--r--.travis.yml20
-rwxr-xr-xbuild-deps/install-build-deps-osx.sh8
-rwxr-xr-xbuild-deps/install-build-deps-ubuntu.sh43
-rwxr-xr-xbuild-deps/zmq/build-for-linux-with-apt.sh36
4 files changed, 105 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml
index ffc6f13c21..914cd01baf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,11 @@
language: rust
-cache: cargo
+cache:
+ cargo: true
+ directories:
+ - $HOME/Library/Caches/Homebrew
+ - $HOME/build-deps-linux
+ - $HOME/build-deps-osx
+
rust:
- stable
- nightly
@@ -7,15 +13,25 @@ os:
- linux
- osx
+sudo: required
+
before_script:
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then $(./build-deps/install-build-deps-ubuntu.sh $HOME/build-deps-linux) ; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then $(./build-deps/install-build-deps-osx.sh $HOME/build-deps-osx) ; fi
- (cargo install rustfmt || true)
- export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
- rustfmt --version
+ - env
script:
+ ## zmq-sys caches the location of `libzmq`, if that location ever changes e.g.
+ ## if the version changes we will get into trouble. This rm will make us
+ ## rebuild it every time instead
+ - rm -rf target/debug/build/zmq*
+
- cargo build --verbose
- cargo test --all --verbose
- - find src/ tests/ benches/ talpid_* -iname "*.rs" -print0 | xargs -0 -n1 rustfmt --write-mode=diff
+ - find src/ tests/ benches/ -iname "*.rs" -print0 | xargs -0 -n1 rustfmt --write-mode=diff
notifications:
email:
diff --git a/build-deps/install-build-deps-osx.sh b/build-deps/install-build-deps-osx.sh
new file mode 100755
index 0000000000..bd0a0e0cbe
--- /dev/null
+++ b/build-deps/install-build-deps-osx.sh
@@ -0,0 +1,8 @@
+#! /usr/bin/env bash
+set -e
+
+## Everything printed to stdout will be run by travis. So only print
+## stuff that needs to be set, e.g. environment variables.
+
+brew update > /dev/stderr
+brew install czmq > /dev/stderr
diff --git a/build-deps/install-build-deps-ubuntu.sh b/build-deps/install-build-deps-ubuntu.sh
new file mode 100755
index 0000000000..f7f891ef11
--- /dev/null
+++ b/build-deps/install-build-deps-ubuntu.sh
@@ -0,0 +1,43 @@
+#! /usr/bin/env bash
+set -eu
+
+## Everything printed to stdout will be run by travis. So only print
+## stuff that needs to be set, e.g. environment variables.
+
+USE_CACHE=${USE_CACHE:-"1"}
+SCRIPT_DIR=$(readlink -f $(dirname $0))
+INSTALL_DIR=$(readlink -f ${1:-"$SCRIPT_DIR"})
+
+################################################################################
+################################## ZMQ #########################################
+
+### TEST IF ZMQ IS BUILT ###
+F1=$INSTALL_DIR/zmq/linux/include/zmq.h
+F2=$INSTALL_DIR/zmq/linux/lib/libzmq.so
+if [[ -f $F1 && -f $F2 ]]; then
+ ZMQ_IS_BUILT=1
+else
+ ZMQ_IS_BUILT=0
+fi
+
+if [[ $USE_CACHE == 1 && $ZMQ_IS_BUILT == 1 ]]; then
+ >&2 echo "Using a cached version of ZeroMQ"
+else
+ >&2 echo "Building ZeroMQ"
+ >&2 echo ""
+ (
+ $(dirname $0)/zmq/build-for-linux-with-apt.sh
+ ) > stderr
+
+ if [[ "$SCRIPT_DIR" != "$INSTALL_DIR" ]]; then
+ mkdir -p $INSTALL_DIR/zmq/linux
+ sudo mv ${SCRIPT_DIR}/zmq/linux/* $INSTALL_DIR/zmq/linux/
+ fi
+fi
+
+>&2 echo "# deps installed, now run"
+echo "export LIBZMQ_PREFIX=$INSTALL_DIR/zmq/linux" | tee /dev/stderr
+echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_DIR/zmq/linux/lib" | tee /dev/stderr
+
+################################## ZMQ #########################################
+################################################################################
diff --git a/build-deps/zmq/build-for-linux-with-apt.sh b/build-deps/zmq/build-for-linux-with-apt.sh
new file mode 100755
index 0000000000..ad009a37ac
--- /dev/null
+++ b/build-deps/zmq/build-for-linux-with-apt.sh
@@ -0,0 +1,36 @@
+#! /usr/bin/env bash
+set -eu
+
+WD=$(pwd)/$(dirname $0)
+GIT_DIR=libzmq-git
+INSTALL_DIR=linux
+
+### Install build deps ###
+sudo apt-get update
+sudo apt-get -y install git build-essential libtool autoconf automake uuid-dev pkg-config
+
+### Get the code ###
+if [ -e "$WD/$GIT_DIR/.git" ]; then
+ cd "$WD/$GIT_DIR"
+ git fetch
+ git checkout origin/master
+ cd -
+else
+ git clone --depth=1 git@github.com:zeromq/zeromq4-1.git "$WD/$GIT_DIR"
+fi
+
+### Build ###
+## We skip running the tests here as we trust the zmq maintainers to publish
+## working code :) Living life on the wild side
+trap "cd -" EXIT
+cd "$WD/$GIT_DIR"
+
+set -x
+./autogen.sh
+./configure --prefix="$WD/$INSTALL_DIR" # add other options here
+make
+sudo make install
+sudo ldconfig
+set +x
+
+echo "WOOWZ, it's built now. All the good stuff is in $WD/$INSTALL_DIR"