diff options
-rw-r--r-- | .gitlab-ci.yml | 20 | ||||
-rw-r--r-- | examples/meson.build | 6 | ||||
-rw-r--r-- | meson.build | 7 | ||||
-rw-r--r-- | meson/suppressions/meson.build | 234 | ||||
-rw-r--r-- | meson/warnings/meson.build | 217 | ||||
-rw-r--r-- | meson_options.txt | 8 | ||||
-rw-r--r-- | test/meson.build | 15 |
7 files changed, 174 insertions, 333 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0013ea3..0d61cd0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ dev: stage: build image: lv2plugin/debian-x64 script: - - meson setup build -Dbuildtype=debug -Ddocs=enabled -Ddocs_cpp=false -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=debug -Ddocs=enabled -Ddocs_cpp=false -Dwarning_level=3 -Dwerror=true -Dlint=true - ninja -C build - meson configure -Dbuildtype=release build - ninja -C build @@ -26,7 +26,7 @@ static: stage: build image: lv2plugin/debian-x64 script: - - meson setup build -Ddefault_library=static -Ddocs=disabled -Dstrict=true -Dwerror=true + - meson setup build -Ddefault_library=static -Ddocs=disabled -Dwarning_level=3 -Dwerror=true - ninja -C build - meson configure -Dbuildtype=release build - ninja -C build @@ -35,7 +35,7 @@ sanitize: stage: build image: lv2plugin/debian-x64-clang script: - - meson setup build -Db_lundef=false -Dbuildtype=plain -Ddocs=disabled -Dstrict=true -Dwerror=true + - meson setup build -Db_lundef=false -Dbuildtype=plain -Ddocs=disabled -Dwarning_level=3 -Dwerror=true - ninja -C build variables: CC: "clang" @@ -50,7 +50,7 @@ arm32: stage: build image: lv2plugin/debian-arm32 script: - - meson setup build --cross-file=/usr/share/meson/cross/arm-linux-gnueabihf.ini -Dbuildtype=debug -Ddocs=disabled -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/arm-linux-gnueabihf.ini -Dbuildtype=debug -Ddocs=disabled -Dwarning_level=3 -Dwerror=true - ninja -C build - meson configure -Dbuildtype=release build - ninja -C build @@ -59,7 +59,7 @@ arm64: stage: build image: lv2plugin/debian-arm64 script: - - meson setup build --cross-file=/usr/share/meson/cross/aarch64-linux-gnu.ini -Dbuildtype=debug -Ddocs=disabled -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/aarch64-linux-gnu.ini -Dbuildtype=debug -Ddocs=disabled -Dwarning_level=3 -Dwerror=true - ninja -C build - meson configure -Dbuildtype=release build - ninja -C build @@ -68,7 +68,7 @@ mingw32: stage: build image: lv2plugin/debian-mingw32 script: - - meson setup build --cross-file=/usr/share/meson/cross/i686-w64-mingw32.ini -Dbuildtype=debug -Ddocs=disabled -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/i686-w64-mingw32.ini -Dbuildtype=debug -Ddocs=disabled -Dwarning_level=everything -Dwerror=true - ninja -C build - meson configure -Dbuildtype=release build - ninja -C build @@ -79,7 +79,7 @@ mingw64: stage: build image: lv2plugin/debian-mingw64 script: - - meson setup build --cross-file=/usr/share/meson/cross/x86_64-w64-mingw32.ini -Dbuildtype=debug -Ddocs=disabled -Dstrict=true -Dwerror=true + - meson setup build --cross-file=/usr/share/meson/cross/x86_64-w64-mingw32.ini -Dbuildtype=debug -Ddocs=disabled -Dwarning_level=everything -Dwerror=true - ninja -C build - meson configure -Dbuildtype=release build - ninja -C build @@ -90,7 +90,7 @@ fedora: stage: build image: lv2plugin/fedora-big script: - - meson setup build -Dbuildtype=plain -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=plain -Dwarning_level=3 -Dwerror=true - ninja -C build variables: CFLAGS: -O2 -D_FORTIFY_SOURCE=2 @@ -101,7 +101,7 @@ mac: stage: build tags: [macos] script: - - meson setup build -Dbuildtype=debug -Ddocs=disabled -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=debug -Ddocs=disabled -Dwarning_level=everything -Dwerror=true - ninja -C build - meson configure -Dbuildtype=release build - ninja -C build @@ -110,7 +110,7 @@ win: stage: build tags: [windows,meson] script: - - meson setup build -Dbuildtype=debug -Ddocs=disabled -Dstrict=true -Dwerror=true + - meson setup build -Dbuildtype=debug -Ddocs=disabled -Dwarning_level=everything -Dwerror=true - ninja -C build - meson configure -Dbuildtype=release build - ninja -C build diff --git a/examples/meson.build b/examples/meson.build index b1ac7a6..5c995a9 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,4 +1,4 @@ -# Copyright 2021-2022 David Robillard <d@drobilla.net> +# Copyright 2021-2023 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC data_dir = get_option('prefix') / get_option('datadir') / 'pugl-0' @@ -35,7 +35,7 @@ includes = include_directories( # Suppress some additional C warnings in examples example_c_args = [] -if get_option('strict') +if get_option('warning_level') == 'everything' if cc.get_id() == 'clang' example_c_args += [ '-Wno-float-equal', @@ -53,7 +53,7 @@ endif # Suppress some additional C++ warnings in examples example_cpp_args = [] -if get_option('strict') and is_variable('cpp') +if get_option('warning_level') == 'everything' and is_variable('cpp') if cpp.get_id() == 'clang' example_cpp_args += [ '-Wno-documentation', # Cairo diff --git a/meson.build b/meson.build index d15ba73..bd6894d 100644 --- a/meson.build +++ b/meson.build @@ -41,11 +41,8 @@ if host_machine.system() == 'darwin' objcc = meson.get_compiler('objc') endif -# Set global ultra-strict warnings for developers if enabled -if get_option('strict') - subdir('meson/warnings') - subdir('meson/suppressions') -endif +# Set global warning suppressions +subdir('meson/suppressions') # Disable deprecated API which is not used by tests or examples add_project_arguments( diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build index 9365086..5ecb425 100644 --- a/meson/suppressions/meson.build +++ b/meson/suppressions/meson.build @@ -1,11 +1,9 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2023 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC -# 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. +# Project-specific warning suppressions + +warning_level = get_option('warning_level') ##### # C # @@ -13,60 +11,92 @@ c_suppressions = [] if cc.get_id() == 'clang' - c_suppressions += [ - '-Wno-bad-function-cast', - '-Wno-declaration-after-statement', - '-Wno-padded', - '-Wno-switch-default', - '-Wno-switch-enum', - ] - - if host_machine.system() == 'darwin' + if warning_level == 'everything' c_suppressions += [ - '-Wno-poison-system-directories', + '-Wno-bad-function-cast', + '-Wno-declaration-after-statement', + '-Wno-padded', + '-Wno-switch-default', + '-Wno-switch-enum', ] - elif host_machine.system() == 'windows' + + if not meson.is_cross_build() + c_suppressions += [ + '-Wno-poison-system-directories', + ] + endif + + if host_machine.system() == 'windows' + c_suppressions += [ + '-Wno-deprecated-declarations', + '-Wno-format-nonliteral', + '-Wno-nonportable-system-include-path', + '-Wno-unused-macros', + ] + endif + endif + +elif cc.get_id() == 'gcc' + if warning_level == 'everything' c_suppressions += [ - '-Wno-deprecated-declarations', - '-Wno-format-nonliteral', - '-Wno-nonportable-system-include-path', - '-Wno-unused-macros', + '-Wno-bad-function-cast', + '-Wno-inline', + '-Wno-padded', + '-Wno-suggest-attribute=const', + '-Wno-suggest-attribute=pure', + '-Wno-switch-default', + '-Wno-switch-enum', + '-Wno-unsuffixed-float-constants', ] + + if host_machine.system() == 'windows' + c_suppressions += [ + '-Wno-cast-function-type', + '-Wno-float-equal', + '-Wno-suggest-attribute=format', + ] + endif endif -elif cc.get_id() == 'gcc' - c_suppressions += [ - '-Wno-bad-function-cast', - '-Wno-inline', - '-Wno-padded', - '-Wno-pedantic', - '-Wno-suggest-attribute=const', - '-Wno-suggest-attribute=pure', - '-Wno-switch-default', - '-Wno-switch-enum', - '-Wno-unsuffixed-float-constants', - ] - if host_machine.system() == 'windows' + if warning_level in ['everything', '3'] c_suppressions += [ - '-Wno-cast-function-type', - '-Wno-float-equal', - '-Wno-suggest-attribute=format', + '-Wno-pedantic', ] endif + elif cc.get_id() == 'msvc' c_suppressions += [ - '/wd4061', # enumerator in switch is not explicitly handled - '/wd4090', # different const qualitifers - '/wd4191', # unsafe conversion from type to type - '/wd4514', # unreferenced inline function has been removed - '/wd4706', # assignment within conditional expression - '/wd4710', # function not inlined - '/wd4711', # function selected for automatic inline expansion - '/wd4820', # padding added after construct - '/wd4996', # POSIX name for this item is deprecated - '/wd5045', # will insert Spectre mitigation for memory load - '/wd5246', # subobject initialization should be wrapped in braces + '/experimental:external', + '/external:W0', + '/external:anglebrackets', ] + + if warning_level == 'everything' + c_suppressions += [ + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4090', # different const qualitifers + '/wd4191', # unsafe conversion from type to type + '/wd4514', # unreferenced inline function has been removed + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4820', # padding added after construct + '/wd5045', # will insert Spectre mitigation for memory load + '/wd5246', # subobject initialization should be wrapped in braces + ] + endif + + if warning_level in ['everything', '3'] + c_suppressions += [ + '/wd4100', # unreferenced formal parameter + '/wd4706', # assignment within conditional expression + ] + endif + + if warning_level in ['everything', '3', '2'] + c_suppressions += [ + '/wd4996', # POSIX name for this item is deprecated + ] + endif endif add_project_arguments( @@ -82,47 +112,72 @@ if is_variable('cpp') cpp_suppressions = [] if cpp.get_id() == 'clang' - cpp_suppressions += [ - '-Wno-inline', - '-Wno-padded', - ] - - if host_machine.system() == 'darwin' + if warning_level == 'everything' cpp_suppressions += [ - '-Wno-poison-system-directories', + '-Wno-c++98-compat-pedantic', + '-Wno-inline', + '-Wno-padded', + '-Wno-sign-conversion', ] + + if not meson.is_cross_build() + cpp_suppressions += [ + '-Wno-poison-system-directories', + ] + endif endif elif cpp.get_id() == 'gcc' - cpp_suppressions += [ - '-Wno-inline', - '-Wno-padded', - ] - - if host_machine.system() == 'windows' + if warning_level == 'everything' cpp_suppressions += [ - '-Wno-cast-function-type', - '-Wno-suggest-attribute=format', + '-Wno-inline', + '-Wno-padded', ] + + if host_machine.system() == 'windows' + cpp_suppressions += [ + '-Wno-cast-function-type', + '-Wno-suggest-attribute=format', + ] + endif endif elif cpp.get_id() == 'msvc' cpp_suppressions += [ - '/wd4061', # enumerator in switch is not explicitly handled - '/wd4191', # unsafe conversion from type to type - '/wd4514', # unreferenced inline function has been removed - '/wd4625', # copy constructor implicitly deleted - '/wd4626', # copy assignment operator implicitly deleted - '/wd4706', # assignment within conditional expression - '/wd4710', # function not inlined - '/wd4711', # function selected for automatic inline expansion - '/wd4800', # implicit conversion to bool - '/wd4820', # padding added after construct - '/wd5026', # move constructor implicitly deleted - '/wd5027', # move assignment operator implicitly deleted - '/wd5039', # pointer to potentially throwing function passed to C - '/wd5045', # will insert Spectre mitigation for memory load + '/experimental:external', + '/external:W0', + '/external:anglebrackets', ] + + if warning_level == 'everything' + cpp_suppressions += [ + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4191', # unsafe conversion from type to type + '/wd4514', # unreferenced inline function has been removed + '/wd4625', # copy constructor implicitly deleted + '/wd4626', # copy assignment operator implicitly deleted + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4800', # implicit conversion to bool + '/wd4820', # padding added after construct + '/wd5026', # move constructor implicitly deleted + '/wd5027', # move assignment operator implicitly deleted + '/wd5039', # pointer to potentially throwing function passed to C + '/wd5045', # will insert Spectre mitigation for memory load + ] + endif + + if warning_level in ['everything', '3'] + cpp_suppressions += [ + '/wd4706', # assignment within conditional expression + ] + endif + + if warning_level in ['everything', '3', '2'] + cpp_suppressions += [ + '/wd4996', # POSIX name for this item is deprecated + ] + endif endif add_project_arguments( @@ -136,15 +191,20 @@ endif ############### if is_variable('objcc') - objc_suppressions = [ - '-Wno-bad-function-cast', - '-Wno-direct-ivar-access', - '-Wno-padded', - '-Wno-pedantic', - '-Wno-poison-system-directories', - ] + if warning_level == 'everything' + objc_suppressions = [ + '-Wno-bad-function-cast', + '-Wno-direct-ivar-access', + '-Wno-objc-messaging-id', + '-Wno-padded', + '-Wno-pedantic', + '-Wno-poison-system-directories', + '-Wno-switch-enum', + '-Wno-undeclared-selector', + ] - objc_suppressions = objcc.get_supported_arguments(objc_suppressions) - add_project_arguments(objc_suppressions, language: ['objc']) - add_project_arguments(objc_suppressions, language: ['objcpp']) + objc_suppressions = objcc.get_supported_arguments(objc_suppressions) + add_project_arguments(objc_suppressions, language: ['objc']) + add_project_arguments(objc_suppressions, language: ['objcpp']) + endif endif diff --git a/meson/warnings/meson.build b/meson/warnings/meson.build deleted file mode 100644 index 094b2e6..0000000 --- a/meson/warnings/meson.build +++ /dev/null @@ -1,217 +0,0 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> -# SPDX-License-Identifier: 0BSD OR ISC - -# 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_common_warnings = [ - '-Wextra', - '-Wpedantic', - - '-Walloc-zero', - '-Walloca', - '-Wanalyzer-too-complex', - '-Warith-conversion', - '-Warray-bounds=2', - '-Wattribute-alias=2', - '-Wbidi-chars=ucn', - '-Wcast-align=strict', - '-Wcast-qual', - '-Wconversion', - '-Wdate-time', - '-Wdisabled-optimization', - '-Wdouble-promotion', - '-Wduplicated-branches', - '-Wduplicated-cond', - '-Wfloat-equal', - '-Wformat-overflow=2', - '-Wformat-signedness', - '-Wformat-truncation=2', - '-Wformat=2', - '-Winit-self', - '-Winline', - '-Winvalid-pch', - '-Wlogical-op', - '-Wmissing-declarations', - '-Wmissing-include-dirs', - '-Wmultichar', - '-Wnormalized=nfc', - '-Wnull-dereference', - '-Wopenacc-parallelism', - '-Wpacked', - '-Wpadded', - '-Wredundant-decls', - '-Wshadow', - '-Wshift-negative-value', - '-Wshift-overflow=2', - '-Wstack-protector', - '-Wstrict-aliasing=3', - '-Wstrict-overflow=5', - '-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', - '-Wundef', - '-Wuninitialized', - '-Wunsafe-loop-optimizations', - '-Wunused-const-variable=2', - '-Wunused-macros', - '-Wvector-operation-performance', - '-Wvla', - '-Wwrite-strings', -] - -##### -# C # -##### - -if is_variable('cc') and not is_variable('all_c_warnings') - all_c_warnings = [] - - if cc.get_id() == 'clang' - all_c_warnings += ['-Weverything'] - - elif cc.get_id() == 'gcc' - all_c_warnings += gcc_common_warnings + [ - '-Wbad-function-cast', - '-Wc++-compat', - '-Wmissing-prototypes', - '-Wnested-externs', - '-Wold-style-definition', - '-Wstrict-prototypes', - '-Wunsuffixed-float-constants', - ] - - elif cc.get_id() == 'msvc' - all_c_warnings += ['/Wall'] - endif - - all_c_warnings = cc.get_supported_arguments(all_c_warnings) -endif - -####### -# 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' - ] - - 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', - '-Wdeprecated-copy-dtor', - '-Wdeprecated-enum-enum-conversion', - '-Wdeprecated-enum-float-conversion', - '-Weffc++', - '-Wextra-semi', - '-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-promo', - '-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'] - endif - - all_cpp_warnings = cpp.get_supported_arguments(all_cpp_warnings) -endif - -# Set all_objc_warnings for the current Objective C compiler -if is_variable('objcc') - all_objc_warnings = [] - - if objcc.get_id() == 'clang' - all_objc_warnings += ['-Weverything'] - - elif objc.get_id() == 'gcc' - all_objc_warnings += gcc_common_warnings + [ - '-Wno-direct-ivar-access', - ] - endif - - all_objc_warnings = objcc.get_supported_arguments(all_objc_warnings) -endif diff --git a/meson_options.txt b/meson_options.txt index eac6969..bca000a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,4 @@ -# Copyright 2021-2022 David Robillard <d@drobilla.net> +# Copyright 2021-2023 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC option('cairo', type: 'feature', value: 'auto', @@ -13,12 +13,12 @@ option('docs', type: 'feature', value: 'auto', option('docs_cpp', type: 'boolean', value: false, description: 'Attempt to build C++ documentation for development') +option('lint', type: 'boolean', value: false, yield: true, + description: 'Run code quality checks') + option('opengl', type: 'feature', value: 'auto', description : 'Enable support for the OpenGL graphics API') -option('strict', type: 'boolean', value: false, - description: 'Enable ultra-strict warnings for developers') - option('stub', type: 'boolean', value: true, description: 'Build stub backend') diff --git a/test/meson.build b/test/meson.build index b22a925..02fb1b9 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,11 +1,9 @@ -# Copyright 2021 David Robillard <d@drobilla.net> +# Copyright 2021-2023 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC -reuse = find_program('reuse', required: false) - # Suppress some additional C warnings in tests test_c_args = [] -if get_option('strict') +if get_option('warning_level') == 'everything' if cc.get_id() == 'clang' test_c_args += [ '-Wno-float-equal', @@ -21,7 +19,7 @@ endif # Suppress some additional C++ warnings in tests test_cpp_args = [] -if get_option('strict') and is_variable('cpp') +if get_option('warning_level') == 'everything' and is_variable('cpp') if cpp.get_id() == 'clang' test_cpp_args += [ '-Wno-documentation', # Cairo @@ -34,8 +32,11 @@ if get_option('strict') and is_variable('cpp') endif # Check licensing metadata -if reuse.found() - test('REUSE', reuse, args: ['--root', pugl_src_root, 'lint'], suite: 'data') +if not meson.is_subproject() and get_option('lint') + reuse = find_program('reuse', required: false) + if reuse.found() + test('REUSE', reuse, args: ['--root', pugl_src_root, 'lint'], suite: 'data') + endif endif basic_exclusive_tests = [ |