Skip to content

Instantly share code, notes, and snippets.

@Nava2
Last active March 3, 2016 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nava2/b50a8bc34f6f06a2fabf to your computer and use it in GitHub Desktop.
Save Nava2/b50a8bc34f6f06a2fabf to your computer and use it in GitHub Desktop.
Vagrant environment *similar* to Travis-CI for linux, but not identical.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# It is recommended to install the vbguest plugin:
# vagrant plugin install vagrant-vbguest
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
def is_trusty
return ENV.has_key?("WITH_TRUSTY") ? true : false
end
def ubuntu_version
trusty = ENV.has_key?("WITH_TRUSTY") ? true : false
return trusty ? "trusty" : "precise"
end
def linux_vm(config)
config.vm.box = "ubuntu/#{ubuntu_version}64"
config.vm.provision "shell", privileged: true, inline: <<-EOF
apt-get update -qq
apt-get install -qq -y python-software-properties
EOF
if !is_trusty
config.vm.provision "shell", privileged: true, inline: <<-EOF
apt-get install -qq -y python-software-properties
EOF
else
config.vm.provision "shell", privileged: true, inline: <<-EOF
apt-get install -qq -y software-properties-common
EOF
end
config.vm.provision "shell", privileged: true, inline: <<-EOF
apt-get install -q -y git vim --no-install-recommends
apt-add-repository -y ppa:ubuntu-toolchain-r/test # Toolchains
apt-get update -qq
apt-get install -y liblua5.1-0-dev libluajit-5.1-dev --no-install-recommends
EOF
if !is_trusty
# Precise
config.vm.provision "shell", privileged: true, inline: <<-EOF
apt-add-repository -y ppa:george-edison55/precise-backports # cmake
EOF
else
# Trusty
config.vm.provision "shell", privileged: true, inline: <<-EOF
apt-add-repository ppa:george-edison55/cmake-3.x -y
EOF
end
# Do an update:
config.vm.provision "shell", privileged:true, inline: <<-EOF
apt-get update -qq
apt-get install bash-completion --reinstall
EOF
# CMake and Ninja
config.vm.provision "shell", privileged:true, inline: <<-EOF
apt-get install -y cmake cmake-data ninja-build --no-install-recommends
EOF
config.vm.provision "shell", privileged:true, inline: <<-EOF
apt-get autoremove --purge -yy -qq
EOF
config.vm.provision :reload
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
# v.gui = true
v.customize ["modifyvm", :id, "--cpuexecutioncap", "85"]
end
# Compilers:
config.vm.define "gcc49", autostart: false do |gcc49|
linux_vm gcc49
cxx_pkgs = ['g++-4.9', 'gcc-4.9']
gcc49.vm.provision "shell", privileged: true, inline: <<-EOF
apt-get install -y #{cxx_pkgs.join(' ')}
echo 'export CXX=#{cxx_pkgs[0]}' >> /etc/bash.bashrc
echo 'export CC=#{cxx_pkgs[1]}' >> /etc/bash.bashrc
EOF
end
config.vm.define "gcc5", autostart: false do |gcc5|
linux_vm gcc5
cxx_pkgs = ['g++-5', 'gcc-5']
gcc5.vm.provision "shell", privileged: true, inline: <<-EOF
apt-get install -y #{cxx_pkgs.join(' ')}
echo 'export CXX=#{cxx_pkgs[0]}' >> /etc/bash.bashrc
echo 'export CC=#{cxx_pkgs[1]}' >> /etc/bash.bashrc
EOF
end
config.vm.define "clang36", autostart: false do |clang36|
linux_vm clang36
clang36.vm.provision "shell", privileged: true, inline: <<-EOF
echo 'deb http://llvm.org/apt/#{ubuntu_version}/ llvm-toolchain-#{ubuntu_version}-3.6 main' >> /etc/apt/sources.list
apt-get update -qq
apt-get install -y clang-3.6 --force-yes
echo 'export CXX=clang++-3.6' >> /etc/bash.bashrc
echo 'export CC=clang-3.6' >> /etc/bash.bashrc
EOF
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment