[v3,7/7] buildtools/chkincs: test headers for C++ compatibility
Checks
Commit Message
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 | 1 +
buildtools/chkincs/main.cpp | 4 ++++
buildtools/chkincs/meson.build | 20 ++++++++++++++++++++
3 files changed, 25 insertions(+)
create mode 100644 buildtools/chkincs/main.cpp
Comments
On Thu, Feb 10, 2022 at 3:05 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> 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 | 1 +
> buildtools/chkincs/main.cpp | 4 ++++
> buildtools/chkincs/meson.build | 20 ++++++++++++++++++++
> 3 files changed, 25 insertions(+)
> 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
>
Even though check_includes=true is not forced for 32bits in
test-meson-builds.sh, I sometimes enable more checks for some targets.
Can this change be applied to test-meson-builds.sh too?
https://git.dpdk.org/dpdk/tree/devtools/test-meson-builds.sh#n249
On Thu, Feb 10, 2022 at 03:37:04PM +0100, David Marchand wrote:
> On Thu, Feb 10, 2022 at 3:05 PM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > 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 | 1 +
> > buildtools/chkincs/main.cpp | 4 ++++
> > buildtools/chkincs/meson.build | 20 ++++++++++++++++++++
> > 3 files changed, 25 insertions(+)
> > 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
> >
>
> Even though check_includes=true is not forced for 32bits in
> test-meson-builds.sh, I sometimes enable more checks for some targets.
> Can this change be applied to test-meson-builds.sh too?
>
> https://git.dpdk.org/dpdk/tree/devtools/test-meson-builds.sh#n249
>
Yes, will do.
@@ -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
new file mode 100644
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+int main(void) { return 0; }
@@ -28,3 +28,23 @@ executable('chkincs', sources,
dependencies: deps,
link_whole: dpdk_static_libraries + dpdk_drivers,
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],
+ link_args: dpdk_extra_ldflags,
+ include_directories: includes,
+ dependencies: deps,
+ link_whole: dpdk_static_libraries + dpdk_drivers,
+ install: false)