scripts: remove legacy build method test
[dpdk.git] / scripts / 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 # Load config options:
34 # - AESNI_MULTI_BUFFER_LIB_PATH
35 # - DPDK_BUILD_TEST_CONFIGS (target1+option1+option2 target2)
36 # - DPDK_DEP_CFLAGS
37 # - DPDK_DEP_LDFLAGS
38 # - DPDK_DEP_MOFED (y/[n])
39 # - DPDK_DEP_PCAP (y/[n])
40 # - DPDK_NOTIFY (notify-send)
41 . $(dirname $(readlink -e $0))/load-devel-config.sh
42
43 print_usage () {
44         echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]"
45 }
46
47 print_help () {
48         echo 'Test building several targets with different options'
49         echo
50         print_usage
51         cat <<- END_OF_HELP
52
53         options:
54                 -h    this help
55                 -jX   use X parallel jobs in "make"
56                 -s    short test with only first config without examples/doc
57
58         config: defconfig name followed by switches delimited with "+" sign
59                 Example: x86_64-native-linuxapp-gcc+next+shared
60                 Default is to enable most of the options.
61                 The external dependencies are setup with DPDK_DEP_* variables.
62         END_OF_HELP
63 }
64
65 J=$DPDK_MAKE_JOBS
66 short=false
67 while getopts hj:s ARG ; do
68         case $ARG in
69                 j ) J=$OPTARG ;;
70                 s ) short=true ;;
71                 h ) print_help ; exit 0 ;;
72                 ? ) print_usage ; exit 1 ;;
73         esac
74 done
75 shift $(($OPTIND - 1))
76 configs=${*:-$DPDK_BUILD_TEST_CONFIGS}
77
78 success=false
79 on_exit ()
80 {
81         if [ "$DPDK_NOTIFY" = notify-send ] ; then
82                 if $success ; then
83                         notify-send -u low --icon=dialog-information 'DPDK build' 'finished'
84                 elif [ -z "$signal" ] ; then
85                         notify-send -u low --icon=dialog-error 'DPDK build' 'failed'
86                 fi
87         fi
88 }
89 # catch manual interrupt to ignore notification
90 trap "signal=INT ; trap - INT ; kill -INT $$" INT
91 # notify result on exit
92 trap on_exit EXIT
93
94 cd $(dirname $(readlink -m $0))/..
95
96 config () # <directory> <target> <options>
97 {
98         if [ ! -e $1/.config ] ; then
99                 echo "================== Configure $1"
100                 make T=$2 O=$1 config
101                 echo $3 | grep -q next || \
102                 sed -ri           's,(NEXT_ABI=)y,\1n,' $1/.config
103                 ! echo $3 | grep -q shared || \
104                 sed -ri         's,(SHARED_LIB=)n,\1y,' $1/.config
105                 echo $2 | grep -q '^i686' || \
106                 sed -ri               's,(NUMA=)n,\1y,' $1/.config
107                 sed -ri         's,(PCI_CONFIG=)n,\1y,' $1/.config
108                 sed -ri    's,(LIBRTE_IEEE1588=)n,\1y,' $1/.config
109                 sed -ri             's,(BYPASS=)n,\1y,' $1/.config
110                 test "$DPDK_DEP_MOFED" != y || \
111                 echo $2 | grep -q '^clang$' || \
112                 sed -ri           's,(MLX._PMD=)n,\1y,' $1/.config
113                 test "$DPDK_DEP_SZE" != y || \
114                 echo $2 | grep -q '^i686' || \
115                 sed -ri       's,(PMD_SZEDATA2=)n,\1y,' $1/.config
116                 test "$DPDK_DEP_ZLIB" != y || \
117                 sed -ri          's,(BNX2X_PMD=)n,\1y,' $1/.config
118                 sed -ri            's,(NFP_PMD=)n,\1y,' $1/.config
119                 test "$DPDK_DEP_PCAP" != y || \
120                 sed -ri               's,(PCAP=)n,\1y,' $1/.config
121                 test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
122                 ! echo $2 | grep -q '^x86_64' || \
123                 sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
124                 test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
125                 ! echo $2 | grep -q '^x86_64' || \
126                 sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
127                 test "$DPDK_DEP_SSL" != y || \
128                 sed -ri            's,(PMD_QAT=)n,\1y,' $1/.config
129                 sed -ri        's,(KNI_VHOST.*=)n,\1y,' $1/.config
130                 sed -ri           's,(SCHED_.*=)n,\1y,' $1/.config
131                 ! echo $2 | grep -q '^i686' || \
132                 sed -ri              's,(POWER=)y,\1n,' $1/.config
133                 sed -ri 's,(TEST_PMD_RECORD_.*=)n,\1y,' $1/.config
134                 sed -ri            's,(DEBUG.*=)n,\1y,' $1/.config
135         fi
136 }
137
138 for conf in $configs ; do
139         target=$(echo $conf | cut -d'+' -f1)
140         options=$(echo $conf | cut -d'+' -sf2- --output-delimiter='-')
141         if [ -z "$options" ] ; then
142                 dir=$target
143         else
144                 dir=$target-$options
145         fi
146         config $dir $target $options
147
148         echo "================== Build $dir"
149         make -j$J EXTRA_CFLAGS="$DPDK_DEP_CFLAGS" \
150                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" O=$dir
151         ! $short || break
152         echo "================== Build examples for $dir"
153         export RTE_SDK=$(pwd)
154         export RTE_TARGET=$dir
155         make -j$J -sC examples \
156                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" \
157                 O=$(readlink -m $dir/examples)
158         unset RTE_TARGET
159         echo "################## $dir done."
160 done
161
162 if ! $short ; then
163         mkdir -p .check
164         echo "================== Build doxygen HTML API"
165         make doc-api-html >/dev/null 2>.check/doc.txt
166         echo "================== Build sphinx HTML guides"
167         make doc-guides-html >/dev/null 2>>.check/doc.txt
168         echo "================== Check docs"
169         diff -u /dev/null .check/doc.txt
170 fi
171
172 success=true