1#!/usr/bin/env bash 2 3set -e 4 5export TOP=$(pwd) 6 7TOOLCHAIN_URL_arm="https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz" 8TOOLCHAIN_URL_aarch64="https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/aarch64-linux-gnu/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz" 9 10TOOLCHAIN_PREFIX_arm=arm-linux-gnueabihf 11TOOLCHAIN_PREFIX_aarch64=aarch64-linux-gnu 12 13TOOLCHAIN_FILE=${TOP}/toolchain.cmake 14touch ${TOOLCHAIN_FILE} 15BUILD_OPENGL_TEST="OFF" 16 17# Prepare toolchain if needed 18if [[ ${JOB_ARCHITECTURE} != "" ]]; then 19 TOOLCHAIN_URL_VAR=TOOLCHAIN_URL_${JOB_ARCHITECTURE} 20 TOOLCHAIN_URL=${!TOOLCHAIN_URL_VAR} 21 wget ${TOOLCHAIN_URL} 22 TOOLCHAIN_ARCHIVE=${TOOLCHAIN_URL##*/} 23 tar xf ${TOOLCHAIN_ARCHIVE} 24 TOOLCHAIN_DIR=${TOP}/${TOOLCHAIN_ARCHIVE%.tar.xz} 25 export PATH=${TOOLCHAIN_DIR}/bin:${PATH} 26 27 TOOLCHAIN_PREFIX_VAR=TOOLCHAIN_PREFIX_${JOB_ARCHITECTURE} 28 TOOLCHAIN_PREFIX=${!TOOLCHAIN_PREFIX_VAR} 29 30 echo "SET(CMAKE_SYSTEM_NAME Linux)" >> ${TOOLCHAIN_FILE} 31 echo "SET(CMAKE_SYSTEM_PROCESSOR ${JOB_ARCHITECTURE})" >> ${TOOLCHAIN_FILE} 32 echo "SET(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)" >> ${TOOLCHAIN_FILE} 33 echo "SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)" >> ${TOOLCHAIN_FILE} 34 echo "SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> ${TOOLCHAIN_FILE} 35 echo "SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> ${TOOLCHAIN_FILE} 36 echo "SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> ${TOOLCHAIN_FILE} 37fi 38 39if [[ ( ${JOB_ARCHITECTURE} == "" && ${JOB_ENABLE_GL} == "1" ) ]]; then 40 BUILD_OPENGL_TEST="ON" 41 sudo apt-get update 42 sudo apt-get -y install libglu1-mesa-dev freeglut3-dev mesa-common-dev libglew-dev 43fi 44# Prepare headers 45git clone https://github.com/KhronosGroup/OpenCL-Headers.git 46cd OpenCL-Headers 47ln -s CL OpenCL # For OSX builds 48cd .. 49 50# Get and build loader 51git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader.git 52cd ${TOP}/OpenCL-ICD-Loader 53mkdir build 54cd build 55cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} -DOPENCL_ICD_LOADER_HEADERS_DIR=${TOP}/OpenCL-Headers/ .. 56make 57 58# Build CTS 59cd ${TOP} 60ls -l 61mkdir build 62cd build 63cmake -DCL_INCLUDE_DIR=${TOP}/OpenCL-Headers \ 64 -DCL_LIB_DIR=${TOP}/OpenCL-ICD-Loader/build \ 65 -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \ 66 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=./bin \ 67 -DOPENCL_LIBRARIES="-lOpenCL -lpthread" \ 68 -DUSE_CL_EXPERIMENTAL=ON \ 69 -DGL_IS_SUPPORTED=${BUILD_OPENGL_TEST} \ 70 .. 71make -j2 72 73