1# Build Configuration for Travis CI
2# https://travis-ci.org
3
4dist: xenial
5sudo: required
6language: cpp
7
8matrix:
9  # Show final status immediately if a test fails.
10  fast_finish: true
11  allow_failures:
12    - env: CHECK_COMMIT_FORMAT=ON
13  include:
14    # Android build.
15    - os: linux
16      compiler: gcc
17      env: VULKAN_BUILD_TARGET=ANDROID ANDROID_TARGET=android-26 ANDROID_ABI=armeabi-v7a
18    # Android 64-bit build.
19    - os: linux
20      compiler: gcc
21      env: VULKAN_BUILD_TARGET=ANDROID ANDROID_TARGET=android-26 ANDROID_ABI=arm64-v8a
22    # Linux GCC debug build.
23    - os: linux
24      compiler: gcc
25      env: VULKAN_BUILD_TARGET=LINUX
26    # Linux clang debug build.
27    - os: linux
28      compiler: clang
29      env: VULKAN_BUILD_TARGET=LINUX
30    # Check for proper clang formatting in the pull request.
31    - env: CHECK_FORMAT=ON
32    # Check for proper commit message formatting for commits in PR
33    - env: CHECK_COMMIT_FORMAT=ON
34
35cache: ccache
36
37# Use set -e so that the build fails when a command fails.
38# The default action for Travis-CI is to continue running even if a command fails.
39# See https://github.com/travis-ci/travis-ci/issues/1066.
40# Use the YAML block scalar header (|) to allow easier multiline script coding.
41
42before_install:
43  - set -e
44  - |
45    if [[ "$VULKAN_BUILD_TARGET" == "LINUX" ]]; then
46      # Install the appropriate Linux packages.
47      sudo apt-get -qq update
48      sudo apt-get -y install libxkbcommon-dev libwayland-dev libmirclient-dev libxrandr-dev \
49                              libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-ewmh-dev \
50                              libxcb-randr0-dev
51    fi
52  - |
53    if [[ "$VULKAN_BUILD_TARGET" == "ANDROID" ]]; then
54      # Install the Android NDK.
55      export ARCH=`uname -m`
56      wget http://dl.google.com/android/repository/android-ndk-r18b-linux-${ARCH}.zip
57      unzip -u -q android-ndk-r18b-linux-${ARCH}.zip
58      export ANDROID_NDK_HOME=`pwd`/android-ndk-r18b
59      export JAVA_HOME="/usr/lib/jvm/java-8-oracle"
60      export PATH="$ANDROID_NDK_HOME:$PATH"
61    fi
62  - |
63    if [[ "$CHECK_FORMAT" == "ON" && "$TRAVIS_PULL_REQUEST" != "false" ]]; then
64      # Install the clang format diff tool, but only for pull requests.
65      curl -L http://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py \
66           -o scripts/clang-format-diff.py;
67    fi
68  # Misc setup
69  - export core_count=$(nproc || echo 4) && echo core_count = $core_count
70  - ccache --zero-stats
71  - set +e
72
73script:
74  - set -e
75  - |
76    if [[ "$VULKAN_BUILD_TARGET" == "LINUX" ]]; then
77      # Build all dependencies for Vulkan-ValidationLayers
78      if [[ "$TRAVIS_EVENT_TYPE" == "cron" ]]; then
79        # Build master branch when triggered by (daily) cron job
80        ${TRAVIS_BUILD_DIR}/scripts/update_deps.py --dir=${TRAVIS_BUILD_DIR}/external --ref=master
81      else
82        ${TRAVIS_BUILD_DIR}/scripts/update_deps.py --dir=${TRAVIS_BUILD_DIR}/external
83      fi
84    fi
85  - |
86    if [[ "$VULKAN_BUILD_TARGET" == "LINUX" ]]; then
87      # Fetch googletest component to build validation layer tests
88      echo Fetching googletest external dependencies for building validation layer tests
89      git clone https://github.com/google/googletest.git ${TRAVIS_BUILD_DIR}/external/googletest
90      pushd ${TRAVIS_BUILD_DIR}/external/googletest
91      git checkout tags/release-1.8.1
92      popd
93    fi
94  - |
95    if [[ "$VULKAN_BUILD_TARGET" == "LINUX" ]]; then
96      # Build Vulkan-ValidationLayers
97      cd ${TRAVIS_BUILD_DIR}
98      mkdir build
99      cd build
100      cmake -C ${TRAVIS_BUILD_DIR}/external/helper.cmake -DCMAKE_BUILD_TYPE=Debug \
101            -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/build/install -DUSE_CCACHE=ON ..
102      cmake --build . --target install -- -j$core_count
103    fi
104  - |
105    if [[ "$VULKAN_BUILD_TARGET" == "LINUX" ]]; then
106      # Build VulkanTools
107      # Note: VulkanTools has a build dependency on Vulkan-ValidationLayers so it must be built after V-VL is built
108      pushd ${TRAVIS_BUILD_DIR}/external/VulkanTools
109      ./update_external_sources.sh
110      mkdir build
111      cd build
112      cmake -DCMAKE_BUILD_TYPE=Debug \
113            -DVULKAN_HEADERS_INSTALL_DIR=${TRAVIS_BUILD_DIR}/external/Vulkan-Headers/build/install \
114            -DVULKAN_LOADER_INSTALL_DIR=${TRAVIS_BUILD_DIR}/external/Vulkan-Loader/build/install \
115            -DVULKAN_VALIDATIONLAYERS_INSTALL_DIR=${TRAVIS_BUILD_DIR}/build/install \
116            ..
117      cmake --build . -- -j $core_count
118      popd
119    fi
120  - |
121    if [[ "$VULKAN_BUILD_TARGET" == "LINUX" ]]; then
122      # Run Tests
123      cd ${TRAVIS_BUILD_DIR}
124      export LD_LIBRARY_PATH=${TRAVIS_BUILD_DIR}/external/Vulkan-Loader/install/lib:${LD_LIBRARY_PATH}
125      export VK_LAYER_PATH=${TRAVIS_BUILD_DIR}/external/VulkanTools/build/layersvt:${TRAVIS_BUILD_DIR}/build/layers
126      export VK_ICD_FILENAMES=${TRAVIS_BUILD_DIR}/external/Vulkan-Tools/build/icd/VkICD_mock_icd.json
127      build/tests/vk_layer_validation_tests
128      for profile in tests/device_profiles/*.json
129      do
130        echo Testing with profile $profile
131        VK_DEVSIM_FILENAME=$profile build/tests/vk_layer_validation_tests --devsim
132      done
133    fi
134  - |
135    if [[ "$VULKAN_BUILD_TARGET" == "ANDROID" ]]; then
136      pushd build-android
137      ./update_external_sources_android.sh --abi $ANDROID_ABI --no-build
138      ./android-generate.sh
139      USE_CCACHE=1 NDK_CCACHE=ccache ndk-build APP_ABI=$ANDROID_ABI -j $core_count
140      popd
141    fi
142  - |
143    if [[ "$CHECK_FORMAT" == "ON" ]]; then
144      if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
145        # Run the clang format check only for pull request builds because the
146        # master branch is needed to do the git diff.
147        echo "Checking clang-format between TRAVIS_BRANCH=$TRAVIS_BRANCH and TRAVIS_PULL_REQUEST_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH"
148        ./scripts/check_code_format.sh
149      else
150        echo "Skipping clang-format check since this is not a pull request."
151      fi
152    fi
153  - |
154    if [[ "$CHECK_COMMIT_FORMAT" == "ON" ]]; then
155      if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
156        echo "Checking commit message formats:  See CONTRIBUTING.md"
157        ./scripts/check_commit_message_format.sh
158      fi
159    fi
160  - ccache --show-stats
161  - set +e
162
163notifications:
164  email:
165    recipients:
166      - karl@lunarg.com
167      - cnorthrop@google.com
168      - tobine@google.com
169      - chrisforbes@google.com
170      - shannon@lunarg.com
171    on_success: change
172    on_failure: always
173