forked from digi-embedded/u-boot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jenkins.sh
executable file
·123 lines (106 loc) · 4.52 KB
/
jenkins.sh
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
#===============================================================================
#
# jenkins.sh
#
# Copyright (C) 2015 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# Description: U-Boot jenkins build script
#
# Parameters from the environment (not all needed):
# DUB_PLATFORMS: Platforms to build
# DUB_REVISION: Revision of the U-Boot repository
# DUB_GIT_URL: U-Boot repo url
# DUB_TOOLCHAIN_URL: Toolchain installer base url
#
#===============================================================================
set -e
# <platform> <uboot_make_target> <toolchain_type>
while read pl mt tt; do
AVAILABLE_PLATFORMS="${AVAILABLE_PLATFORMS:+${AVAILABLE_PLATFORMS} }${pl}"
eval "${pl}_make_target=\"${mt}\""
eval "${pl}_toolchain_type=\"${tt}\""
done<<-_EOF_
ccimx6dlsbc256MB u-boot.imx cortexa9hf
ccimx6dlsbc512MB u-boot.imx cortexa9hf
ccimx6dlsbc u-boot.imx cortexa9hf
ccimx6qsbc2GB u-boot.imx cortexa9hf
ccimx6qsbc512MB u-boot.imx cortexa9hf
ccimx6qsbc u-boot.imx cortexa9hf
ccimx6qpsbc2GB u-boot.imx cortexa9hf
ccimx6ulstarter u-boot.imx cortexa9hf
ccimx6ulsbc u-boot.imx cortexa9hf
ccimx6ulstarter1GB u-boot.imx cortexa9hf
ccimx6ulsbc1GB u-boot.imx cortexa9hf
ccimx8x_sbc_express1GB u-boot-dtb.bin aarch64
ccimx8x_sbc_express2GB u-boot-dtb.bin aarch64
ccimx8x_sbc_pro1GB u-boot-dtb.bin aarch64
ccimx8x_sbc_pro2GB u-boot-dtb.bin aarch64
_EOF_
# Set default values if not provided by Jenkins
DUB_GIT_URL="${DUB_GIT_URL:-ssh://git@stash.digi.com/uboot/u-boot-denx.git}"
DUB_TOOLCHAIN_URL="${DUB_TOOLCHAIN_URL:-http://build-linux.digi.com/yocto/toolchain}"
DUB_PLATFORMS="${DUB_PLATFORMS:-$(echo ${AVAILABLE_PLATFORMS})}"
error() {
printf "${1}"
exit 1
}
# Sanity check (Jenkins environment)
[ -z "${WORKSPACE}" ] && error "WORKSPACE not specified"
# Unset BUILD_TAG from Jenkins so U-Boot does not show it
unset BUILD_TAG
printf "\n[INFO] Build U-Boot \"${DUB_REVISION}\" for \"${DUB_PLATFORMS}\"\n\n"
# Remove nested directories from the revision
DUB_REVISION_SANE="$(echo ${DUB_REVISION} | tr '/' '_')"
DUB_IMGS_DIR="${WORKSPACE}/images"
DUB_TOOLCHAIN_DIR="${WORKSPACE}/toolchain"
DUB_UBOOT_DIR="${WORKSPACE}/u-boot${DUB_REVISION_SANE:+-${DUB_REVISION_SANE}}.git"
rm -rf ${DUB_IMGS_DIR} ${DUB_TOOLCHAIN_DIR} ${DUB_UBOOT_DIR}
mkdir -p ${DUB_IMGS_DIR} ${DUB_TOOLCHAIN_DIR} ${DUB_UBOOT_DIR}
if pushd ${DUB_UBOOT_DIR}; then
# Install U-Boot
git clone ${DUB_GIT_URL} .
if [ -n "${DUB_REVISION}" -a "${DUB_REVISION}" != "master" ]; then
git checkout ${DUB_REVISION}
fi
CPUS="$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)"
[ ${CPUS} -gt 1 ] && MAKE_JOBS="-j${CPUS}"
for platform in ${DUB_PLATFORMS}; do
# Build in a sub-shell to avoid mixing environments for different platform
(
printf "\n[PLATFORM: ${platform} - CPUS: ${CPUS}]\n"
# Install toolchain
eval TOOLCHAIN_TYPE=\"\${${platform}_toolchain_type}\"
for TLABEL in ${DUB_REVISION_SANE} default; do
TLABEL="${TLABEL}-${TOOLCHAIN_TYPE}"
# If the toolchain is already installed exit the loop
[ -d "${DUB_TOOLCHAIN_DIR}/${TLABEL}" ] && break
if wget -q --spider "${DUB_TOOLCHAIN_URL}/toolchain-${TLABEL}.sh"; then
printf "\n[INFO] Installing toolchain-${TLABEL}.sh\n\n"
tmp_toolchain="$(mktemp /tmp/toolchain.XXXXXX)"
wget -q -O ${tmp_toolchain} "${DUB_TOOLCHAIN_URL}/toolchain-${TLABEL}.sh" && chmod +x ${tmp_toolchain}
rm -rf ${DUB_TOOLCHAIN_DIR}/${TLABEL} && sh ${tmp_toolchain} -y -d ${DUB_TOOLCHAIN_DIR}/${TLABEL}
rm -f ${tmp_toolchain}
break
fi
done
eval $(grep "^export CROSS_COMPILE=" ${DUB_TOOLCHAIN_DIR}/${TLABEL}/environment-setup-*)
eval $(grep "^export PATH=" ${DUB_TOOLCHAIN_DIR}/${TLABEL}/environment-setup-*)
eval $(grep "^export SDKTARGETSYSROOT=" ${DUB_TOOLCHAIN_DIR}/${TLABEL}/environment-setup-*)
# We need to explicitly pass the CC variable. Otherwise u-boot discards the
# '--sysroot' option and the build fails
eval UBOOT_MAKE_TARGET=\"\${${platform}_make_target}\"
make distclean
make ${platform}_defconfig
make ${MAKE_JOBS} CC="${CROSS_COMPILE}gcc --sysroot=${SDKTARGETSYSROOT}" ${UBOOT_MAKE_TARGET}
# Copy u-boot image
cp ${UBOOT_MAKE_TARGET} ${DUB_IMGS_DIR}/${UBOOT_MAKE_TARGET/u-boot/u-boot-${platform}}
)
done
popd
fi