aboutsummaryrefslogtreecommitdiff
path: root/zephyr-upstream/builders.sh
blob: 6b625f37127092940efe5528570bce1c47965235 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash

echo "Going to build:"
echo "git branch: ${BRANCH}"
echo "git revision: ${GIT_COMMIT}"
echo "Root build cause: ${ROOT_BUILD_CAUSE}"
echo

sudo apt-get -q=2 update

# gcc-arm-none-eabi
sudo apt-get -q=2 -y install git ninja-build g++ gperf python3-ply \
    rsync device-tree-compiler \
    python3-pip python3-serial python3-setuptools python3-wheel \
    python3-requests util-linux rename srecord \
    protobuf-compiler python3-protobuf

set -ex

sudo pip3 install west pyelftools
west --version

git clone -b ${BRANCH} https://github.com/zephyrproject-rtos/zephyr.git
west init -l zephyr/
west update

cd zephyr
git clean -fdx
if [ -n "${GIT_COMMIT}" ]; then
  git checkout ${GIT_COMMIT}
fi
echo "GIT_COMMIT_ID=$(git rev-parse --short=8 HEAD)" > ${WORKSPACE}/env_var_parameters

# Toolchains are downloaded once (per release) and cached in a persistent
# docker volume under ${HOME}/srv/toolchain/.
# Note that Zephyr SDK is needed even when building with the gnuarmemb
# toolchain, ZEPHYR_SDK_INSTALL_DIR is needed to find things like conf.
export ZEPHYR_SDK_INSTALL_DIR="${HOME}/srv/toolchain/zephyr-sdk-0.13.1"
export GNUARMEMB_TOOLCHAIN_PATH="${HOME}/srv/toolchain/gcc-arm-none-eabi-9-2019-q4-major"

# Set build environment variables
export LANG=C.UTF-8
ZEPHYR_BASE=${WORKSPACE}/zephyr
PATH=${ZEPHYR_BASE}/scripts:${PATH}
#OUTDIR=${HOME}/srv/zephyr/${BRANCH}/${ZEPHYR_TOOLCHAIN_VARIANT}/${PLATFORM}
OUTDIR=${WORKSPACE}/zephyr-out/${BRANCH}/${ZEPHYR_TOOLCHAIN_VARIANT}/${PLATFORM}
export LANG ZEPHYR_BASE PATH
CCACHE_DIR="${HOME}/srv/ccache-zephyr/${BRANCH}"
CCACHE_UNIFY=1
CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros
USE_CCACHE=1
export CCACHE_DIR CCACHE_UNIFY CCACHE_SLOPPINESS USE_CCACHE
env |grep '^ZEPHYR'
mkdir -p "${CCACHE_DIR}"
rm -rf ${OUTDIR}

echo ""
echo "########################################################################"
echo "    mass-build (twister)"
echo "########################################################################"

# Show ccache stats both before and after build.
CCACHE_DIR=${CCACHE_DIR} ccache --show-stats

time ${ZEPHYR_BASE}/scripts/twister \
  --platform ${PLATFORM} \
  --inline-logs \
  --verbose \
  --build-only \
  --outdir ${OUTDIR} \
  -x=USE_CCACHE=${USE_CCACHE} \
  --jobs 2 \
  ${TWISTER_EXTRA}

CCACHE_DIR=${CCACHE_DIR} ccache --show-stats

# Put report where rsync below will pick it up.
cp ${OUTDIR}/twister.csv ${OUTDIR}/${PLATFORM}/

cd ${ZEPHYR_BASE}
# OUTDIR is already per-platform, but it may get contaminated with unrelated
# builds e.g. due to bugs in twister script. It however stores builds in
# per-platform named subdirs under its --outdir (${OUTDIR} in our case), so
# we use ${OUTDIR}/${PLATFORM} paths below.
find ${OUTDIR}/${PLATFORM} -type f -name '.config' -exec rename 's/.config/zephyr.config/' {} +
rsync -avm \
  --include=zephyr.bin \
  --include=zephyr.config \
  --include=zephyr.elf \
  --include='twister.*' \
  --include='*/' \
  --exclude='*' \
  ${OUTDIR}/${PLATFORM} ${WORKSPACE}/out/
find ${OUTDIR}/${PLATFORM} -type f -name 'zephyr.config' -delete
# If there are support files, ship them.
BOARD_CONFIG=$(find "${ZEPHYR_BASE}/boards/" -type f -name "${PLATFORM}_defconfig")
BOARD_DIR=$(dirname ${BOARD_CONFIG})
test -d "${BOARD_DIR}/support" && rsync -avm "${BOARD_DIR}/support" "${WORKSPACE}/out/${PLATFORM}"

cd ${WORKSPACE}/
echo "=== contents of ${WORKSPACE}/out/ ==="
find out
echo "=== end of contents of ${WORKSPACE}/out/ ==="

CCACHE_DIR=${CCACHE_DIR} ccache -M 30G