compress/isal: add skeleton ISA-L compression PMD
[dpdk.git] / devtools / test-build.sh
1 #! /bin/sh -e
2
3 # BSD LICENSE
4 #
5 # Copyright 2015 6WIND S.A.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 #
11 #   * Redistributions of source code must retain the above copyright
12 #     notice, this list of conditions and the following disclaimer.
13 #   * Redistributions in binary form must reproduce the above copyright
14 #     notice, this list of conditions and the following disclaimer in
15 #     the documentation and/or other materials provided with the
16 #     distribution.
17 #   * Neither the name of 6WIND S.A. nor the names of its
18 #     contributors may be used to endorse or promote products derived
19 #     from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 default_path=$PATH
34
35 # Load config options:
36 # - ARMV8_CRYPTO_LIB_PATH
37 # - DPDK_BUILD_TEST_CONFIGS (defconfig1+option1+option2 defconfig2)
38 # - DPDK_DEP_ARCHIVE
39 # - DPDK_DEP_CFLAGS
40 # - DPDK_DEP_ISAL (y/[n])
41 # - DPDK_DEP_LDFLAGS
42 # - DPDK_DEP_MLX (y/[n])
43 # - DPDK_DEP_NUMA ([y]/n)
44 # - DPDK_DEP_PCAP (y/[n])
45 # - DPDK_DEP_SSL (y/[n])
46 # - DPDK_DEP_IPSEC_MB (y/[n])
47 # - DPDK_DEP_SZE (y/[n])
48 # - DPDK_DEP_ZLIB (y/[n])
49 # - DPDK_MAKE_JOBS (int)
50 # - DPDK_NOTIFY (notify-send)
51 # - FLEXRAN_SDK
52 # - LIBMUSDK_PATH
53 # - LIBSSO_SNOW3G_PATH
54 # - LIBSSO_KASUMI_PATH
55 # - LIBSSO_ZUC_PATH
56 . $(dirname $(readlink -e $0))/load-devel-config
57
58 print_usage () {
59         echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]"
60 }
61
62 print_help () {
63         echo 'Test building several targets with different options'
64         echo
65         print_usage
66         cat <<- END_OF_HELP
67
68         options:
69                 -h    this help
70                 -jX   use X parallel jobs in "make"
71                 -s    short test only first config without tests|examples|doc
72                 -v    verbose build
73
74         config: defconfig[[~][+]option1[[~][+]option2...]]
75                 Example: x86_64-native-linuxapp-gcc+debug~RXTX_CALLBACKS
76                 The lowercase options are defined inside $(basename $0).
77                 The uppercase options can be the end of a defconfig option
78                 to enable if prefixed with '+' or to disable if prefixed with '~'.
79                 Default is to automatically enable most of the options.
80                 The external dependencies are setup with DPDK_DEP_* variables.
81                 If no config on command line, DPDK_BUILD_TEST_CONFIGS is used.
82         END_OF_HELP
83 }
84
85 J=$DPDK_MAKE_JOBS
86 short=false
87 unset verbose
88 maxerr=-Wfatal-errors
89 while getopts hj:sv ARG ; do
90         case $ARG in
91                 j ) J=$OPTARG ;;
92                 s ) short=true ;;
93                 v ) verbose='V=1' ;;
94                 h ) print_help ; exit 0 ;;
95                 ? ) print_usage ; exit 1 ;;
96         esac
97 done
98 shift $(($OPTIND - 1))
99 configs=${*:-$DPDK_BUILD_TEST_CONFIGS}
100
101 success=false
102 on_exit ()
103 {
104         if $success ; then
105                 [ "$DPDK_NOTIFY" != notify-send ] || \
106                         notify-send -u low --icon=dialog-information 'DPDK build' 'finished'
107         elif [ -z "$signal" ] ; then
108                 [ -z "$dir" ] || echo "failed to build $dir" >&2
109                 [ "$DPDK_NOTIFY" != notify-send ] || \
110                         notify-send -u low --icon=dialog-error 'DPDK build' 'failed'
111         fi
112 }
113 # catch manual interrupt to ignore notification
114 trap "signal=INT ; trap - INT ; kill -INT $$" INT
115 # notify result on exit
116 trap on_exit EXIT
117
118 cd $(dirname $(readlink -m $0))/..
119
120 reset_env ()
121 {
122         export PATH=$default_path
123         unset CROSS
124         unset DPDK_DEP_ARCHIVE
125         unset DPDK_DEP_CFLAGS
126         unset DPDK_DEP_ISAL
127         unset DPDK_DEP_LDFLAGS
128         unset DPDK_DEP_MLX
129         unset DPDK_DEP_NUMA
130         unset DPDK_DEP_PCAP
131         unset DPDK_DEP_SSL
132         unset DPDK_DEP_IPSEC_MB
133         unset DPDK_DEP_SZE
134         unset DPDK_DEP_ZLIB
135         unset ARMV8_CRYPTO_LIB_PATH
136         unset FLEXRAN_SDK
137         unset LIBMUSDK_PATH
138         unset LIBSSO_SNOW3G_PATH
139         unset LIBSSO_KASUMI_PATH
140         unset LIBSSO_ZUC_PATH
141         unset PQOS_INSTALL_PATH
142 }
143
144 config () # <directory> <target> <options>
145 {
146         reconfig=false
147         if git rev-parse 2>&- && [ -n "$(git diff HEAD~ -- config)" ] ; then
148                 echo 'Default config may have changed'
149                 reconfig=true
150         fi
151         if [ ! -e $1/.config ] || $reconfig ; then
152                 echo "================== Configure $1"
153                 make T=$2 O=$1 config
154
155                 echo 'Customize configuration'
156                 # Built-in options (lowercase)
157                 ! echo $3 | grep -q '+default' || \
158                 sed -ri 's,(RTE_MACHINE=")native,\1default,' $1/.config
159                 echo $3 | grep -q '+next' || \
160                 sed -ri           's,(NEXT_ABI=)y,\1n,' $1/.config
161                 ! echo $3 | grep -q '+shared' || \
162                 sed -ri         's,(SHARED_LIB=)n,\1y,' $1/.config
163                 ! echo $3 | grep -q '+debug' || ( \
164                 sed -ri  's,(RTE_LOG_DP_LEVEL=).*,\1RTE_LOG_DEBUG,' $1/.config
165                 sed -ri           's,(_DEBUG.*=)n,\1y,' $1/.config
166                 sed -ri            's,(_STAT.*=)n,\1y,' $1/.config
167                 sed -ri 's,(TEST_PMD_RECORD_.*=)n,\1y,' $1/.config )
168
169                 # Automatic configuration
170                 test "$DPDK_DEP_NUMA" != n || \
171                 sed -ri             's,(NUMA.*=)y,\1n,' $1/.config
172                 sed -ri    's,(LIBRTE_IEEE1588=)n,\1y,' $1/.config
173                 sed -ri             's,(BYPASS=)n,\1y,' $1/.config
174                 test "$DPDK_DEP_ARCHIVE" != y || \
175                 sed -ri       's,(RESOURCE_TAR=)n,\1y,' $1/.config
176                 test "$DPDK_DEP_ISAL" != y || \
177                 sed -ri           's,(ISAL_PMD=)n,\1y,' $1/.config
178                 test "$DPDK_DEP_MLX" != y || \
179                 sed -ri           's,(MLX._PMD=)n,\1y,' $1/.config
180                 test "$DPDK_DEP_SZE" != y || \
181                 sed -ri       's,(PMD_SZEDATA2=)n,\1y,' $1/.config
182                 test "$DPDK_DEP_ZLIB" != y || \
183                 sed -ri          's,(BNX2X_PMD=)n,\1y,' $1/.config
184                 sed -ri            's,(NFP_PMD=)n,\1y,' $1/.config
185                 test "$DPDK_DEP_PCAP" != y || \
186                 sed -ri               's,(PCAP=)n,\1y,' $1/.config
187                 test -z "$ARMV8_CRYPTO_LIB_PATH" || \
188                 sed -ri   's,(PMD_ARMV8_CRYPTO=)n,\1y,' $1/.config
189                 test "$DPDK_DEP_IPSEC_MB" != y || \
190                 sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
191                 test "$DPDK_DEP_IPSEC_MB" != y || \
192                 sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
193                 test -z "$LIBSSO_SNOW3G_PATH" || \
194                 sed -ri         's,(PMD_SNOW3G=)n,\1y,' $1/.config
195                 test -z "$LIBSSO_KASUMI_PATH" || \
196                 sed -ri         's,(PMD_KASUMI=)n,\1y,' $1/.config
197                 test -z "$LIBSSO_ZUC_PATH" || \
198                 sed -ri            's,(PMD_ZUC=)n,\1y,' $1/.config
199                 test "$DPDK_DEP_SSL" != y || \
200                 sed -ri            's,(PMD_CCP=)n,\1y,' $1/.config
201                 test "$DPDK_DEP_SSL" != y || \
202                 sed -ri        's,(PMD_OPENSSL=)n,\1y,' $1/.config
203                 test "$DPDK_DEP_SSL" != y || \
204                 sed -ri            's,(PMD_QAT=)n,\1y,' $1/.config
205                 test -z "$FLEXRAN_SDK" || \
206                 sed -ri     's,(BBDEV_TURBO_SW=)n,\1y,' $1/.config
207                 sed -ri           's,(SCHED_.*=)n,\1y,' $1/.config
208                 test -z "$LIBMUSDK_PATH" || \
209                 sed -ri    's,(PMD_MVSAM_CRYPTO=)n,\1y,' $1/.config
210                 test -z "$LIBMUSDK_PATH" || \
211                 sed -ri          's,(MVPP2_PMD=)n,\1y,' $1/.config
212                 build_config_hook $1 $2 $3
213
214                 # Explicit enabler/disabler (uppercase)
215                 for option in $(echo $3 | sed 's,[~+], &,g') ; do
216                         pattern=$(echo $option | cut -c2-)
217                         if echo $option | grep -q '^~' ; then
218                                 sed -ri "s,($pattern=)y,\1n," $1/.config
219                         elif echo $option | grep -q '^+' ; then
220                                 sed -ri "s,($pattern=)n,\1y," $1/.config
221                         fi
222                 done
223         fi
224 }
225
226 # default empty hook to override in devel config
227 build_config_hook () # <directory> <target> <options>
228 {
229         :
230 }
231
232 for conf in $configs ; do
233         target=$(echo $conf | sed 's,[~+].*,,')
234         # reload config with DPDK_TARGET set
235         DPDK_TARGET=$target
236         reset_env
237         . $(dirname $(readlink -e $0))/load-devel-config
238
239         options=$(echo $conf | sed 's,[^~+]*,,')
240         dir=$conf
241         config $dir $target $options
242
243         echo "================== Build $dir"
244         make -j$J EXTRA_CFLAGS="$maxerr $DPDK_DEP_CFLAGS" \
245                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
246         ! $short || break
247         echo "================== Build tests for $dir"
248         make test-build -j$J EXTRA_CFLAGS="$maxerr $DPDK_DEP_CFLAGS" \
249                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
250         echo "================== Build examples for $dir"
251         export RTE_SDK=$(pwd)
252         export RTE_TARGET=$dir
253         make -j$J -sC examples \
254                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
255                 O=$(readlink -m $dir/examples)
256         unset RTE_TARGET
257         echo "################## $dir done."
258         unset dir
259 done
260
261 if ! $short ; then
262         mkdir -p .check
263         echo "================== Build doxygen HTML API"
264         make doc-api-html >/dev/null 2>.check/doc.txt
265         echo "================== Build sphinx HTML guides"
266         make doc-guides-html >/dev/null 2>>.check/doc.txt
267         echo "================== Check docs"
268         diff -u /dev/null .check/doc.txt
269 fi
270
271 success=true