Skip to content

Commit

Permalink
More travis run speedups
Browse files Browse the repository at this point in the history
- Using clang instead of gcc; compiles faster and with less memory,
meaning we can build in parallel.
- Caching more stuff so startup is faster. In particular, the Rust
toolchain.
- Using the ninja build tool which tends to be faster than Make.
  • Loading branch information
Valloric committed Feb 2, 2016
1 parent f3d01e1 commit facc8f1
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 18 deletions.
27 changes: 20 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ env:
global:
- MONO_THREADS_PER_CPU=2000
- MONO_MANAGED_WATCHER=disabled
# Travis can run out of RAM when compiling if we don't prevent parallelization.
- YCM_CORES=1
# Travis can run out of RAM, so we need to be careful here.
- YCM_CORES=3
matrix:
# Don't forget to take the below matrix exclusions into account.
- USE_CLANG_COMPLETER=true YCMD_PYTHON_VERSION=2.7
Expand All @@ -36,18 +36,31 @@ matrix:
- os: linux
env: USE_CLANG_COMPLETER=true YCMD_PYTHON_VERSION=2.7
addons:
# If this doesn't make much sense to you, see the travis docs:
# https://docs.travis-ci.com/user/migrating-from-legacy/
apt:
sources:
- ubuntu-toolchain-r-test
- deadsnakes
# The Travis apt source whitelist can be found here:
# https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
- ubuntu-toolchain-r-test # for new libstdc++
- llvm-toolchain-precise-3.7 # for clang
- deadsnakes # for various versions of python
- kalakris-cmake # for a more recent version of cmake (needed for ninja-build)
packages:
- g++-4.8
- cmake
- clang-3.7
- ninja-build
- python2.6
- python2.6-dev
- python2.7
- python2.7-dev
- python-virtualenv
cache:
directories:
- $HOME/.cache/pip
- $HOME/.dnx/packages
- $HOME/.cache/pip # Python packages from pip
- $HOME/.dnx/packages # .Net packages?
- $HOME/multirust # multirust itself
- $HOME/.multirust # what multirust downloads
- $HOME/.cargo # cargo package deps
- $HOME/clang_archives # clang downloads
- $HOME/racerd/target/release # compilation output
22 changes: 20 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os.path as p
import sys
import shlex
import distutils.dir_util

major, minor = sys.version_info[ 0 : 2 ]
if major != 2 or minor < 6:
Expand Down Expand Up @@ -172,9 +173,10 @@ def GetGenerator( args ):
if ( not args.arch and platform.architecture()[ 0 ] == '64bit'
or args.arch == 64 ):
generator = generator + ' Win64'

return generator

if PathToFirstExistingExecutable( ['ninja'] ):
return 'Ninja'
return 'Unix Makefiles'


Expand Down Expand Up @@ -298,9 +300,25 @@ def BuildRacerd():
if not FindExecutable( 'cargo' ):
sys.exit( 'cargo is required for the rust completer' )

os.chdir( p.join( DIR_OF_THIRD_PARTY, 'racerd' ) )
# Building the dependencies of racerd takes a while, so for Travis, we copy
# the racerd source dir to ~/racerd (outside the repo) and build there. Then
# copy back. Having the dep build products outside the repo makes it possible
# to cache them (see .travis.yml).

orig_racerd_dir = p.join( DIR_OF_THIRD_PARTY, 'racerd' )
build_racerd_dir = orig_racerd_dir
if OnTravisOrAppVeyor():
cached_racerd_dir = os.path.expanduser( os.path.join( '~', 'racerd' ) )
distutils.dir_util.copy_tree( orig_racerd_dir, cached_racerd_dir )
build_racerd_dir = cached_racerd_dir

os.chdir( build_racerd_dir )
print( 'Compiling racerd in: ', build_racerd_dir )
subprocess.check_call( [ 'cargo', 'build', '--release' ] )

if OnTravisOrAppVeyor():
distutils.dir_util.copy_tree( cached_racerd_dir, orig_racerd_dir )


def SetUpTern():
paths = {}
Expand Down
14 changes: 10 additions & 4 deletions ci/travis/travis_install.linux.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Linux-specific installation

# We can't use sudo, so we have to approximate the behaviour of the following:
# $ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90
# $ sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.7 100

mkdir ${HOME}/bin

ln -s /usr/bin/g++-4.8 ${HOME}/bin/g++
ln -s /usr/bin/gcc-4.8 ${HOME}/bin/gcc
ln -s ${HOME}/bin/g++ ${HOME}/bin/c++
ln -s /usr/bin/clang++-3.7 ${HOME}/bin/clang++
ln -s /usr/bin/clang-3.7 ${HOME}/bin/clang

ln -s /usr/bin/clang++-3.7 ${HOME}/bin/c++
ln -s /usr/bin/clang-3.7 ${HOME}/bin/cc

# These shouldn't be necessary, but just in case.
ln -s /usr/bin/clang++-3.7 ${HOME}/bin/g++
ln -s /usr/bin/clang-3.7 ${HOME}/bin/gcc

export PATH=${HOME}/bin:${PATH}

Expand Down
1 change: 1 addition & 0 deletions ci/travis/travis_install.osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
brew update || brew update
brew install node.js || brew outdated node.js || brew upgrade node.js
brew install go || brew outdated go || brew upgrade go
brew install ninja

# OS X comes with 2 versions of python by default, and a neat system
# (versioner) to switch between them:
Expand Down
16 changes: 11 additions & 5 deletions ci/travis/travis_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ fi

# Need rust available, but travis doesn't give it to you without language: rust
pushd ${HOME}
git clone --recursive https://github.com/brson/multirust
cd multirust
git reset --hard f3974f2b966476ad656afba311b50a9c23fe6d2e
./build.sh
./install.sh --prefix=${HOME}
# Multirust might already exist if cached; see bottom of travis.yml
if [ ! -f "$HOME/multirust/blastoff.sh" ]; then
git clone --recursive https://github.com/brson/multirust
cd multirust
git reset --hard f3974f2b966476ad656afba311b50a9c23fe6d2e
./build.sh
./install.sh --prefix=${HOME}
else
cd multirust
./install.sh --prefix=${HOME}
fi
popd

multirust update stable
Expand Down

0 comments on commit facc8f1

Please sign in to comment.