Reputation: 3334
I have a matrix in travis for different builds. The ideas is to use a CLANG_SRC_VER variable. This variable is set through a travis matrix and in the before_install part, I launch a script which install package based on the value of the variable CLANG_SRC_VER.
The travis.yml looks like this:
matrix:
include:
- os: linux
dist: trusty
sudo: required
rvm: 2.1
env:
- CLANG_SRC_VER='35'
...
- os: linux
dist: trusty
sudo: required
rvm: ruby-head
env:
- CLANG_SRC_VER='35'
- os: linux
dist: trusty
sudo: required
rvm: 2.1
env:
- CLANG_SRC_VER='37'
- os: linux
dist: trusty
sudo: required
rvm: 2.2
env:
- CLANG_SRC_VER='37'
...
- os: linux
dist: trusty
sudo: required
rvm: 2.1
env:
- CLANG_SRC_VER='36'
- os: linux
dist: trusty
sudo: required
rvm: 2.2
env:
- CLANG_SRC_VER='36'
...
before_install:
- sudo ./tools/travis_before_install.sh
- gem install bundler
script:
- bundle exec tools/travis_build_gem.sh
- bundle exec gem install --debug --verbose --local clangc-0.0.1.gem
- ./tools/travis_run_tests.sh
And the travis_before_install.sh looks like that:
#!/bin/bash
case $CLANG_SRC_VER in
35)
echo "$CLANG_SRC_VER"
apt-get update -qq
echo "install the libs for $CLANG_SRC_VER"
apt-get install -qq llvm-dev libclang-3.5-dev libclang1-3.5 libclang-common-3.5-dev build-essential ruby-dev
echo "add symbolic link for $CLANG_SRC_VER"
ln -s /usr/lib/x86_64-linux-gnu/libclang-3.5.so /usr/lib/x86_64-linux-gnu/libclang.so;;
36)
echo "${CLANG_SRC_VER}"
apt-get update -qq
echo "install the libs for $CLANG_SRC_VER"
apt-get install -qq llvm-dev libclang-3.6-dev libclang1-3.6 libclang-common-3.6-dev build-essential ruby-dev
echo "add symbolic link for $CLANG_SRC_VER"
ln -s /usr/lib/x86_64-linux-gnu/libclang-3.6.so /usr/lib/x86_64-linux-gnu/libclang.so;;
37)
echo "$CLANG_SRC_VER"
apt-get update -qq
echo "install the libs for $CLANG_SRC_VER"
apt-get install -qq llvm-dev libclang-3.7-dev libclang1-3.7 libclang-common-3.7-dev build-essential ruby-dev
echo "add symbolic link for $CLANG_SRC_VER"
ln -s /usr/lib/x86_64-linux-gnu/libclang-3.7.so /usr/lib/x86_64-linux-gnu/libclang.so;;
38)
echo "$CLANG_SRC_VER"
apt-get update -qq
echo "install the libs for $CLANG_SRC_VER"
apt-get install -qq llvm-dev libclang-3.8-dev libclang1-3.8 libclang-common-3.8-dev build-essential ruby-dev
echo "add symbolic link for $CLANG_SRC_VER"
ln -s /usr/lib/x86_64-linux-gnu/libclang-3.8.so /usr/lib/x86_64-linux-gnu/libclang.so;;
*)
echo "$CLANG_SRC_VER"
apt-get update -qq
echo "install the libs for $CLANG_SRC_VER"
apt-get install -qq llvm-dev libclang-3.5-dev libclang1-3.5 libclang-common-3.5-dev build-essential ruby-dev
echo "add symbolic link for $CLANG_SRC_VER"
ln -s /usr/lib/x86_64-linux-gnu/libclang-3.5.so /usr/lib/x86_64-linux-gnu/libclang.so;;
esac
The problem is that in each case of the matrix, the CLANG_SRC_VER is empty. I have checked the travis ouput and I have that line that shows that the variable is set and exported:
Setting environment variables from .travis.yml
$ export CLANG_SRC_VER='37'
Upvotes: 0
Views: 602
Reputation: 3334
It was easy, in the travis.yml I just changed this line:
sudo ./tools/travis_before_install.sh
to
sudo CLANG_SRC_VER=$CLANG_SRC_VER ./tools/travis_before_install.sh
In order to define the variable in the sudo environment.
Upvotes: 0