ci: enable header includes check
[dpdk.git] / .ci / linux-build.sh
1 #!/bin/sh -xe
2
3 on_error() {
4     if [ $? = 0 ]; then
5         exit
6     fi
7     FILES_TO_PRINT="build/meson-logs/testlog.txt build/.ninja_log build/meson-logs/meson-log.txt"
8
9     for pr_file in $FILES_TO_PRINT; do
10         if [ -e "$pr_file" ]; then
11             cat "$pr_file"
12         fi
13     done
14 }
15 # We capture the error logs as artifacts in Github Actions, no need to dump
16 # them via a EXIT handler.
17 [ -n "$GITHUB_WORKFLOW" ] || trap on_error EXIT
18
19 install_libabigail() {
20     version=$1
21     instdir=$2
22
23     wget -q "http://mirrors.kernel.org/sourceware/libabigail/${version}.tar.gz"
24     tar -xf ${version}.tar.gz
25     cd $version && autoreconf -vfi && cd -
26     mkdir $version/build
27     cd $version/build && ../configure --prefix=$instdir && cd -
28     make -C $version/build all install
29     rm -rf $version
30     rm ${version}.tar.gz
31 }
32
33 if [ "$AARCH64" = "true" ]; then
34     # convert the arch specifier
35     if [ "$CC_FOR_BUILD" = "gcc" ]; then
36         OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc"
37     elif [ "$CC_FOR_BUILD" = "clang" ]; then
38         OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_clang_ubuntu1804"
39     fi
40 fi
41
42 if [ "$BUILD_DOCS" = "true" ]; then
43     OPTS="$OPTS -Denable_docs=true"
44 fi
45
46 if [ "$BUILD_32BIT" = "true" ]; then
47     OPTS="$OPTS -Dc_args=-m32 -Dc_link_args=-m32"
48     export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
49 fi
50
51 if [ "$DEF_LIB" = "static" ]; then
52     OPTS="$OPTS -Dexamples=l2fwd,l3fwd"
53 else
54     OPTS="$OPTS -Dexamples=all"
55 fi
56
57 OPTS="$OPTS -Dmachine=default"
58 OPTS="$OPTS --default-library=$DEF_LIB"
59 OPTS="$OPTS --buildtype=debugoptimized"
60 OPTS="$OPTS -Dcheck_includes=true"
61 meson build --werror $OPTS
62 ninja -C build
63
64 if [ "$AARCH64" != "true" ]; then
65     devtools/test-null.sh
66 fi
67
68 if [ "$ABI_CHECKS" = "true" ]; then
69     LIBABIGAIL_VERSION=${LIBABIGAIL_VERSION:-libabigail-1.6}
70
71     if [ "$(cat libabigail/VERSION 2>/dev/null)" != "$LIBABIGAIL_VERSION" ]; then
72         rm -rf libabigail
73         # if we change libabigail, invalidate existing abi cache
74         rm -rf reference
75     fi
76
77     if [ ! -d libabigail ]; then
78         install_libabigail $LIBABIGAIL_VERSION $(pwd)/libabigail
79         echo $LIBABIGAIL_VERSION > libabigail/VERSION
80     fi
81
82     export PATH=$(pwd)/libabigail/bin:$PATH
83
84     REF_GIT_REPO=${REF_GIT_REPO:-https://dpdk.org/git/dpdk}
85     REF_GIT_TAG=${REF_GIT_TAG:-v19.11}
86
87     if [ "$(cat reference/VERSION 2>/dev/null)" != "$REF_GIT_TAG" ]; then
88         rm -rf reference
89     fi
90
91     if [ ! -d reference ]; then
92         refsrcdir=$(readlink -f $(pwd)/../dpdk-$REF_GIT_TAG)
93         git clone --single-branch -b $REF_GIT_TAG $REF_GIT_REPO $refsrcdir
94         meson $OPTS -Dexamples= $refsrcdir $refsrcdir/build
95         ninja -C $refsrcdir/build
96         DESTDIR=$(pwd)/reference ninja -C $refsrcdir/build install
97         devtools/gen-abi.sh reference
98         find reference/usr/local -name '*.a' -delete
99         rm -rf reference/usr/local/bin
100         rm -rf reference/usr/local/share
101         echo $REF_GIT_TAG > reference/VERSION
102     fi
103
104     DESTDIR=$(pwd)/install ninja -C build install
105     devtools/gen-abi.sh install
106     devtools/check-abi.sh reference install ${ABI_CHECKS_WARN_ONLY:-}
107 fi
108
109 if [ "$RUN_TESTS" = "true" ]; then
110     sudo meson test -C build --suite fast-tests -t 3
111 fi