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