Skip to content

Commit 0818f3e

Browse files
ikurtchenvladimirlaz
authored andcommitted
[Buildbot] Add scripts for build steps
The scripts will be called by Buildbot on corresponding steps. Signed-off-by: Kurt Chen <kurt.chen@intel.com>
1 parent ba999d3 commit 0818f3e

File tree

6 files changed

+237
-0
lines changed

6 files changed

+237
-0
lines changed

buildbot/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Scripts for build steps on Buildbot
2+
3+
## Purpose
4+
5+
The purpose of the script is for developer to customize build command for the builder on Buildbot.
6+
7+
## How it works
8+
9+
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.
10+
11+
## Arguments for the scripts
12+
13+
Common
14+
15+
* -b BRANCH: the branch name to build
16+
* -n BUILD\_NUMBER: the Buildbot build number (the build count of one builder, which will be in the url of one specific build)
17+
* -r PR\_NUMBER: if it's a pull request build, this will be the pull request number
18+
19+
LIT Test (check.sh)
20+
21+
* -t TESTCASE: the LIT testing target, e.g. check-sycl
22+
23+
## Assumptions
24+
25+
The Buildbot worker directory structure is:
26+
27+
/path/to/WORKER_ROOT/BUILDER/
28+
llvm.src --> source code
29+
llvm.obj --> build directory
30+
31+
Initial working directory of the scripts:
32+
33+
* dependency.sh : llvm.obj
34+
* configure.sh : llvm.obj
35+
* compile.sh : llvm.obj
36+
* clang-tidy.sh : llvm.src
37+
* check.sh : llvm.obj

buildbot/check.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
BRANCH=
4+
BUILD_NUMBER=
5+
PR_NUMBER=
6+
TESTCASE=
7+
8+
# $1 exit code
9+
# $2 error message
10+
exit_if_err()
11+
{
12+
if [ $1 -ne 0 ]; then
13+
echo "Error: $2"
14+
exit $1
15+
fi
16+
}
17+
18+
unset OPTIND
19+
while getopts ":b:r:n:t:" option; do
20+
case $option in
21+
b) BRANCH=$OPTARG ;;
22+
n) BUILD_NUMBER=$OPTARG ;;
23+
r) PR_NUMBER=$OPTARG ;;
24+
t) TESTCASE=$OPTARG ;;
25+
esac
26+
done && shift $(($OPTIND - 1))
27+
28+
# we're in llvm.obj dir
29+
BUILD_DIR=${PWD}
30+
31+
if [ -z "${TESTCASE}" ]; then
32+
echo "No target provided"
33+
exit 1
34+
fi
35+
36+
make ${TESTCASE} VERBOSE=1 LIT_ARGS="-v -j `nproc`"

buildbot/clang-tidy.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
BRANCH=
4+
BUILD_NUMBER=
5+
PR_NUMBER=
6+
7+
# $1 exit code
8+
# $2 error message
9+
exit_if_err()
10+
{
11+
if [ $1 -ne 0 ]; then
12+
echo "Error: $2"
13+
exit $1
14+
fi
15+
}
16+
17+
unset OPTIND
18+
while getopts ":b:r:n:" option; do
19+
case $option in
20+
b) BRANCH=$OPTARG ;;
21+
n) BUILD_NUMBER=$OPTARG ;;
22+
r) PR_NUMBER=$OPTARG ;;
23+
esac
24+
done && shift $(($OPTIND - 1))
25+
26+
if [ -z "${PR_NUMBER}" ]; then
27+
echo "No PR number provided"
28+
exit 1
29+
fi
30+
31+
# we're in llvm.src dir
32+
SRC_DIR=${PWD}
33+
BUILDER_DIR=$(cd ..; pwd)
34+
35+
# Get changed files
36+
base_commit=`git merge-base origin/sycl refs/pull/${PR_NUMBER}/merge`
37+
exit_if_err $? "fail to get base commit"
38+
39+
path_list_file=${BUILDER_DIR}/changed_files.txt
40+
git --no-pager diff ${base_commit} refs/pull/${PR_NUMBER}/merge --name-only > ${path_list_file}
41+
cat ${path_list_file}
42+
43+
# Run clang-tidy
44+
while IFS='' read -r line ; do
45+
file_name=$(basename ${line})
46+
file_ext=${file_name##*.}
47+
if [[ "${file_ext}" == "h" || "${file_ext}" == "hpp" || "${file_ext}" == "c" || "${file_ext}" == "cc" || "${file_ext}" == "cpp" ]]; then
48+
${BUILDER_DIR}/llvm.obj/bin/clang-tidy ${line}
49+
fi
50+
done < "${path_list_file}"

buildbot/compile.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
BRANCH=
4+
BUILD_NUMBER=
5+
PR_NUMBER=
6+
7+
# $1 exit code
8+
# $2 error message
9+
exit_if_err()
10+
{
11+
if [ $1 -ne 0 ]; then
12+
echo "Error: $2"
13+
exit $1
14+
fi
15+
}
16+
17+
unset OPTIND
18+
while getopts ":b:r:n:" option; do
19+
case $option in
20+
b) BRANCH=$OPTARG ;;
21+
n) BUILD_NUMBER=$OPTARG ;;
22+
r) PR_NUMBER=$OPTARG ;;
23+
esac
24+
done && shift $(($OPTIND - 1))
25+
26+
# we're in llvm.obj dir
27+
BUILD_DIR=${PWD}
28+
29+
make -j`nproc`

buildbot/configure.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
BRANCH=
4+
BUILD_NUMBER=
5+
PR_NUMBER=
6+
7+
# $1 exit code
8+
# $2 error message
9+
exit_if_err()
10+
{
11+
if [ $1 -ne 0 ]; then
12+
echo "Error: $2"
13+
exit $1
14+
fi
15+
}
16+
17+
unset OPTIND
18+
while getopts ":b:r:n:" option; do
19+
case $option in
20+
b) BRANCH=$OPTARG ;;
21+
n) BUILD_NUMBER=$OPTARG ;;
22+
r) PR_NUMBER=$OPTARG ;;
23+
esac
24+
done && shift $(($OPTIND - 1))
25+
26+
# we're in llvm.obj dir
27+
BUILD_DIR=${PWD}
28+
29+
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang -DLLVM_EXTERNAL_PROJECTS="sycl;llvm-spirv" \
30+
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=../llvm.src/sycl -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=../llvm.src/llvm-spirv \
31+
-DLLVM_TOOL_SYCL_BUILD=ON -DLLVM_TOOL_LLVM_SPIRV_BUILD=ON -DOpenCL_INCLUDE_DIR="OpenCL-Headers" \
32+
-DOpenCL_LIBRARY="OpenCL-ICD-Loader/build/lib/libOpenCL.so" ../llvm.src/llvm

buildbot/dependency.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
BRANCH=
4+
BUILD_NUMBER=
5+
PR_NUMBER=
6+
7+
# $1 exit code
8+
# $2 error message
9+
exit_if_err()
10+
{
11+
if [ $1 -ne 0 ]; then
12+
echo "Error: $2"
13+
exit $1
14+
fi
15+
}
16+
17+
unset OPTIND
18+
while getopts ":b:r:n:" option; do
19+
case $option in
20+
b) BRANCH=$OPTARG ;;
21+
n) BUILD_NUMBER=$OPTARG ;;
22+
r) PR_NUMBER=$OPTARG ;;
23+
esac
24+
done && shift $(($OPTIND - 1))
25+
26+
# we're in llvm.obj dir
27+
BUILD_DIR=${PWD}
28+
29+
## GET dependencies
30+
if [ ! -d "OpenCL-Headers" ]; then
31+
git clone https://github.com/KhronosGroup/OpenCL-Headers OpenCL-Headers
32+
exit_if_err $? "failed to clone OpenCL-Headers"
33+
else
34+
cd OpenCL-Headers
35+
git pull --ff --ff-only origin
36+
exit_if_err $? "failed to update OpenCL-Headers"
37+
fi
38+
39+
OPENCL_HEADERS=${BUILD_DIR}/OpenCL-Headers
40+
41+
cd ${BUILD_DIR}
42+
if [ ! -d "OpenCL-ICD-Loader" ]; then
43+
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader OpenCL-ICD-Loader
44+
exit_if_err $? "failed to clone OpenCL-ICD-Loader"
45+
else
46+
cd OpenCL-ICD-Loader
47+
git pull --ff --ff-only origin
48+
exit_if_err $? "failed to update OpenCL-ICD-Loader"
49+
fi
50+
51+
cd ${BUILD_DIR}/OpenCL-ICD-Loader
52+
make C_INCLUDE_PATH=${OPENCL_HEADERS}
53+
exit_if_err $? "failed to build OpenCL-ICD-Loader"

0 commit comments

Comments
 (0)