From 5e437164df11fb2fbc96a26b30b65d05f502f584 Mon Sep 17 00:00:00 2001 From: Bruce Richardson Date: Fri, 11 Feb 2022 11:36:41 +0000 Subject: [PATCH] buildtools/chkincs: test headers for C++ compatibility Add support for checking each of our headers for issues when included in a C++ file. Signed-off-by: Bruce Richardson --- .ci/linux-build.sh | 1 + .github/workflows/build.yml | 2 +- buildtools/chkincs/main.cpp | 4 ++++ buildtools/chkincs/meson.build | 18 ++++++++++++++++++ devtools/test-meson-builds.sh | 3 ++- 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 buildtools/chkincs/main.cpp diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index c10c1a8ab5..67d68535e0 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6cf997d6ee..d30cfd08d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 index 0000000000..d25bb8852a --- /dev/null +++ b/buildtools/chkincs/main.cpp @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Intel Corporation + */ +int main(void) { return 0; } diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.build index 7ea136ff95..790f700619 100644 --- a/buildtools/chkincs/meson.build +++ b/buildtools/chkincs/meson.build @@ -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) diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh index 4ed61328b9..c07fd16fdc 100755 --- a/devtools/test-meson-builds.sh +++ b/devtools/test-meson-builds.sh @@ -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