0dd02f97970b6c74e88b56d9ef4dcae0f6d74dbb
[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 # - DPDK_BUILD_TEST_CONFIGS (target1+option1+option2 target2)
35 # - DPDK_DEP_CFLAGS
36 # - DPDK_DEP_LDFLAGS
37 # - DPDK_DEP_MOFED (y/[n])
38 # - DPDK_DEP_PCAP (y/[n])
39 # - DPDK_NOTIFY (notify-send)
40 . scripts/load-devel-config.sh
41
42 print_usage () {
43         echo "usage: $(basename $0) [-jX] [-s] [config1 [config2] ...]]"
44 }
45
46 J=$DPDK_MAKE_JOBS
47 short=false
48 while getopts hj:s ARG ; do
49         case $ARG in
50                 j ) J=$OPTARG ;;
51                 s ) short=true ;;
52                 h ) print_usage ; exit 0 ;;
53                 ? ) print_usage ; exit 1 ;;
54         esac
55 done
56 shift $(($OPTIND - 1))
57 configs=${*:-$DPDK_BUILD_TEST_CONFIGS}
58
59 success=false
60 on_exit ()
61 {
62         if [ "$DPDK_NOTIFY" = notify-send ] ; then
63                 if $success ; then
64                         notify-send -u low --icon=dialog-information 'DPDK build' 'finished'
65                 elif [ -z "$signal" ] ; then
66                         notify-send -u low --icon=dialog-error 'DPDK build' 'failed'
67                 fi
68         fi
69 }
70 # catch manual interrupt to ignore notification
71 trap "signal=INT ; trap - INT ; kill -INT $$" INT
72 # notify result on exit
73 trap on_exit EXIT
74
75 cd $(dirname $(readlink -m $0))/..
76
77 config () # <directory> <target> <options>
78 {
79         if [ ! -e $1/.config ] ; then
80                 echo Custom configuration
81                 make T=$2 O=$1 config
82                 echo $3 | grep -q next || \
83                 sed -ri           's,(NEXT_ABI=)y,\1n,' $1/.config
84                 ! echo $3 | grep -q shared || \
85                 sed -ri         's,(SHARED_LIB=)n,\1y,' $1/.config
86                 ! echo $3 | grep -q combined || \
87                 sed -ri       's,(COMBINE_LIBS=)n,\1y,' $1/.config
88                 echo $2 | grep -q '^i686' || \
89                 sed -ri               's,(NUMA=)n,\1y,' $1/.config
90                 sed -ri         's,(PCI_CONFIG=)n,\1y,' $1/.config
91                 sed -ri    's,(LIBRTE_IEEE1588=)n,\1y,' $1/.config
92                 sed -ri             's,(BYPASS=)n,\1y,' $1/.config
93                 test "$DPDK_DEP_MOFED" != y || \
94                 echo $2 | grep -q '^clang$' || \
95                 echo $3 | grep -q 'shared.*combined' || \
96                 sed -ri           's,(MLX._PMD=)n,\1y,' $1/.config
97                 test "$DPDK_DEP_SZE" != y || \
98                 echo $2 | grep -q '^i686' || \
99                 sed -ri       's,(PMD_SZEDATA2=)n,\1y,' $1/.config
100                 test "$DPDK_DEP_ZLIB" != y || \
101                 echo $2 | grep -q '^i686' || \
102                 sed -ri          's,(BNX2X_PMD=)n,\1y,' $1/.config
103                 test "$DPDK_DEP_PCAP" != y || \
104                 sed -ri               's,(PCAP=)n,\1y,' $1/.config
105                 test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
106                 echo $2 | grep -q '^i686' || \
107                 echo $3 | grep -q 'shared.*combined' || \
108                 sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
109                 test "$DPDK_DEP_SSL" != y || \
110                 echo $2 | grep -q '^i686' || \
111                 echo $3 | grep -q 'shared.*combined' || \
112                 sed -ri            's,(PMD_QAT=)n,\1y,' $1/.config
113                 sed -ri        's,(KNI_VHOST.*=)n,\1y,' $1/.config
114                 sed -ri           's,(SCHED_.*=)n,\1y,' $1/.config
115                 ! echo $2 | grep -q '^i686' || \
116                 sed -ri              's,(POWER=)y,\1n,' $1/.config
117                 sed -ri 's,(TEST_PMD_RECORD_.*=)n,\1y,' $1/.config
118                 sed -ri            's,(DEBUG.*=)n,\1y,' $1/.config
119         fi
120 }
121
122 for conf in $configs ; do
123         target=$(echo $conf | cut -d'+' -f1)
124         options=$(echo $conf | cut -d'+' -sf2- --output-delimiter='-')
125         if [ -z "$options" ] ; then
126                 dir=$target
127                 config $dir $target
128                 # Use install rule
129                 make -j$J T=$target install EXTRA_CFLAGS="$DPDK_DEP_CFLAGS" EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS"
130                 $short || make -j$J T=$target examples O=$dir/examples EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS"
131         else
132                 dir=$target-$options
133                 config $dir $target $options
134                 echo "================== Build $dir"
135                 # Use O variable without install
136                 make -j$J O=$dir EXTRA_CFLAGS="$DPDK_DEP_CFLAGS" EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS"
137                 echo "================== Build examples for $dir"
138                 make -j$J -sC examples RTE_SDK=$(pwd) RTE_TARGET=$dir O=$(readlink -m $dir/examples) EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS"
139         fi
140         echo "################## $dir done."
141         ! $short || break
142 done
143
144 if ! $short ; then
145         mkdir -p .check
146         echo "================== Build doxygen HTML API"
147         make doc-api-html >/dev/null 2>.check/doc.txt
148         echo "================== Build sphinx HTML guides"
149         make doc-guides-html >/dev/null 2>>.check/doc.txt
150         echo "================== Check docs"
151         diff -u /dev/null .check/doc.txt
152 fi
153
154 success=true