9b50bf73dc7c6d16d097b2014bcf1bcc0ceeeee0
[dpdk.git] / devtools / test-build.sh
1 #! /bin/sh -e
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2015 6WIND S.A.
4
5 default_path=$PATH
6
7 # Load config options:
8 # - ARMV8_CRYPTO_LIB_PATH
9 # - DPDK_BUILD_TEST_CONFIGS (defconfig1+option1+option2 defconfig2)
10 # - DPDK_DEP_ARCHIVE
11 # - DPDK_DEP_CFLAGS
12 # - DPDK_DEP_ELF (y/[n])
13 # - DPDK_DEP_ISAL (y/[n])
14 # - DPDK_DEP_JSON (y/[n])
15 # - DPDK_DEP_LDFLAGS
16 # - DPDK_DEP_MLX (y/[n])
17 # - DPDK_DEP_NUMA ([y]/n)
18 # - DPDK_DEP_PCAP (y/[n])
19 # - DPDK_DEP_SSL (y/[n])
20 # - DPDK_DEP_IPSEC_MB (y/[n])
21 # - DPDK_DEP_SZE (y/[n])
22 # - DPDK_DEP_NFB (y/[n])
23 # - DPDK_DEP_ZLIB (y/[n])
24 # - DPDK_MAKE_JOBS (int)
25 # - DPDK_NOTIFY (notify-send)
26 # - FLEXRAN_SDK
27 # - LIBMUSDK_PATH
28 # - LIBSSO_SNOW3G_PATH
29 # - LIBSSO_KASUMI_PATH
30 # - LIBSSO_ZUC_PATH
31 . $(dirname $(readlink -e $0))/load-devel-config
32
33 print_usage () {
34         echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]"
35 }
36
37 print_help () {
38         echo 'Test building several targets with different options'
39         echo
40         print_usage
41         cat <<- END_OF_HELP
42
43         options:
44                 -h    this help
45                 -jX   use X parallel jobs in "make"
46                 -s    short test only first config without tests|examples|doc
47                 -v    verbose build
48
49         config: defconfig[[~][+]option1[[~][+]option2...]]
50                 Example: x86_64-native-linux-gcc+debug~RXTX_CALLBACKS
51                 The lowercase options are defined inside $(basename $0).
52                 The uppercase options can be the end of a defconfig option
53                 to enable if prefixed with '+' or to disable if prefixed with '~'.
54                 Default is to automatically enable most of the options.
55                 The external dependencies are setup with DPDK_DEP_* variables.
56                 If no config on command line, DPDK_BUILD_TEST_CONFIGS is used.
57         END_OF_HELP
58 }
59
60 J=$DPDK_MAKE_JOBS
61 short=false
62 unset verbose
63 maxerr=-Wfatal-errors
64 while getopts hj:sv ARG ; do
65         case $ARG in
66                 j ) J=$OPTARG ;;
67                 s ) short=true ;;
68                 v ) verbose='V=1' ;;
69                 h ) print_help ; exit 0 ;;
70                 ? ) print_usage ; exit 1 ;;
71         esac
72 done
73 shift $(($OPTIND - 1))
74 configs=${*:-$DPDK_BUILD_TEST_CONFIGS}
75
76 success=false
77 on_exit ()
78 {
79         if $success ; then
80                 [ "$DPDK_NOTIFY" != notify-send ] || \
81                         notify-send -u low --icon=dialog-information 'DPDK build' 'finished'
82         elif [ -z "$signal" ] ; then
83                 [ -z "$dir" ] || echo "failed to build $dir" >&2
84                 [ "$DPDK_NOTIFY" != notify-send ] || \
85                         notify-send -u low --icon=dialog-error 'DPDK build' 'failed'
86         fi
87 }
88 # catch manual interrupt to ignore notification
89 trap "signal=INT ; trap - INT ; kill -INT $$" INT
90 # notify result on exit
91 trap on_exit EXIT
92
93 cd $(dirname $(readlink -m $0))/..
94
95 reset_env ()
96 {
97         export PATH=$default_path
98         unset CROSS
99         unset DPDK_DEP_ARCHIVE
100         unset DPDK_DEP_CFLAGS
101         unset DPDK_DEP_ELF
102         unset DPDK_DEP_ISAL
103         unset DPDK_DEP_JSON
104         unset DPDK_DEP_LDFLAGS
105         unset DPDK_DEP_MLX
106         unset DPDK_DEP_NUMA
107         unset DPDK_DEP_PCAP
108         unset DPDK_DEP_SSL
109         unset DPDK_DEP_IPSEC_MB
110         unset DPDK_DEP_SZE
111         unset DPDK_DEP_ZLIB
112         unset ARMV8_CRYPTO_LIB_PATH
113         unset FLEXRAN_SDK
114         unset LIBMUSDK_PATH
115         unset LIBSSO_SNOW3G_PATH
116         unset LIBSSO_KASUMI_PATH
117         unset LIBSSO_ZUC_PATH
118         unset PQOS_INSTALL_PATH
119 }
120
121 config () # <directory> <target> <options>
122 {
123         reconfig=false
124         if git rev-parse 2>&- && [ -n "$(git diff HEAD~ -- config)" ] ; then
125                 echo 'Default config may have changed'
126                 reconfig=true
127         fi
128         if [ ! -e $1/.config ] || $reconfig ; then
129                 echo "================== Configure $1"
130                 make T=$2 O=$1 config
131
132                 echo 'Customize configuration'
133                 # Built-in options (lowercase)
134                 ! echo $3 | grep -q '+default' || \
135                 sed -ri 's,(RTE_MACHINE=")native,\1default,' $1/.config
136                 echo $3 | grep -q '+next' || \
137                 sed -ri           's,(NEXT_ABI=)y,\1n,' $1/.config
138                 ! echo $3 | grep -q '+shared' || \
139                 sed -ri         's,(SHARED_LIB=)n,\1y,' $1/.config
140                 ! echo $3 | grep -q '+debug' || ( \
141                 sed -ri  's,(RTE_LOG_DP_LEVEL=).*,\1RTE_LOG_DEBUG,' $1/.config
142                 sed -ri           's,(_DEBUG.*=)n,\1y,' $1/.config
143                 sed -ri            's,(_STAT.*=)n,\1y,' $1/.config
144                 sed -ri 's,(TEST_PMD_RECORD_.*=)n,\1y,' $1/.config )
145
146                 # Automatic configuration
147                 test "$DPDK_DEP_NUMA" != n || \
148                 sed -ri             's,(NUMA.*=)y,\1n,' $1/.config
149                 sed -ri    's,(LIBRTE_IEEE1588=)n,\1y,' $1/.config
150                 sed -ri             's,(BYPASS=)n,\1y,' $1/.config
151                 test "$DPDK_DEP_ARCHIVE" != y || \
152                 sed -ri       's,(RESOURCE_TAR=)n,\1y,' $1/.config
153                 test "$DPDK_DEP_ISAL" != y || \
154                 sed -ri           's,(PMD_ISAL=)n,\1y,' $1/.config
155                 test "$DPDK_DEP_MLX" != y || \
156                 sed -ri           's,(MLX._PMD=)n,\1y,' $1/.config
157                 test "$DPDK_DEP_SZE" != y || \
158                 sed -ri       's,(PMD_SZEDATA2=)n,\1y,' $1/.config
159                 test "$DPDK_DEP_ZLIB" != y || \
160                 sed -ri          's,(BNX2X_PMD=)n,\1y,' $1/.config
161                 test "$DPDK_DEP_ZLIB" != y || \
162                 sed -ri           's,(PMD_ZLIB=)n,\1y,' $1/.config
163                 test "$DPDK_DEP_ZLIB" != y || \
164                 sed -ri   's,(COMPRESSDEV_TEST=)n,\1y,' $1/.config
165                 test "$DPDK_DEP_PCAP" != y || \
166                 sed -ri               's,(PCAP=)n,\1y,' $1/.config
167                 test -z "$ARMV8_CRYPTO_LIB_PATH" || \
168                 sed -ri   's,(PMD_ARMV8_CRYPTO=)n,\1y,' $1/.config
169                 test "$DPDK_DEP_IPSEC_MB" != y || \
170                 sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
171                 test "$DPDK_DEP_IPSEC_MB" != y || \
172                 sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
173                 test -z "$LIBSSO_SNOW3G_PATH" || \
174                 sed -ri         's,(PMD_SNOW3G=)n,\1y,' $1/.config
175                 test -z "$LIBSSO_KASUMI_PATH" || \
176                 sed -ri         's,(PMD_KASUMI=)n,\1y,' $1/.config
177                 test -z "$LIBSSO_ZUC_PATH" || \
178                 sed -ri            's,(PMD_ZUC=)n,\1y,' $1/.config
179                 test "$DPDK_DEP_SSL" != y || \
180                 sed -ri            's,(PMD_CCP=)n,\1y,' $1/.config
181                 test "$DPDK_DEP_SSL" != y || \
182                 sed -ri        's,(PMD_OPENSSL=)n,\1y,' $1/.config
183                 test "$DPDK_DEP_SSL" != y || \
184                 sed -ri            's,(QAT_SYM=)n,\1y,' $1/.config
185                 test -z "$FLEXRAN_SDK" || \
186                 sed -ri     's,(BBDEV_TURBO_SW=)n,\1y,' $1/.config
187                 sed -ri           's,(SCHED_.*=)n,\1y,' $1/.config
188                 test -z "$LIBMUSDK_PATH" || \
189                 sed -ri   's,(PMD_MVSAM_CRYPTO=)n,\1y,' $1/.config
190                 test -z "$LIBMUSDK_PATH" || \
191                 sed -ri          's,(MVPP2_PMD=)n,\1y,' $1/.config
192                 test -z "$LIBMUSDK_PATH" || \
193                 sed -ri         's,(MVNETA_PMD=)n,\1y,' $1/.config
194                 test "$DPDK_DEP_ELF" != y || \
195                 sed -ri            's,(BPF_ELF=)n,\1y,' $1/.config
196                 test "$DPDK_DEP_JSON" != y || \
197                 sed -ri          's,(TELEMETRY=)n,\1y,' $1/.config
198                 build_config_hook $1 $2 $3
199
200                 # Explicit enabler/disabler (uppercase)
201                 for option in $(echo $3 | sed 's,[~+], &,g') ; do
202                         pattern=$(echo $option | cut -c2-)
203                         if echo $option | grep -q '^~' ; then
204                                 sed -ri "s,($pattern=)y,\1n," $1/.config
205                         elif echo $option | grep -q '^+' ; then
206                                 sed -ri "s,($pattern=)n,\1y," $1/.config
207                         fi
208                 done
209         fi
210 }
211
212 # default empty hook to override in devel config
213 build_config_hook () # <directory> <target> <options>
214 {
215         :
216 }
217
218 for conf in $configs ; do
219         target=$(echo $conf | sed 's,[~+].*,,')
220         # reload config with DPDK_TARGET set
221         DPDK_TARGET=$target
222         reset_env
223         . $(dirname $(readlink -e $0))/load-devel-config
224
225         options=$(echo $conf | sed 's,[^~+]*,,')
226         dir=$conf
227         config $dir $target $options
228
229         echo "================== Build $dir"
230         make -j$J EXTRA_CFLAGS="$maxerr $DPDK_DEP_CFLAGS" \
231                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
232         ! $short || break
233         echo "================== Build examples for $dir"
234         export RTE_SDK=$(pwd)
235         export RTE_TARGET=$dir
236         make -j$J -sC examples \
237                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
238                 O=$(readlink -m $dir/examples)
239         unset RTE_TARGET
240         echo "################## $dir done."
241         unset dir
242 done
243
244 if ! $short ; then
245         mkdir -p .check
246         echo "================== Build doxygen HTML API"
247         make doc-api-html >/dev/null 2>.check/doc.txt
248         echo "================== Build sphinx HTML guides"
249         make doc-guides-html >/dev/null 2>>.check/doc.txt
250         echo "================== Check docs"
251         diff -u /dev/null .check/doc.txt
252 fi
253
254 success=true