diff options
-rw-r--r-- | .gitlab-ci.yml | 28 | ||||
-rw-r--r-- | .reuse/dep5 | 2 | ||||
-rw-r--r-- | meson.build | 66 | ||||
-rw-r--r-- | meson/suppressions/meson.build | 65 | ||||
-rw-r--r-- | meson/warnings/meson.build | 203 | ||||
-rw-r--r-- | meson_options.txt | 7 | ||||
-rw-r--r-- | test/meson.build | 7 |
7 files changed, 87 insertions, 291 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18c41ac..6191bba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,46 +4,46 @@ arm32_dbg: image: lv2plugin/debian-arm32 script: - - meson setup build --cross-file=/usr/share/meson/cross/arm-linux-gnueabihf.ini -Dbuildtype=debug -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/arm-linux-gnueabihf.ini -Dbuildtype=debug -Dwarning_level=3 -Dwerror=true - ninja -C build test arm32_rel: image: lv2plugin/debian-arm32 script: - - meson setup build --cross-file=/usr/share/meson/cross/arm-linux-gnueabihf.ini -Dbuildtype=release -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/arm-linux-gnueabihf.ini -Dbuildtype=release -Dwarning_level=3 -Dwerror=true - ninja -C build test arm64_dbg: image: lv2plugin/debian-arm64 script: - - meson setup build --cross-file=/usr/share/meson/cross/aarch64-linux-gnu.ini -Dbuildtype=debug -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/aarch64-linux-gnu.ini -Dbuildtype=debug -Dwarning_level=3 -Dwerror=true - ninja -C build test arm64_rel: image: lv2plugin/debian-arm64 script: - - meson setup build --cross-file=/usr/share/meson/cross/aarch64-linux-gnu.ini -Dbuildtype=release -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/aarch64-linux-gnu.ini -Dbuildtype=release -Dwarning_level=3 -Dwerror=true - ninja -C build test x32_dbg: image: lv2plugin/debian-x32 script: - - meson setup build --cross-file=/usr/share/meson/cross/i686-linux-gnu.ini -Dbuildtype=debug -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/i686-linux-gnu.ini -Dbuildtype=debug -Dwarning_level=3 -Dwerror=true - ninja -C build test x32_rel: image: lv2plugin/debian-x32 script: - - meson setup build --cross-file=/usr/share/meson/cross/i686-linux-gnu.ini -Dbuildtype=release -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/i686-linux-gnu.ini -Dbuildtype=release -Dwarning_level=3 -Dwerror=true - ninja -C build test x64_dbg: image: lv2plugin/debian-x64 script: - - meson setup build -Dbuildtype=debug -Dstrict=true -Dwerror=true -Db_coverage=true + - meson setup build -Dbuildtype=debug -Dwarning_level=3 -Dwerror=true -Db_coverage=true - ninja -C build test - ninja -C build coverage-html coverage: '/ *lines\.*: \d+\.\d+.*/' @@ -54,21 +54,21 @@ x64_dbg: x64_rel: image: lv2plugin/debian-x64 script: - - meson setup build -Dbuildtype=release -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=release -Dwarning_level=3 -Dwerror=true - ninja -C build test x64_static: image: lv2plugin/debian-x64 script: - - meson setup build -Ddefault_library=static -Dstrict=true -Dwerror=true + - meson setup build -Ddefault_library=static -Dwarning_level=3 -Dwerror=true - ninja -C build test x64_sanitize: image: lv2plugin/debian-x64-clang script: - - meson setup build -Db_lundef=false -Dbuildtype=plain -Dstrict=true -Dwerror=true + - meson setup build -Db_lundef=false -Dbuildtype=plain -Dwarning_level=3 -Dwerror=true - ninja -C build test variables: CXX: "clang++" @@ -79,26 +79,26 @@ x64_sanitize: mac_dbg: tags: [macos] script: - - meson setup build -Dbuildtype=debug -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=debug -Dwarning_level=3 -Dwerror=true - ninja -C build test mac_rel: tags: [macos] script: - - meson setup build -Dbuildtype=release -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=release -Dwarning_level=3 -Dwerror=true - ninja -C build test win_dbg: tags: [windows,meson] script: - - meson setup build -Dbuildtype=debug -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=debug -Dwarning_level=everything -Dwerror=true - ninja -C build test win_rel: tags: [windows,meson] script: - - meson setup build -Dbuildtype=release -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=release -Dwarning_level=everything -Dwerror=true - ninja -C build test diff --git a/.reuse/dep5 b/.reuse/dep5 index 8a44c58..602b476 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -3,6 +3,6 @@ Upstream-Name: raul Upstream-Contact: David Robillard <d@drobilla.net> Source: https://gitlab.com/drobilla/raul -Files: *.md raul.ttl .clant.json .includes.imp NEWS meson_options.txt +Files: *.md raul.ttl .clant.json .includes.imp NEWS Copyright: 2020-2021 David Robillard <d@drobilla.net> License: 0BSD OR GPL-3.0-or-later diff --git a/meson.build b/meson.build index 68aff7d..becc6cd 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -# Copyright 2019-2022 David Robillard <d@drobilla.net> +# Copyright 2019-2023 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later project('raul', ['cpp'], @@ -23,11 +23,67 @@ versioned_name = 'raul-@0@'.format(meson.project_version().split('.')[0]) pkg = import('pkgconfig') cpp = meson.get_compiler('cpp') -# Set global warning flags -if get_option('strict') and not meson.is_subproject() - subdir('meson/warnings') +# Set global warning suppressions +warning_level = get_option('warning_level') +cpp_suppressions = [] +if cpp.get_id() in ['clang', 'emscripten'] + if warning_level == 'everything' + cpp_suppressions += [ + '-Wno-c++17-extensions', + '-Wno-c++98-compat', + '-Wno-padded', + '-Wno-weak-vtables', + ] + + if host_machine.system() == 'windows' + cpp_suppressions += [ + '-Wno-nonportable-system-include-path', + ] + endif + endif + +elif cpp.get_id() == 'gcc' + if warning_level == 'everything' + cpp_suppressions += [ + '-Wno-abi-tag', + '-Wno-inline', + '-Wno-multiple-inheritance', + '-Wno-padded', + '-Wno-suggest-attribute=pure', + '-Wno-switch-default', + '-Wno-useless-cast', + ] + endif + +elif cpp.get_id() == 'msvc' + cpp_suppressions += [ + '/experimental:external', + '/external:W0', + '/external:anglebrackets', + ] + + if warning_level == 'everything' + cpp_suppressions += [ + '/wd4514', # unreferenced inline function removed + '/wd4625', # copy constructor implicitly deleted + '/wd4626', # assignment operator implicitly deleted + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd5026', # move constructor implicitly deleted + '/wd5027', # move assignment operator implicitly deleted + '/wd5045', # compiler will insert Spectre mitigation + '/wd5262', # implicit fall-through + ] + endif + + if warning_level in ['everything', '3'] + cpp_suppressions += [ + '/wd4706', # assignment within conditional expression + ] + endif endif -subdir('meson/suppressions') + +cpp_suppressions = cpp.get_supported_arguments(cpp_suppressions) ################ # Dependencies # diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build deleted file mode 100644 index a92c808..0000000 --- a/meson/suppressions/meson.build +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> -# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later - -# Project-specific warning suppressions. -# -# This should be used in conjunction with the generic "warnings" sibling that -# enables all reasonable warnings for the compiler. It lives here just to keep -# the top-level meson.build more readable. - -####### -# C++ # -####### - -if is_variable('cpp') - cpp_suppressions = [] - - if get_option('strict') - if cpp.get_id() in ['clang', 'emscripten'] - cpp_suppressions += [ - '-Wno-c++17-extensions', - '-Wno-padded', - '-Wno-weak-vtables', - ] - - if host_machine.system() == 'windows' - cpp_suppressions += [ - '-Wno-nonportable-system-include-path', - ] - endif - - elif cpp.get_id() == 'gcc' - cpp_suppressions += [ - '-Wno-abi-tag', - '-Wno-inline', - '-Wno-multiple-inheritance', - '-Wno-padded', - '-Wno-suggest-attribute=pure', - '-Wno-switch-default', - '-Wno-useless-cast', - ] - - elif cpp.get_id() == 'msvc' - cpp_suppressions += [ - '/wd4514', # unreferenced inline function removed - '/wd4625', # copy constructor implicitly deleted - '/wd4626', # assignment operator implicitly deleted - '/wd4706', # assignment within conditional expression - '/wd4710', # function not inlined - '/wd4711', # function selected for automatic inline expansion - '/wd5026', # move constructor implicitly deleted - '/wd5027', # move assignment operator implicitly deleted - '/wd5045', # compiler will insert Spectre mitigation - '/wd5262', # implicit fall-through - ] - endif - endif - - if cpp.get_id() in ['clang', 'emscripten'] - cpp_suppressions += [ - '-Wno-nullability-extension', - ] - endif - - cpp_suppressions = cpp.get_supported_arguments(cpp_suppressions) -endif diff --git a/meson/warnings/meson.build b/meson/warnings/meson.build deleted file mode 100644 index 7abb749..0000000 --- a/meson/warnings/meson.build +++ /dev/null @@ -1,203 +0,0 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> -# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later - -# General code to enable approximately all warnings in GCC 12, clang, and MSVC. -# -# This is trivial for clang and MSVC, but GCC doesn't have an "everything" -# option, so we need to enable everything we want explicitly. Wall is assumed, -# but Wextra is not, for stability. -# -# These are collected from common.opt and c.opt in the GCC source, and manually -# curated with the help of the GCC documentation. Warnings that are -# application-specific, historical, or about compatibility between specific -# language revisions are omitted. The intent here is to have roughly the same -# meaning as clang's Weverything: extremely strict, but general. Specifically -# omitted are: -# -# General: -# -# Wabi= -# Waggregate-return -# Walloc-size-larger-than=BYTES -# Walloca-larger-than=BYTES -# Wframe-larger-than=BYTES -# Wlarger-than=BYTES -# Wstack-usage=BYTES -# Wsystem-headers -# Wtraditional -# Wtraditional-conversion -# Wtrampolines -# Wvla-larger-than=BYTES -# -# Build specific: -# -# Wpoison-system-directories -# -# C Specific: -# -# Wc11-c2x-compat -# Wc90-c99-compat -# Wc99-c11-compat -# Wdeclaration-after-statement -# Wtraditional -# Wtraditional-conversion -# -# C++ Specific: -# -# Wc++0x-compat -# Wc++1z-compat -# Wc++2a-compat -# Wctad-maybe-unsupported -# Wnamespaces -# Wtemplates - -# GCC warnings that apply to all C-family languages -gcc_common_warnings = [ - '-Walloc-zero', - '-Walloca', - '-Wanalyzer-too-complex', - '-Warith-conversion', - '-Warray-bounds=2', - '-Wattribute-alias=2', - '-Wbidi-chars=ucn', - '-Wcast-align=strict', - '-Wcast-function-type', - '-Wcast-qual', - '-Wclobbered', - '-Wconversion', - '-Wdate-time', - '-Wdisabled-optimization', - '-Wdouble-promotion', - '-Wduplicated-branches', - '-Wduplicated-cond', - '-Wempty-body', - '-Wendif-labels', - '-Wfloat-equal', - '-Wformat-overflow=2', - '-Wformat-signedness', - '-Wformat-truncation=2', - '-Wformat=2', - '-Wignored-qualifiers', - '-Wimplicit-fallthrough=3', - '-Winit-self', - '-Winline', - '-Winvalid-pch', - '-Wlogical-op', - '-Wmissing-declarations', - '-Wmissing-field-initializers', - '-Wmissing-include-dirs', - '-Wmultichar', - '-Wnormalized=nfc', - '-Wnull-dereference', - '-Wopenacc-parallelism', - '-Woverlength-strings', - '-Wpacked', - '-Wpacked-bitfield-compat', - '-Wpadded', - '-Wpointer-arith', - '-Wredundant-decls', - '-Wshadow', - '-Wshift-negative-value', - '-Wshift-overflow=2', - '-Wstack-protector', - '-Wstrict-aliasing=3', - '-Wstrict-overflow=5', - '-Wstring-compare', - '-Wstringop-overflow=3', - '-Wsuggest-attribute=cold', - '-Wsuggest-attribute=const', - '-Wsuggest-attribute=format', - '-Wsuggest-attribute=malloc', - '-Wsuggest-attribute=noreturn', - '-Wsuggest-attribute=pure', - '-Wswitch-default', - '-Wswitch-enum', - '-Wtrampolines', - '-Wtrivial-auto-var-init', - '-Wtype-limits', - '-Wundef', - '-Wuninitialized', - '-Wunsafe-loop-optimizations', - '-Wunused', - '-Wunused-const-variable=2', - '-Wunused-macros', - '-Wvector-operation-performance', - '-Wvla', - '-Wwrite-strings', -] - -####### -# C++ # -####### - -if is_variable('cpp') - all_cpp_warnings = [] - - if cpp.get_id() == 'clang' - all_cpp_warnings += [ - '-Weverything', - '-Wno-c++98-compat', - '-Wno-c++98-compat-pedantic' - ] - - if not meson.is_cross_build() - all_cpp_warnings += [ - '-Wno-poison-system-directories', - ] - endif - - elif cpp.get_id() == 'gcc' - all_cpp_warnings += gcc_common_warnings + [ - '-Wabi-tag', - '-Waligned-new=all', - '-Wcatch-value=3', - '-Wcomma-subscript', - '-Wconditionally-supported', - '-Wctor-dtor-privacy', - '-Wdelete-non-virtual-dtor', - '-Wdeprecated', - '-Wdeprecated-copy', - '-Wdeprecated-copy-dtor', - '-Wdeprecated-enum-enum-conversion', - '-Wdeprecated-enum-float-conversion', - '-Weffc++', - '-Wexpansion-to-defined', - '-Wextra-semi', - '-Wimport', - '-Winvalid-imported-macros', - '-Wmismatched-tags', - '-Wmultiple-inheritance', - '-Wnoexcept', - '-Wnoexcept-type', - '-Wnon-virtual-dtor', - '-Wold-style-cast', - '-Woverloaded-virtual', - '-Wplacement-new=2', - '-Wredundant-move', - '-Wredundant-tags', - '-Wregister', - '-Wsign-compare', - '-Wsign-promo', - '-Wsized-deallocation', - '-Wstrict-null-sentinel', - '-Wsuggest-final-methods', - '-Wsuggest-final-types', - '-Wsuggest-override', - '-Wuseless-cast', - '-Wvirtual-inheritance', - '-Wvolatile', - '-Wzero-as-null-pointer-constant', - ] - - elif cpp.get_id() == 'msvc' - all_cpp_warnings += [ - '/Wall', - '/experimental:external', - '/external:W0', - '/external:anglebrackets', - ] - endif - - all_cpp_warnings = cpp.get_supported_arguments(all_cpp_warnings) - add_global_arguments(all_cpp_warnings, language: ['cpp']) -endif diff --git a/meson_options.txt b/meson_options.txt index c14078e..8013287 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,5 +1,8 @@ -option('strict', type: 'boolean', value: false, yield: true, - description: 'Enable ultra-strict warnings') +# Copyright 2022-2023 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later + +option('lint', type: 'boolean', value: false, yield: true, + description: 'Run code quality checks') option('tests', type: 'feature', value: 'auto', yield: true, description: 'Build tests') diff --git a/test/meson.build b/test/meson.build index 0c073b8..ce9dd49 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,7 +1,7 @@ # Copyright 2019-2022 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later -if get_option('strict') +if get_option('lint') if not meson.is_subproject() # Check release metadata autoship = find_program('autoship', required: get_option('tests')) @@ -33,6 +33,7 @@ header_args = [] if cpp.get_id() == 'clang' header_args += [ '-Wno-c++17-extensions', + '-Wno-c++98-compat', '-Wno-padded', '-Wno-weak-vtables', ] @@ -54,6 +55,10 @@ elif cpp.get_id() == 'gcc' elif cpp.get_id() == 'msvc' header_args += [ + '/experimental:external', + '/external:W0', + '/external:anglebrackets', + '/wd4626', # assignment operator implicitly deleted '/wd5027', # move assignment operator implicitly deleted '/wd5262', # implicit fall-through |