From 0e79399f1a42ff2f97990b98de8500cf6cbf653e Mon Sep 17 00:00:00 2001 From: Kurt Chen Date: Thu, 21 Mar 2019 16:34:16 +0300 Subject: [PATCH] [Buildbot] Add scripts for build steps The scripts will be called by Buildbot on corresponding steps. Signed-off-by: Kurt Chen --- buildbot/README.md | 37 +++++++++++++++++++++++++++++ buildbot/check.sh | 36 ++++++++++++++++++++++++++++ buildbot/clang-tidy.sh | 50 +++++++++++++++++++++++++++++++++++++++ buildbot/compile.sh | 29 +++++++++++++++++++++++ buildbot/configure.sh | 32 +++++++++++++++++++++++++ buildbot/dependency.sh | 53 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 237 insertions(+) create mode 100644 buildbot/README.md create mode 100755 buildbot/check.sh create mode 100755 buildbot/clang-tidy.sh create mode 100755 buildbot/compile.sh create mode 100755 buildbot/configure.sh create mode 100755 buildbot/dependency.sh diff --git a/buildbot/README.md b/buildbot/README.md new file mode 100644 index 0000000000000..930528c5867fb --- /dev/null +++ b/buildbot/README.md @@ -0,0 +1,37 @@ +# Scripts for build steps on Buildbot + +## Purpose + +The purpose of the script is for developer to customize build command for the builder on Buildbot. + +## How it works + +The scripts will be run by Buildbot at corresponding build step, for example, the "compile" step will run "compile.sh". Developer can change the build command, then the builder (e.g. pull request builder) will use the changed command to do the build. + +## Arguments for the scripts + +Common + +* -b BRANCH: the branch name to build +* -n BUILD\_NUMBER: the Buildbot build number (the build count of one builder, which will be in the url of one specific build) +* -r PR\_NUMBER: if it's a pull request build, this will be the pull request number + +LIT Test (check.sh) + +* -t TESTCASE: the LIT testing target, e.g. check-sycl + +## Assumptions + +The Buildbot worker directory structure is: + + /path/to/WORKER_ROOT/BUILDER/ + llvm.src --> source code + llvm.obj --> build directory + +Initial working directory of the scripts: + +* dependency.sh : llvm.obj +* configure.sh : llvm.obj +* compile.sh : llvm.obj +* clang-tidy.sh : llvm.src +* check.sh : llvm.obj diff --git a/buildbot/check.sh b/buildbot/check.sh new file mode 100755 index 0000000000000..55d3057b4e39a --- /dev/null +++ b/buildbot/check.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +BRANCH= +BUILD_NUMBER= +PR_NUMBER= +TESTCASE= + +# $1 exit code +# $2 error message +exit_if_err() +{ + if [ $1 -ne 0 ]; then + echo "Error: $2" + exit $1 + fi +} + +unset OPTIND +while getopts ":b:r:n:t:" option; do + case $option in + b) BRANCH=$OPTARG ;; + n) BUILD_NUMBER=$OPTARG ;; + r) PR_NUMBER=$OPTARG ;; + t) TESTCASE=$OPTARG ;; + esac +done && shift $(($OPTIND - 1)) + +# we're in llvm.obj dir +BUILD_DIR=${PWD} + +if [ -z "${TESTCASE}" ]; then + echo "No target provided" + exit 1 +fi + +make ${TESTCASE} VERBOSE=1 LIT_ARGS="-v -j `nproc`" diff --git a/buildbot/clang-tidy.sh b/buildbot/clang-tidy.sh new file mode 100755 index 0000000000000..e5f507a3654ab --- /dev/null +++ b/buildbot/clang-tidy.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +BRANCH= +BUILD_NUMBER= +PR_NUMBER= + +# $1 exit code +# $2 error message +exit_if_err() +{ + if [ $1 -ne 0 ]; then + echo "Error: $2" + exit $1 + fi +} + +unset OPTIND +while getopts ":b:r:n:" option; do + case $option in + b) BRANCH=$OPTARG ;; + n) BUILD_NUMBER=$OPTARG ;; + r) PR_NUMBER=$OPTARG ;; + esac +done && shift $(($OPTIND - 1)) + +if [ -z "${PR_NUMBER}" ]; then + echo "No PR number provided" + exit 1 +fi + +# we're in llvm.src dir +SRC_DIR=${PWD} +BUILDER_DIR=$(cd ..; pwd) + +# Get changed files +base_commit=`git merge-base origin/sycl refs/pull/${PR_NUMBER}/merge` +exit_if_err $? "fail to get base commit" + +path_list_file=${BUILDER_DIR}/changed_files.txt +git --no-pager diff ${base_commit} refs/pull/${PR_NUMBER}/merge --name-only > ${path_list_file} +cat ${path_list_file} + +# Run clang-tidy +while IFS='' read -r line ; do + file_name=$(basename ${line}) + file_ext=${file_name##*.} + if [[ "${file_ext}" == "h" || "${file_ext}" == "hpp" || "${file_ext}" == "c" || "${file_ext}" == "cc" || "${file_ext}" == "cpp" ]]; then + ${BUILDER_DIR}/llvm.obj/bin/clang-tidy ${line} + fi +done < "${path_list_file}" diff --git a/buildbot/compile.sh b/buildbot/compile.sh new file mode 100755 index 0000000000000..7a76d14fcecdc --- /dev/null +++ b/buildbot/compile.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +BRANCH= +BUILD_NUMBER= +PR_NUMBER= + +# $1 exit code +# $2 error message +exit_if_err() +{ + if [ $1 -ne 0 ]; then + echo "Error: $2" + exit $1 + fi +} + +unset OPTIND +while getopts ":b:r:n:" option; do + case $option in + b) BRANCH=$OPTARG ;; + n) BUILD_NUMBER=$OPTARG ;; + r) PR_NUMBER=$OPTARG ;; + esac +done && shift $(($OPTIND - 1)) + +# we're in llvm.obj dir +BUILD_DIR=${PWD} + +make -j`nproc` diff --git a/buildbot/configure.sh b/buildbot/configure.sh new file mode 100755 index 0000000000000..ef5f758f51029 --- /dev/null +++ b/buildbot/configure.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +BRANCH= +BUILD_NUMBER= +PR_NUMBER= + +# $1 exit code +# $2 error message +exit_if_err() +{ + if [ $1 -ne 0 ]; then + echo "Error: $2" + exit $1 + fi +} + +unset OPTIND +while getopts ":b:r:n:" option; do + case $option in + b) BRANCH=$OPTARG ;; + n) BUILD_NUMBER=$OPTARG ;; + r) PR_NUMBER=$OPTARG ;; + esac +done && shift $(($OPTIND - 1)) + +# we're in llvm.obj dir +BUILD_DIR=${PWD} + +cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang -DLLVM_EXTERNAL_PROJECTS="sycl;llvm-spirv" \ + -DLLVM_EXTERNAL_SYCL_SOURCE_DIR=../llvm.src/sycl -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=../llvm.src/llvm-spirv \ + -DLLVM_TOOL_SYCL_BUILD=ON -DLLVM_TOOL_LLVM_SPIRV_BUILD=ON -DOpenCL_INCLUDE_DIR="OpenCL-Headers" \ + -DOpenCL_LIBRARY="OpenCL-ICD-Loader/build/lib/libOpenCL.so" ../llvm.src/llvm diff --git a/buildbot/dependency.sh b/buildbot/dependency.sh new file mode 100755 index 0000000000000..261ad0f774b10 --- /dev/null +++ b/buildbot/dependency.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +BRANCH= +BUILD_NUMBER= +PR_NUMBER= + +# $1 exit code +# $2 error message +exit_if_err() +{ + if [ $1 -ne 0 ]; then + echo "Error: $2" + exit $1 + fi +} + +unset OPTIND +while getopts ":b:r:n:" option; do + case $option in + b) BRANCH=$OPTARG ;; + n) BUILD_NUMBER=$OPTARG ;; + r) PR_NUMBER=$OPTARG ;; + esac +done && shift $(($OPTIND - 1)) + +# we're in llvm.obj dir +BUILD_DIR=${PWD} + +## GET dependencies +if [ ! -d "OpenCL-Headers" ]; then + git clone https://github.com/KhronosGroup/OpenCL-Headers OpenCL-Headers + exit_if_err $? "failed to clone OpenCL-Headers" +else + cd OpenCL-Headers + git pull --ff --ff-only origin + exit_if_err $? "failed to update OpenCL-Headers" +fi + +OPENCL_HEADERS=${BUILD_DIR}/OpenCL-Headers + +cd ${BUILD_DIR} +if [ ! -d "OpenCL-ICD-Loader" ]; then + git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader OpenCL-ICD-Loader + exit_if_err $? "failed to clone OpenCL-ICD-Loader" +else + cd OpenCL-ICD-Loader + git pull --ff --ff-only origin + exit_if_err $? "failed to update OpenCL-ICD-Loader" +fi + +cd ${BUILD_DIR}/OpenCL-ICD-Loader +make C_INCLUDE_PATH=${OPENCL_HEADERS} +exit_if_err $? "failed to build OpenCL-ICD-Loader"