diff options
| author | David Robillard <d@drobilla.net> | 2025-11-13 19:52:34 -0500 |
|---|---|---|
| committer | David Robillard <d@drobilla.net> | 2025-11-13 20:04:39 -0500 |
| commit | 5942f4c2e868f84141117a04b71077c233c1760d (patch) | |
| tree | c096fc97c74ed487df418cd8cf088be558217382 | |
| parent | 46ab5fa6820e069ae4e97a26712b03144a34a04f (diff) | |
| download | lv2-5942f4c2e868f84141117a04b71077c233c1760d.tar.xz | |
Avoid checking for tools and options that won't be used
With many components disabled, configuration checked for many programs and
compiler flags that weren't actually used for anything. This is slow, and
makes simple builds look a lot more complicated than they are. So, rework
things to only check for tools and flags that will actually be used.
Mainly this is to make the package nice to use as a subproject.
| -rw-r--r-- | doc/c/meson.build | 2 | ||||
| -rw-r--r-- | meson.build | 262 | ||||
| -rw-r--r-- | test/meson.build | 164 |
3 files changed, 220 insertions, 208 deletions
diff --git a/doc/c/meson.build b/doc/c/meson.build index da88b86..2642c3a 100644 --- a/doc/c/meson.build +++ b/doc/c/meson.build @@ -1,8 +1,6 @@ # Copyright 2022 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC -lv2_source_doc = meson.current_source_dir() - if doxygen.found() reference_doxygen_in = files('reference.doxygen.in') diff --git a/meson.build b/meson.build index 572d19e..669c139 100644 --- a/meson.build +++ b/meson.build @@ -20,163 +20,23 @@ lv2_docdir = get_option('datadir') / 'doc' / 'lv2' lv2_source_root = meson.current_source_dir() lv2_build_root = meson.current_build_dir() -############################# -# Compilers and Build Tools # -############################# - -# Required tools -pkg = import('pkgconfig') -pymod = import('python') -cc = meson.get_compiler('c') - -# Optional C++ compiler and Python tools for tests -if not get_option('tests').disabled() - if add_languages(['cpp'], native: false, required: get_option('tests')) - cpp = meson.get_compiler('cpp') - endif -endif - -######################## -# Warning Suppressions # -######################## - -warning_level = get_option('warning_level') - -# C -c_suppressions = [] -if cc.get_id() in ['clang', 'emscripten'] - if warning_level == 'everything' - c_suppressions += [ - '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-declaration-after-statement', - '-Wno-documentation-unknown-command', - '-Wno-double-promotion', - '-Wno-float-equal', - '-Wno-padded', - '-Wno-reserved-id-macro', - '-Wno-sign-conversion', - '-Wno-unsafe-buffer-usage', - ] - - if not meson.is_cross_build() - c_suppressions += ['-Wno-poison-system-directories'] - endif - - if host_machine.system() == 'windows' - c_suppressions += ['-Wno-format-nonliteral'] - endif - endif - - if warning_level in ['everything', '3', '2'] - c_suppressions += ['-Wno-unused-parameter'] - endif - -elif cc.get_id() == 'gcc' - if warning_level == 'everything' - c_suppressions += [ - '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-double-promotion', - '-Wno-float-equal', - '-Wno-inline', - '-Wno-padded', - '-Wno-suggest-attribute=const', - '-Wno-suggest-attribute=malloc', - '-Wno-suggest-attribute=pure', - '-Wno-unsuffixed-float-constants', - '-Wno-unused-const-variable', - ] - - if target_machine.system() == 'windows' - c_suppressions += [ - '-Wno-sign-conversion', - '-Wno-suggest-attribute=format', - ] - endif - endif - - if warning_level in ['everything', '3', '2'] - c_suppressions += ['-Wno-unused-parameter'] - endif - -elif cc.get_id() == 'msvc' - if warning_level == 'everything' - c_suppressions += [ - '/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 - ] - endif - - if warning_level in ['everything', '3'] - c_suppressions += [ - '/wd4100', # unreferenced formal parameter - ] - endif - - if warning_level in ['everything', '3', '2'] - c_suppressions += [ - '/wd4267', # conversion from size_t to a smaller type - ] - endif -endif +installing_anything = ( + get_option('bundles') or + get_option('headers') or + get_option('old_headers') +) -c_suppressions = cc.get_supported_arguments(c_suppressions) - -# C++ -if is_variable('cpp') - cpp_suppressions = [] - - if warning_level == 'everything' - if cpp.get_id() in ['clang', 'emscripten'] - cpp_suppressions += [ - '-Wno-c++98-compat', - '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-documentation-unknown-command', - '-Wno-nullability-extension', - '-Wno-padded', - '-Wno-reserved-id-macro', - '-Wno-unsafe-buffer-usage', - ] - - if not meson.is_cross_build() - cpp_suppressions += ['-Wno-poison-system-directories'] - endif - - if host_machine.system() == 'windows' - cpp_suppressions += ['-Wno-format-nonliteral'] - endif - - elif cpp.get_id() == 'gcc' - cpp_suppressions += [ - '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-inline', - '-Wno-padded', - '-Wno-unused-const-variable', - '-Wno-useless-cast', - ] - - if target_machine.system() == 'windows' - cpp_suppressions += ['-Wno-suggest-attribute=format'] - endif - - elif cpp.get_id() == 'msvc' - cpp_suppressions += [ - '/wd4514', # unreferenced inline function has been removed - '/wd4710', # function not inlined - '/wd4711', # function selected for automatic inline expansion - '/wd4820', # padding added after data member - '/wd5045', # will insert Spectre mitigation - ] - endif - endif +############### +# Build Tools # +############### - cpp_suppressions = cpp.get_supported_arguments(cpp_suppressions) +pymod = disabler() +if ( + get_option('bundles') + or get_option('lint') + or not get_option('docs').disabled() +) + pymod = import('python') endif ########################## @@ -202,7 +62,8 @@ endif ###################### # Generate pkg-config file for external dependants -if get_option('bundles') or get_option('headers') or get_option('old_headers') +if installing_anything + pkg = import('pkgconfig') pkg.generate( description: 'Plugin standard for audio systems', filebase: 'lv2', @@ -328,38 +189,41 @@ subdir('schemas.lv2') lv2_check_specification = files('scripts' / 'lv2_check_specification.py') -check_python = pymod.find_installation( - 'python3', - modules: ['rdflib'], - required: get_option('tests'), -) - -if ( - check_python.found() - and check_python.language_version().version_compare('<3.7') -) - warning('Python 3.7 is required for tests') +if get_option('bundles') check_python = disabler() -endif - -foreach bundle_name : all_spec_names - bundle = 'lv2' / bundle_name + '.lv2' + if not get_option('tests').disabled() + check_python = pymod.find_installation( + 'python3', + modules: ['rdflib'], + required: get_option('tests'), + ) - # Check specification - if check_python.found() - test( - bundle_name, - lv2_check_specification, - args: files(bundle / 'manifest.ttl'), - suite: ['spec'], + if ( + check_python.found() + and check_python.language_version().version_compare('<3.7') ) + warning('Python 3.7 is required for tests') + check_python = disabler() + endif endif - # Install specification bundle - if get_option('bundles') + foreach bundle_name : all_spec_names + bundle = 'lv2' / bundle_name + '.lv2' + + # Check specification + if check_python.found() + test( + bundle_name, + lv2_check_specification, + args: files(bundle / 'manifest.ttl'), + suite: ['spec'], + ) + endif + + # Install specification bundle install_subdir(bundle, install_dir: lv2dir) - endif -endforeach + endforeach +endif spec_files = files( 'lv2/atom.lv2/atom.meta.ttl', @@ -443,40 +307,34 @@ spec_files = files( ################# # Determine if all the dependencies for building documentation are present -doxygen = find_program('doxygen', required: get_option('docs')) build_docs = false -build_lv2specgen = false -doc_deps = [] if not get_option('docs').disabled() - doc_python_modules = ['lxml', 'markdown', 'pygments', 'rdflib'] - - python = pymod.find_installation( + doxygen = find_program('doxygen', required: get_option('docs')) + doc_python = pymod.find_installation( 'python3', - modules: doc_python_modules, + modules: ['lxml', 'markdown', 'pygments', 'rdflib'], required: get_option('docs'), ) - if python.found() and python.language_version().version_compare('<3.7') + build_docs = doxygen.found() and doc_python.found() + if doc_python.found() and doc_python.language_version().version_compare('<3.7') warning('Python 3.7 is required for documentation') build_docs = false endif - - build_docs = doxygen.found() and python.found() - build_lv2specgen = python.found() endif -# Run Doxygen first to generate tags -subdir('doc/c') +if build_docs + # Run Doxygen first to generate tags + subdir('doc/c') -# Set up lv2specgen and lv2specgen_command_prefix (which references tags) -if build_lv2specgen + # Set up lv2specgen and lv2specgen_command_prefix (which references tags) subdir('lv2specgen') -endif -# Generate specification documentation -if build_docs - subdir('doc/style') - subdir('doc/ns') + # Generate specification documentation + if build_docs + subdir('doc/style') + subdir('doc/ns') + endif endif ############ diff --git a/test/meson.build b/test/meson.build index c4a483d..7144349 100644 --- a/test/meson.build +++ b/test/meson.build @@ -68,6 +68,163 @@ if get_option('lint') endif endif +############################# +# Compilers and Build Tools # +############################# + +cc = meson.get_compiler('c') + +if add_languages(['cpp'], native: false, required: get_option('tests')) + cpp = meson.get_compiler('cpp') +endif + +######################## +# Warning Suppressions # +######################## + +warning_level = get_option('warning_level') + +# C +test_c_suppressions = [] +if cc.get_id() in ['clang', 'emscripten'] + if warning_level == 'everything' + test_c_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-declaration-after-statement', + '-Wno-documentation-unknown-command', + '-Wno-double-promotion', + '-Wno-float-equal', + '-Wno-padded', + '-Wno-reserved-id-macro', + '-Wno-unsafe-buffer-usage', + ] + + if not meson.is_cross_build() + test_c_suppressions += ['-Wno-poison-system-directories'] + endif + + if host_machine.system() == 'windows' + test_c_suppressions += ['-Wno-format-nonliteral'] + endif + endif + + if warning_level in ['everything', '3', '2'] + test_c_suppressions += ['-Wno-unused-parameter'] + endif + +elif cc.get_id() == 'gcc' + if warning_level == 'everything' + test_c_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-double-promotion', + '-Wno-float-equal', + '-Wno-inline', + '-Wno-padded', + '-Wno-suggest-attribute=const', + '-Wno-suggest-attribute=malloc', + '-Wno-suggest-attribute=pure', + '-Wno-unsuffixed-float-constants', + '-Wno-unused-const-variable', + ] + + if target_machine.system() == 'windows' + test_c_suppressions += [ + '-Wno-sign-conversion', + '-Wno-suggest-attribute=format', + ] + endif + endif + + if warning_level in ['everything', '3', '2'] + test_c_suppressions += ['-Wno-unused-parameter'] + endif + +elif cc.get_id() == 'msvc' + if warning_level == 'everything' + test_c_suppressions += [ + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4244', # conversion with possible loss of data + '/wd4365', # signed/unsigned mismatch + '/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 + ] + endif + + if warning_level in ['everything', '3'] + test_c_suppressions += [ + '/wd4100', # unreferenced formal parameter + ] + endif + + if warning_level in ['everything', '3', '2'] + test_c_suppressions += [ + '/wd4267', # conversion from size_t to a smaller type + ] + endif +endif + +test_c_suppressions = cc.get_supported_arguments(test_c_suppressions) + +# C++ +if is_variable('cpp') + test_cpp_suppressions = [] + + if warning_level == 'everything' + if cpp.get_id() in ['clang', 'emscripten'] + test_cpp_suppressions += [ + '-Wno-c++98-compat', + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-documentation-unknown-command', + '-Wno-nullability-extension', + '-Wno-padded', + '-Wno-reserved-id-macro', + '-Wno-unsafe-buffer-usage', + ] + + if not meson.is_cross_build() + test_cpp_suppressions += ['-Wno-poison-system-directories'] + endif + + if host_machine.system() == 'windows' + test_cpp_suppressions += ['-Wno-format-nonliteral'] + endif + + elif cpp.get_id() == 'gcc' + test_cpp_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-inline', + '-Wno-padded', + '-Wno-unused-const-variable', + '-Wno-useless-cast', + ] + + if target_machine.system() == 'windows' + test_cpp_suppressions += ['-Wno-suggest-attribute=format'] + endif + + elif cpp.get_id() == 'msvc' + test_cpp_suppressions += [ + '/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 data member + '/wd5045', # will insert Spectre mitigation + '/wd5264', # const variable is not used + ] + endif + endif + + test_cpp_suppressions = cpp.get_supported_arguments(test_cpp_suppressions) +endif + ######## # Code # ######## @@ -78,7 +235,7 @@ test( executable( 'test_build_c', files('test_build.c'), - c_args: c_suppressions, + c_args: test_c_suppressions, dependencies: [lv2_dep], implicit_include_directories: false, ), @@ -92,7 +249,7 @@ if is_variable('cpp') executable( 'test_build_cpp', files('cpp/test_build.cpp'), - cpp_args: cpp_suppressions, + cpp_args: test_cpp_suppressions, dependencies: [lv2_dep], implicit_include_directories: false, ), @@ -131,7 +288,6 @@ if get_option('lint') # Check scripts for errors with pylint pylint = find_program('pylint', required: get_option('tests')) if pylint.found() - pymod = import('python') lint_py = pymod.find_installation( 'python3', modules: ['pygments', 'rdflib'], @@ -171,7 +327,7 @@ foreach test_name : test_names executable( test_name, files('test_@0@.c'.format(test_name)), - c_args: c_suppressions + atom_test_suppressions, + c_args: test_c_suppressions + atom_test_suppressions, dependencies: [lv2_dep], implicit_include_directories: false, ), |