buildtools/chkincs: test headers for C++ compatibility
authorBruce Richardson <bruce.richardson@intel.com>
Fri, 11 Feb 2022 11:36:41 +0000 (11:36 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 12 Feb 2022 13:26:21 +0000 (14:26 +0100)
Add support for checking each of our headers for issues when included in
a C++ file.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
.ci/linux-build.sh
.github/workflows/build.yml
buildtools/chkincs/main.cpp [new file with mode: 0644]
buildtools/chkincs/meson.build
devtools/test-meson-builds.sh

index c10c1a8..67d6853 100755 (executable)
@@ -74,6 +74,7 @@ fi
 
 if [ "$BUILD_32BIT" = "true" ]; then
     OPTS="$OPTS -Dc_args=-m32 -Dc_link_args=-m32"
+    OPTS="$OPTS -Dcpp_args=-m32 -Dcpp_link_args=-m32"
     export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
 fi
 
index 6cf997d..d30cfd0 100644 (file)
@@ -116,7 +116,7 @@ jobs:
           libdw-dev
     - name: Install i386 cross compiling packages
       if: env.BUILD_32BIT == 'true'
-      run: sudo apt install -y gcc-multilib
+      run: sudo apt install -y gcc-multilib g++-multilib
     - name: Install aarch64 cross compiling packages
       if: env.AARCH64 == 'true'
       run: sudo apt install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross
diff --git a/buildtools/chkincs/main.cpp b/buildtools/chkincs/main.cpp
new file mode 100644 (file)
index 0000000..d25bb88
--- /dev/null
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+int main(void) { return 0; }
index 7ea136f..790f700 100644 (file)
@@ -27,3 +27,21 @@ executable('chkincs', sources,
         include_directories: includes,
         dependencies: deps,
         install: false)
+
+# run tests for c++ builds also
+if not add_languages('cpp', required: false)
+    subdir_done()
+endif
+
+gen_cpp_files = generator(gen_c_file_for_header,
+        output: '@BASENAME@.cpp',
+        arguments: ['@INPUT@', '@OUTPUT@'])
+
+cpp_sources = files('main.cpp')
+cpp_sources += gen_cpp_files.process(dpdk_chkinc_headers)
+
+executable('chkincs-cpp', cpp_sources,
+        cpp_args: ['-include', 'rte_config.h', cflags],
+        include_directories: includes,
+        dependencies: deps,
+        install: false)
index 4ed6132..c07fd16 100755 (executable)
@@ -246,7 +246,8 @@ if check_cc_flags '-m32' ; then
                export PKG_CONFIG_LIBDIR='/usr/lib/pkgconfig'
        fi
        target_override='i386-pc-linux-gnu'
-       build build-32b cc ABI -Dc_args='-m32' -Dc_link_args='-m32'
+       build build-32b cc ABI -Dc_args='-m32' -Dc_link_args='-m32' \
+                       -Dcpp_args='-m32' -Dcpp_link_args='-m32'
        target_override=
        unset PKG_CONFIG_LIBDIR
 fi