forked from xen-project/xen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·105 lines (82 loc) · 3.44 KB
/
build
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 -ex
test -f /etc/os-release && cat "$_"
# Construct $cc such that it matches what `make` will chose when taking
# CROSS_COMPILE into account. Do not modify $CC directly, as that will cause
# `make` to double-account CROSS_COMPILE.
cc="${CROSS_COMPILE}${CC}"
$cc --version
# random config or default config
if [[ "${RANDCONFIG}" == "y" ]]; then
# Append job-specific fixed configuration
if [[ -n "${EXTRA_FIXED_RANDCONFIG}" ]]; then
echo "${EXTRA_FIXED_RANDCONFIG}" >> xen/tools/kconfig/allrandom.config
fi
make -j$(nproc) -C xen KCONFIG_ALLCONFIG=tools/kconfig/allrandom.config randconfig
# RANDCONFIG implies HYPERVISOR_ONLY
HYPERVISOR_ONLY="y"
else
# Start off with arch's defconfig
make -C xen defconfig
echo "CONFIG_DEBUG=${debug}" >> xen/.config
if [[ -n "${EXTRA_XEN_CONFIG}" ]]; then
echo "${EXTRA_XEN_CONFIG}" >> xen/.config
fi
make -j$(nproc) -C xen olddefconfig
fi
# Save the config file before building because build failure causes the script
# to exit early -- bash is invoked with -e.
cp xen/.config xen-config
# Directory for the artefacts to be dumped into
mkdir -p binaries
if [[ "${CPPCHECK}" == "y" ]] && [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
# Cppcheck analysis invokes Xen-only build
xen/scripts/xen-analysis.py --run-cppcheck --cppcheck-misra -- -j$(nproc)
# Preserve artefacts
cp xen/xen binaries/xen
cp xen/cppcheck-report/xen-cppcheck.txt xen-cppcheck.txt
elif [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
# Xen-only build
make -j$(nproc) xen
# Preserve artefacts
cp xen/xen binaries/xen
else
# Full build. Figure out our ./configure options
cfgargs=()
cfgargs+=("--enable-docs")
# booleans for which compiler is in use
cc_is_gcc="$($cc --version | grep -q gcc && echo "y" || :)"
cc_is_clang="$($cc --version | grep -q clang && echo "y" || :)"
# The compiler version as an integer. e.g. GCC 4.9.2 => 0x040902
cc_ver="$($cc -dumpversion | awk -F. '{ printf "0x%02x%02x%02x", $1, $2, $3 }')"
if [[ "${cc_is_clang}" == "y" ]]; then
# SeaBIOS cannot be built with clang
cfgargs+=("--with-system-seabios=/usr/share/no-seabios.bin")
# iPXE cannot be built with clang
cfgargs+=("--with-system-ipxe=/usr/share/no-ipxe.pxe")
# newlib cannot be built with clang so we cannot build stubdoms
cfgargs+=("--disable-stubdom")
fi
if ldd /bin/ls | grep -q musl; then
# disable --disable-werror for QEMUU when building with MUSL
cfgargs+=("--with-extra-qemuu-configure-args=\"--disable-werror\"")
fi
# Qemu requires Python 3.5 or later, and ninja
# and Clang 10 or later
if ! type python3 || python3 -c "import sys; res = sys.version_info < (3, 5); exit(not(res))" \
|| [[ "$cc_is_clang" == y && "$cc_ver" -lt 0x0a0000 ]] \
|| ! type ninja; then
cfgargs+=("--with-system-qemu=/bin/false")
fi
# SeaBIOS requires GCC 4.6 or later
if [[ "${cc_is_gcc}" == "y" && "${cc_ver}" -lt 0x040600 ]]; then
cfgargs+=("--with-system-seabios=/usr/share/no-seabios.bin")
fi
./configure "${cfgargs[@]}"
make -j$(nproc) dist
# Preserve artefacts
# Note: Some smoke tests depending on finding binaries/xen on a full build
# even though dist/ contains everything, while some containers don't even
# build Xen
cp -r dist binaries/
if [[ -f xen/xen ]] ; then cp xen/xen binaries/xen; fi
fi