aboutsummaryrefslogtreecommitdiffstats
path: root/bindings/cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2025-01-21 11:48:14 -0500
committerDavid Robillard <d@drobilla.net>2025-01-21 11:48:14 -0500
commit51aae63069fb93a9994cae72f8c28cee06f92362 (patch)
treef708c503a72d2c4bf06856d81cf49286b02b10b7 /bindings/cpp
parent8c8c268bf2166b9049b51cde89a3330462771249 (diff)
downloadpugl-51aae63069fb93a9994cae72f8c28cee06f92362.tar.gz
pugl-51aae63069fb93a9994cae72f8c28cee06f92362.tar.bz2
pugl-51aae63069fb93a9994cae72f8c28cee06f92362.zip
Add header warning tests
Diffstat (limited to 'bindings/cpp')
-rw-r--r--bindings/cpp/meson.build12
-rw-r--r--bindings/cpp/test/headers/.clang-tidy26
-rw-r--r--bindings/cpp/test/headers/meson.build33
-rw-r--r--bindings/cpp/test/headers/test_headers.cpp20
4 files changed, 90 insertions, 1 deletions
diff --git a/bindings/cpp/meson.build b/bindings/cpp/meson.build
index 5d8f586..3e55c71 100644
--- a/bindings/cpp/meson.build
+++ b/bindings/cpp/meson.build
@@ -1,6 +1,10 @@
-# Copyright 2021 David Robillard <d@drobilla.net>
+# Copyright 2021-2025 David Robillard <d@drobilla.net>
# SPDX-License-Identifier: 0BSD OR ISC
+######################################
+# C++ Bindings Package (Header-Only) #
+######################################
+
subdir('include')
puglpp_dep = declare_dependency(
@@ -20,3 +24,9 @@ pkg.generate(
)
meson.override_dependency(puglpp_versioned_name, puglpp_dep)
+
+############################
+# C++ Header Warning Tests #
+############################
+
+subdir('test/headers')
diff --git a/bindings/cpp/test/headers/.clang-tidy b/bindings/cpp/test/headers/.clang-tidy
new file mode 100644
index 0000000..0e20b52
--- /dev/null
+++ b/bindings/cpp/test/headers/.clang-tidy
@@ -0,0 +1,26 @@
+# Copyright 2020-2025 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: 0BSD OR ISC
+
+Checks: >
+ *,
+ -*-magic-numbers,
+ -*-use-using,
+ -altera-*,
+ -cppcoreguidelines-avoid-const-or-ref-data-members,
+ -cppcoreguidelines-pro-bounds-pointer-arithmetic,
+ -cppcoreguidelines-pro-type-reinterpret-cast,
+ -llvmlibc-*,
+ -modernize-redundant-void-arg,
+ -modernize-use-trailing-return-type,
+ -performance-enum-size,
+ -readability-implicit-bool-conversion,
+CheckOptions:
+ - key: readability-function-cognitive-complexity.Threshold
+ value: '2'
+ - key: readability-identifier-length.IgnoredParameterNames
+ value: '^(f)|(id)|(x)|(y)$'
+ - key: readability-identifier-length.IgnoredVariableNames
+ value: '^(r)$'
+FormatStyle: file
+HeaderFilterRegex: '.*'
+WarningsAsErrors: '*'
diff --git a/bindings/cpp/test/headers/meson.build b/bindings/cpp/test/headers/meson.build
new file mode 100644
index 0000000..67dad3c
--- /dev/null
+++ b/bindings/cpp/test/headers/meson.build
@@ -0,0 +1,33 @@
+# Copyright 2020-2025 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: 0BSD OR ISC
+
+header_cpp_suppressions = []
+
+if get_option('warning_level') == 'everything'
+ if cc.get_id() == 'clang'
+ if not meson.is_cross_build()
+ header_cpp_suppressions += ['-Wno-poison-system-directories']
+ endif
+ endif
+endif
+
+test_headers_cpp_args = header_cpp_suppressions
+test_headers_cpp_args += [
+ '-DPUGL_NO_INCLUDE_GL_H',
+ '-DPUGL_NO_INCLUDE_GLU_H',
+]
+
+if vulkan_dep.found()
+ test_headers_cpp_args += ['-DPUGL_TEST_VULKAN']
+endif
+
+test(
+ 'headers',
+ executable(
+ 'test_headers_cpp',
+ files('test_headers.cpp'),
+ cpp_args: test_headers_cpp_args,
+ dependencies: puglpp_dep,
+ ),
+ suite: 'unit',
+)
diff --git a/bindings/cpp/test/headers/test_headers.cpp b/bindings/cpp/test/headers/test_headers.cpp
new file mode 100644
index 0000000..a28f537
--- /dev/null
+++ b/bindings/cpp/test/headers/test_headers.cpp
@@ -0,0 +1,20 @@
+// Copyright 2022-2025 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#include <pugl/cairo.hpp> // IWYU pragma: keep
+#include <pugl/gl.hpp> // IWYU pragma: keep
+#include <pugl/pugl.hpp> // IWYU pragma: keep
+#include <pugl/stub.hpp> // IWYU pragma: keep
+
+#ifdef PUGL_TEST_VULKAN
+# include <pugl/vulkan.hpp> // IWYU pragma: keep
+#endif
+
+#ifdef __GNUC__
+__attribute__((const))
+#endif
+int
+main()
+{
+ return 0;
+}