Skip to content

Commit 88f750d

Browse files
committed
[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 88f750d

File tree

9 files changed

+314
-0
lines changed

9 files changed

+314
-0
lines changed

buildbot/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
* -b BRANCH: the branch name to build
14+
* -n BUILD\_NUMBER: the Buildbot build number (the build count of one builder, which will be in the url of one specific build)
15+
* -r PR\_NUMBER: if it's a pull request build, this will be the pull request number
16+
17+
## Assumptions
18+
19+
The Buildbot worker directory structure is:
20+
21+
/path/to/WORKER_ROOT/BUILDER/
22+
llvm.src --> source code
23+
llvm.obj --> build directory
24+
25+
Initial working directory of the scripts:
26+
27+
* dependency.sh : llvm.obj
28+
* configure.sh : llvm.obj
29+
* compile.sh : llvm.obj
30+
* clang-tidy.sh : llvm.src
31+
* check-llvm.sh : llvm.obj
32+
* check-clang.sh : llvm.obj
33+
* check-llvm-spirv.sh : llvm.obj
34+
* check-sycl.sh : llvm.obj

buildbot/check-clang.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 check-clang VERBOSE=1 LIT_ARGS="-v -j `nproc`"

buildbot/check-llvm-spirv.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 check-llvm-spirv VERBOSE=1 LIT_ARGS="-v -j `nproc`"

buildbot/check-llvm.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 check-llvm VERBOSE=1 LIT_ARGS="-v -j `nproc`"

buildbot/check-sycl.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 check-sycl 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)