diff options
author | David Robillard <d@drobilla.net> | 2022-07-15 07:42:23 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-17 13:50:43 -0400 |
commit | 0579dca6a5fae625efbbfe3b31167d855c8f966d (patch) | |
tree | bcf69a28dfb65f941e9540986a693fd4c612eb50 | |
parent | e1bcda7bd5ed51bf60157605bb087d2312e15e59 (diff) | |
download | jalv-0579dca6a5fae625efbbfe3b31167d855c8f966d.tar.gz jalv-0579dca6a5fae625efbbfe3b31167d855c8f966d.tar.bz2 jalv-0579dca6a5fae625efbbfe3b31167d855c8f966d.zip |
Switch to meson build system
-rw-r--r-- | .clang-tidy | 3 | ||||
-rw-r--r-- | .gitignore | 13 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | .reuse/dep5 | 4 | ||||
-rw-r--r-- | INSTALL | 59 | ||||
-rw-r--r-- | INSTALL.md | 70 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | doc/meson.build | 16 | ||||
-rw-r--r-- | meson.build | 364 | ||||
-rw-r--r-- | meson/suppressions/meson.build | 146 | ||||
-rw-r--r-- | meson/warnings/meson.build | 238 | ||||
-rw-r--r-- | meson_options.txt | 35 | ||||
-rw-r--r-- | src/control.c | 2 | ||||
-rw-r--r-- | src/jack.c | 12 | ||||
-rw-r--r-- | src/jalv.c | 26 | ||||
-rw-r--r-- | src/jalv_config.h | 169 | ||||
-rw-r--r-- | src/jalv_console.c | 22 | ||||
-rw-r--r-- | src/jalv_internal.h | 4 | ||||
-rw-r--r-- | src/log.c | 8 | ||||
-rw-r--r-- | src/portaudio.c | 1 | ||||
-rw-r--r-- | src/zix/ring.c | 2 | ||||
-rw-r--r-- | subprojects/lilv.wrap | 9 | ||||
-rw-r--r-- | subprojects/lv2.wrap | 9 | ||||
-rw-r--r-- | subprojects/serd.wrap | 9 | ||||
-rw-r--r-- | subprojects/sord.wrap | 9 | ||||
-rw-r--r-- | subprojects/sratom.wrap | 9 | ||||
-rw-r--r-- | subprojects/suil.wrap | 9 | ||||
-rw-r--r-- | test/meson.build | 14 | ||||
-rwxr-xr-x | waf | 30 | ||||
m--------- | waflib | 0 | ||||
-rw-r--r-- | wscript | 424 |
31 files changed, 1160 insertions, 562 deletions
diff --git a/.clang-tidy b/.clang-tidy index a097be9..0b547da 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,11 +10,10 @@ Checks: > -bugprone-branch-clone, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, - -cert-dcl37-c, - -cert-dcl51-cpp, -cert-err33-c, -cert-err34-c, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, + -clang-analyzer-valist.Uninitialized, -concurrency-mt-unsafe, -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-owning-memory, @@ -1,4 +1,9 @@ -build/** -.waf-* -.lock-waf* -__pycache__ +# Copyright 2019-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +build/ +subprojects/lilv/ +subprojects/lv2/ +subprojects/serd/ +subprojects/sord/ +subprojects/sratom/ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index b2babe7..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "waflib"] - path = waflib - url = ../autowaf.git diff --git a/.reuse/dep5 b/.reuse/dep5 index 5e6fc0b..1dd8e43 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -3,10 +3,10 @@ Upstream-Name: jalv Upstream-Contact: David Robillard <d@drobilla.net> Source: https://gitlab.com/drobilla/jalv -Files: jalv.desktop.in .clang* *.md .clant.json .git* INSTALL NEWS AUTHORS +Files: .clang* .clant.json .gitignore AUTHORS NEWS jalv.desktop.in meson_options.txt Copyright: 2010-2022 David Robillard <d@drobilla.net> License: CC0-1.0 OR ISC -Files: doc/*.1 +Files: INSTALL.md README.md doc/*.1 Copyright: 2011-2020 David Robillard <d@drobilla.net> License: ISC diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 623cddd..0000000 --- a/INSTALL +++ /dev/null @@ -1,59 +0,0 @@ -Installation Instructions -========================= - -Basic Installation ------------------- - -Building this software requires only Python. To install with default options: - - ./waf configure - ./waf - ./waf install - -You may need to become root for the install stage, for example: - - sudo ./waf install - -Configuration Options ---------------------- - -All supported options can be viewed using the command: - - ./waf --help - -Most options only need to be passed during the configure stage, for example: - - ./waf configure --prefix=/usr - ./waf - ./waf install - -Compiler Configuration ----------------------- - -Several standard environment variables can be used to control how compilers are -invoked: - - * CC: Path to C compiler - * CFLAGS: C compiler options - * CXX: Path to C++ compiler - * CXXFLAGS: C++ compiler options - * CPPFLAGS: C preprocessor options - * LINKFLAGS: Linker options - -Installation Directories ------------------------- - -The --prefix option (or the PREFIX environment variable) can be used to change -the prefix which all files are installed under. There are also several options -allowing for more fine-tuned control, see the --help output for details. - -Packaging ---------- - -Everything can be installed to a specific root directory by passing a --destdir -option to the install stage (or setting the DESTDIR environment variable), -which adds a prefix to all install paths. For example: - - ./waf configure --prefix=/usr - ./waf - ./waf install --destdir=/tmp/package diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..7109c35 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,70 @@ +Installation Instructions +========================= + +Prerequisites +------------- + +To build from source, you will need: + + * A relatively modern C compiler (GCC, Clang, and MSVC are known to work). + + * [Meson](http://mesonbuild.com/), which depends on + [Python](http://python.org/). + +This is a brief overview of building this project with meson. See the meson +documentation for more detailed information. + +Configuration +------------- + +The build is configured with the `setup` command, which creates a new build +directory with the given name: + + meson setup build + +Some environment variables are read during `setup` and stored with the +configuration: + + * `CC`: Path to C compiler. + * `CFLAGS`: C compiler options. + * `LDFLAGS`: Linker options. + +However, it is better to use meson options for configuration. All options can +be inspected with the `configure` command from within the build directory: + + cd build + meson configure + +Options can be set by passing C-style "define" options to `configure`: + + meson configure -Dc_args="-march=native" -Dprefix="/opt/mypackage/" + +Building +-------- + +From within a configured build directory, everything can be built with the +`compile` command: + + meson compile + +Similarly, tests can be run with the `test` command: + + meson test + +Meson can also generate a project for several popular IDEs, see the `backend` +option for details. + +Installation +------------ + +A compiled project can be installed with the `install` command: + + meson install + +You may need to acquire root permissions to install to a system-wide prefix. +For packaging, the installation may be staged to a directory using the +`DESTDIR` environment variable or the `--destdir` option: + + DESTDIR=/tmp/mypackage/ meson install + + meson install --destdir=/tmp/mypackage/ @@ -14,8 +14,9 @@ jalv (1.6.7) unstable; * Print status information consistently to stdout * Remove Gtkmm interface * Remove Qt4 support + * Switch to meson build system - -- David Robillard <d@drobilla.net> Wed, 20 Jul 2022 19:47:00 +0000 + -- David Robillard <d@drobilla.net> Wed, 20 Jul 2022 19:49:03 +0000 jalv (1.6.6) stable; diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 0000000..58d7dc1 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,16 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +install_man('jalv.1') + +if not get_option('gtk2').disabled() + install_man('jalv.gtk.1') +endif + +if not get_option('gtk3').disabled() + install_man('jalv.gtk3.1') +endif + +if not get_option('qt5').disabled() + install_man('jalv.qt5.1') +endif diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..6d017f9 --- /dev/null +++ b/meson.build @@ -0,0 +1,364 @@ +# Copyright 2020-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +project('jalv', ['c', 'cpp'], + version: '1.6.7', + license: 'ISC', + meson_version: '>= 0.56.0', + default_options: [ + 'b_ndebug=if-release', + 'buildtype=release', + 'c_std=c99', + 'cpp_std=c++14', + ]) + +jalv_src_root = meson.current_source_dir() +major_version = meson.project_version().split('.')[0] +version_suffix = '@0@-@1@'.format(meson.project_name(), major_version) + +####################### +# Compilers and Flags # +####################### + +# Required tools +cc = meson.get_compiler('c') + +# Optional C++ support +if add_languages(['cpp'], native: false, required: get_option('cxx')) + cpp = meson.get_compiler('cpp') +endif + +# Set global warning flags +if get_option('strict') and not meson.is_subproject() + subdir('meson/warnings') +endif + +# Set global warning suppressions +subdir('meson/suppressions') +add_project_arguments(c_suppressions, language: ['c']) +if is_variable('cpp') + add_project_arguments(cpp_suppressions, language: ['cpp']) +endif + +####################### +# Common Dependencies # +####################### + +m_dep = cc.find_library('m', required: false) + +thread_dep = dependency('threads') + +lv2_dep = dependency('lv2', + version: '>= 1.18.0', + fallback: ['lv2', 'lv2_dep']) + +lilv_dep = dependency('lilv-0', + version: '>= 0.24.0', + fallback: ['lilv', 'lilv_dep']) + +serd_dep = dependency('serd-0', + version: '>= 0.30.0', + fallback: ['serd', 'serd_dep']) + +sord_dep = dependency('sord-0', + version: '>= 0.14.0', + fallback: ['sord', 'sord_dep']) + +sratom_dep = dependency('sratom-0', + version: '>= 0.6.4', + fallback: ['sratom', 'sratom_dep']) + +suil_dep = dependency('suil-0', + version: '>= 0.10.0', + fallback: ['suil', 'suil_dep'], + required: get_option('suil')) + +########### +# Drivers # +########### + +portaudio_dep = dependency('portaudio-2.0', + version: '>= 2.0.0', + include_type: 'system', + required: get_option('portaudio')) + +jack_dep = dependency('jack', + version: '>= 0.120.0', + include_type: 'system', + required: get_option('jack')) + +backend_sources = files() +if get_option('jack').enabled() and get_option('portaudio').enabled() + error('Only one of jack and portaudio can be enabled') +elif get_option('jack').enabled() + backend_dep = jack_dep + backend_sources += files('src/jack.c') +elif get_option('portaudio').enabled() + backend_dep = portaudio_dep + backend_sources += files('src/portaudio.c') +elif jack_dep.found() + backend_dep = jack_dep + backend_sources += files('src/jack.c') +else + backend_dep = portaudio_dep + backend_sources += files('src/portaudio.c') +endif + +if not backend_dep.found() + error('No backend found, either jack or portaudio is required') +endif + +########################## +# Platform Configuration # +########################## + +platform_defines = [ + '-DJALV_VERSION="@0@"'.format(meson.project_version()), + '-DZIX_STATIC', +] + +suil_defines = ['-DHAVE_SUIL=@0@'.format(suil_dep.found().to_int())] + +# Determine whether to use POSIX +no_posix = get_option('posix').disabled() or host_machine.system() == 'windows' +if no_posix + platform_defines += ['-DJALV_NO_POSIX'] +elif host_machine.system() == 'darwin' + platform_defines += [ + '-D_DARWIN_C_SOURCE', + '-D_POSIX_C_SOURCE=200809L', + '-D_XOPEN_SOURCE=600', + ] +else + platform_defines += [ + '-D_BSD_SOURCE', + '-D_DEFAULT_SOURCE', + '-D_POSIX_C_SOURCE=200809L', + '-D_XOPEN_SOURCE=600', + ] +endif + +# Check for platform features with the build system +if get_option('checks') + platform_defines += [ + '-DJALV_NO_DEFAULT_CONFIG', + ] + + fileno_code = '''#include <stdio.h> +int main(void) { return fileno(stdin); }''' + + isatty_code = '''#include <unistd.h> +int main(void) { return isatty(0); }''' + + mlock_code = '''#include <sys/mman.h> +int main(void) { return mlock(0, 0); }''' + + posix_memalign_code = '''#include <stdlib.h> +int main(void) { void* mem; posix_memalign(&mem, 8, 8); }''' + + sigaction_code = '''#include <signal.h> +int main(void) { return sigaction(SIGINT, 0, 0); }''' + + jack_metadata_code = '''#include <jack/metadata.h> +int main(void) { return !!&jack_set_property; }''' + + jack_port_type_get_buffer_size_code = '''#include <jack/jack.h> +int main(void) { return !!&jack_port_type_get_buffer_size; }''' + + platform_defines += '-DHAVE_FILENO=@0@'.format( + cc.compiles(fileno_code, + args: platform_defines, + name: 'fileno').to_int()) + + platform_defines += '-DHAVE_ISATTY=@0@'.format( + cc.compiles(isatty_code, + args: platform_defines, + name: 'isatty').to_int()) + + platform_defines += '-DHAVE_MLOCK=@0@'.format( + cc.compiles(mlock_code, + args: platform_defines, + name: 'mlock').to_int()) + + platform_defines += '-DHAVE_POSIX_MEMALIGN=@0@'.format( + cc.compiles(posix_memalign_code, + args: platform_defines, + name: 'posix_memalign').to_int()) + + platform_defines += '-DHAVE_SIGACTION=@0@'.format( + cc.compiles(sigaction_code, + args: platform_defines, + name: 'sigaction').to_int()) + + platform_defines += '-DHAVE_JACK_METADATA=@0@'.format( + cc.compiles(jack_metadata_code, + args: platform_defines, + name: 'jack_metadata').to_int()) + + platform_defines += '-DHAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE=@0@'.format( + cc.compiles(jack_port_type_get_buffer_size_code, + args: platform_defines, + name: 'jack_port_type_get_buffer_size').to_int()) +endif + +############ +# Programs # +############ + +sources = backend_sources + files( + 'src/control.c', + 'src/jalv.c', + 'src/log.c', + 'src/lv2_evbuf.c', + 'src/state.c', + 'src/symap.c', + 'src/worker.c', + 'src/zix/ring.c', +) + +common_dependencies = [ + backend_dep, + lilv_dep, + m_dep, + thread_dep, +] + +# Internal JACK client library +if jack_dep.found() + shared_library( + 'jalv', + sources + files('src/jalv_console.c'), + c_args: c_suppressions + platform_defines + ['-DHAVE_SUIL=0'], + dependencies: common_dependencies, + include_directories: include_directories('src'), + install: true, + install_dir: get_option('prefix') / get_option('libdir') / 'jack', + name_prefix: '', + ) +endif + +# Console version +executable( + 'jalv', + sources + files('src/jalv_console.c'), + c_args: c_suppressions + platform_defines + suil_defines, + dependencies: common_dependencies + [suil_dep], + include_directories: include_directories('src'), + install: true, +) + +# Gtk 2.0 GUI version +if not get_option('gtk2').disabled() + gdk2_dep = dependency('gdk-2.0', + version: '>= 2.18.0', + include_type: 'system', + required: get_option('gtk2')) + + gtk2_dep = dependency('gtk+-2.0', + version: '>= 2.18.0', + include_type: 'system', + required: get_option('gtk2')) + + if gdk2_dep.found() and gtk2_dep.found() + executable( + 'jalv.gtk', + sources + files('src/jalv_gtk.c'), + c_args: c_suppressions + platform_defines + suil_defines, + dependencies: common_dependencies + [gdk2_dep, gtk2_dep, suil_dep], + include_directories: include_directories('src'), + install: true, + ) + endif +endif + +# Gtk 3.0 GUI version +if not get_option('gtk3').disabled() + gdk3_dep = dependency('gdk-3.0', + version: '>= 3.0.0', + include_type: 'system', + required: get_option('gtk3')) + + gtk3_dep = dependency('gtk+-3.0', + version: '>= 3.0.0', + include_type: 'system', + required: get_option('gtk3')) + + if gdk3_dep.found() and gtk3_dep.found() + config = configuration_data() + config.set('APP_INSTALL_NAME', 'jalv.gtk3') + config.set('APP_HUMAN_NAME', 'Jalv') + config.set('BINDIR', get_option('prefix') / get_option('bindir')) + + configure_file(configuration: config, + input: files('jalv.desktop.in'), + output: 'jalv.desktop', + install: true, + install_dir: get_option('datadir') / 'applications') + + executable( + 'jalv.gtk3', + sources + files('src/jalv_gtk.c'), + c_args: c_suppressions + platform_defines + suil_defines, + dependencies: common_dependencies + [gdk3_dep, gtk3_dep, suil_dep], + include_directories: include_directories('src'), + install: true, + ) + endif +endif + +# Qt 5 GUI version +if not get_option('qt5').disabled() + qt5_dep = dependency('Qt5Widgets', + version: '>= 5.1.0', + include_type: 'system', + required: get_option('qt5')) + + moc = find_program('moc-qt5', required: false) + if not moc.found() + moc = find_program('moc', required: get_option('qt5')) + endif + + if moc.found() + jalv_qt_hpp = files(jalv_src_root / 'src' / 'jalv_qt.hpp') + + jalv_qt5_meta_cpp = custom_target( + 'jalv_qt5_meta.cpp', + capture: true, + command: [moc, '@INPUT@'], + input: jalv_qt_hpp, + output: 'jalv_qt5_meta.cpp', + ) + + executable( + 'jalv.qt5', + sources + files('src/jalv_qt.cpp') + [jalv_qt5_meta_cpp], + c_args: c_suppressions + platform_defines + suil_defines, + cpp_args: cpp_suppressions + platform_defines + suil_defines, + dependencies: common_dependencies + [qt5_dep, suil_dep], + include_directories: include_directories('src'), + install: true, + ) + endif +endif + +################# +# Documentation # +################# + +subdir('doc') + +######### +# Tests # +######### + +if not get_option('tests').disabled() + subdir('test') +endif + +if not meson.is_subproject() + summary('Install prefix', get_option('prefix')) + summary('Executables', get_option('prefix') / get_option('bindir')) + summary('Man pages', get_option('prefix') / get_option('mandir')) + + summary('Backend', backend_dep.name()) +endif diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build new file mode 100644 index 0000000..1981e64 --- /dev/null +++ b/meson/suppressions/meson.build @@ -0,0 +1,146 @@ +# Copyright 2020-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 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. + +clang_common_suppressions = [ + '-Wno-atomic-implicit-seq-cst', + '-Wno-c99-extensions', + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-disabled-macro-expansion', + '-Wno-documentation-unknown-command', + '-Wno-double-promotion', + '-Wno-float-conversion', + '-Wno-float-equal', + '-Wno-format-nonliteral', + '-Wno-implicit-fallthrough', + '-Wno-implicit-float-conversion', + '-Wno-nullability-extension', + '-Wno-padded', + '-Wno-redundant-parens', + '-Wno-reserved-id-macro', + '-Wno-reserved-identifier', + '-Wno-shorten-64-to-32', + '-Wno-sign-conversion', + '-Wno-switch-enum', + '-Wno-unknown-warning-option', + '-Wno-unused-macros', + '-Wno-unused-parameter', +] + +gcc_common_suppressions = [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-conversion', + '-Wno-double-promotion', + '-Wno-float-conversion', + '-Wno-float-equal', + '-Wno-inline', + '-Wno-padded', + '-Wno-pedantic', + '-Wno-stack-protector', + '-Wno-switch-default', + '-Wno-switch-enum', + '-Wno-unused-macros', + '-Wno-unused-parameter', +] + +if host_machine.system() == 'darwin' + clang_common_suppressions += [ + '-Wno-documentation', # JACK + '-Wno-documentation-deprecated-sync', # JACK + ] +elif host_machine.system() == 'freebsd' + clang_common_suppressions += [ + '-Wno-c11-extensions', # isnan and friends + ] +endif + +##### +# C # +##### + +if is_variable('cc') + c_suppressions = [] + + if get_option('strict') + if cc.get_id() == 'clang' + c_suppressions += clang_common_suppressions + [ + '-Wno-bad-function-cast', + '-Wno-declaration-after-statement', + '-Wno-missing-noreturn', + ] + + elif cc.get_id() == 'gcc' + c_suppressions += gcc_common_suppressions + [ + '-Wno-array-bounds', + '-Wno-bad-function-cast', + '-Wno-c++-compat', + '-Wno-format-nonliteral', + '-Wno-strict-overflow', + '-Wno-suggest-attribute=const', + '-Wno-suggest-attribute=pure', + '-Wno-unsuffixed-float-constants', + '-Wno-unused-const-variable', + ] + + elif cc.get_id() == 'msvc' + c_suppressions += [ + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4090', # different const qualifiers + '/wd4100', # unreferenced formal parameter + '/wd4191', # unsafe function conversion + '/wd4200', # zero-sized array in struct/union + '/wd4242', # possible loss of data from float conversion + '/wd4244', # possible loss of data from integer conversion + '/wd4267', # possible loss of data from size conversion + '/wd4365', # signed/unsigned mismatch + '/wd4514', # unreferenced inline function has been removed + '/wd4706', # assignment within conditional expression + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4800', # implicit conversion from int to bool + '/wd4820', # padding added after construct + '/wd4996', # POSIX name for this item is deprecated + '/wd5045', # compiler will insert Spectre mitigation + ] + endif + endif + + c_suppressions = cc.get_supported_arguments(c_suppressions) +endif + +####### +# C++ # +####### + +if is_variable('cpp') + cpp_suppressions = [] + + if get_option('strict') + if cpp.get_id() == 'clang' + cpp_suppressions = clang_common_suppressions + [ + '-Wno-extra-semi-stmt', + '-Wno-old-style-cast', + '-Wno-weak-vtables', + '-Wno-zero-as-null-pointer-constant', + ] + + elif cpp.get_id() == 'gcc' + cpp_suppressions = gcc_common_suppressions + [ + '-Wno-effc++', + '-Wno-strict-overflow', + '-Wno-suggest-attribute=const', + '-Wno-suggest-attribute=pure', + '-Wno-unused-const-variable', + ] + endif + endif + + cpp_suppressions = cpp.get_supported_arguments(cpp_suppressions) +endif diff --git a/meson/warnings/meson.build b/meson/warnings/meson.build new file mode 100644 index 0000000..c4863e6 --- /dev/null +++ b/meson/warnings/meson.build @@ -0,0 +1,238 @@ +# Copyright 2020-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 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 = [ + '-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('cc') and not is_variable('all_c_warnings') + all_c_warnings = [] + + if cc.get_id() == 'clang' + all_c_warnings += ['-Weverything'] + + if not meson.is_cross_build() + all_c_warnings += [ + '-Wno-poison-system-directories', + ] + endif + + elif cc.get_id() == 'gcc' + all_c_warnings += gcc_common_warnings + [ + '-Wabsolute-value', + '-Wbad-function-cast', + '-Wc++-compat', + '-Wenum-conversion', + '-Wjump-misses-init', + '-Wmissing-parameter-type', + '-Wmissing-prototypes', + '-Wnested-externs', + '-Wold-style-declaration', + '-Wold-style-definition', + '-Woverride-init', + '-Wsign-compare', + '-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) + add_global_arguments(all_c_warnings, language: ['c']) +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' + ] + + 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'] + endif + + all_cpp_warnings = cpp.get_supported_arguments(all_cpp_warnings) +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..9cdbe2f --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,35 @@ +option('checks', type: 'boolean', value: true, yield: true, + description: 'Check for features with the build system') + +option('cxx', type: 'feature', value: 'auto', yield: true, + description: 'Build C++ programs') + +option('gtk2', type: 'feature', value: 'auto', yield: true, + description: 'Build Gtk2 GUI') + +option('gtk3', type: 'feature', value: 'auto', yield: true, + description: 'Build Gtk3 GUI') + +option('portaudio', type: 'feature', value: 'auto', yield: true, + description: 'Build PortAudio driver') + +option('jack', type: 'feature', value: 'auto', yield: true, + description: 'Build JACK driver') + +option('posix', type: 'feature', value: 'auto', yield: true, + description: 'Use POSIX system facilities') + +option('qt5', type: 'feature', value: 'auto', yield: true, + description: 'Build Qt5 GUI') + +option('strict', type: 'boolean', value: false, yield: true, + description: 'Enable ultra-strict warnings') + +option('suil', type: 'feature', value: 'auto', yield: true, + description: 'Use suil to load plugin UIs') + +option('title', type: 'string', value: 'Jalv', + description: 'Project title') + +option('tests', type: 'feature', value: 'auto', yield: true, + description: 'Build tests') diff --git a/src/control.c b/src/control.c index 23bdf05..7150032 100644 --- a/src/control.c +++ b/src/control.c @@ -1,8 +1,6 @@ // Copyright 2007-2022 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#define _POSIX_C_SOURCE 200809L - #include "control.h" #include "log.h" @@ -27,7 +27,7 @@ #include <jack/transport.h> #include <jack/types.h> -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA # include <jack/metadata.h> #endif @@ -64,7 +64,7 @@ jack_buffer_size_cb(jack_nframes_t nframes, void* data) Jalv* const jalv = (Jalv*)data; jalv->block_length = nframes; jalv->buf_size_set = true; -#ifdef HAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE +#if USE_JACK_PORT_TYPE_GET_BUFFER_SIZE jalv->midi_buf_size = jack_port_type_get_buffer_size(jalv->backend->client, JACK_DEFAULT_MIDI_TYPE); #endif @@ -174,7 +174,7 @@ jack_process_cb(jack_nframes_t nframes, void* data) // Connect plugin port directly to Jack port buffer lilv_instance_connect_port( jalv->instance, p, jack_port_get_buffer(port->sys_port, nframes)); -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA } else if (port->type == TYPE_CV && port->sys_port) { // Connect plugin port directly to Jack port buffer lilv_instance_connect_port( @@ -376,7 +376,7 @@ jalv_backend_init(Jalv* jalv) jalv->sample_rate = (float)jack_get_sample_rate(client); jalv->block_length = jack_get_buffer_size(client); jalv->midi_buf_size = 4096; -#ifdef HAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE +#if USE_JACK_PORT_TYPE_GET_BUFFER_SIZE jalv->midi_buf_size = jack_port_type_get_buffer_size(client, JACK_DEFAULT_MIDI_TYPE); #endif @@ -455,7 +455,7 @@ jalv_backend_activate_port(Jalv* jalv, uint32_t port_index) port->sys_port = jack_port_register( client, lilv_node_as_string(sym), JACK_DEFAULT_AUDIO_TYPE, jack_flags, 0); break; -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA case TYPE_CV: port->sys_port = jack_port_register( client, lilv_node_as_string(sym), JACK_DEFAULT_AUDIO_TYPE, jack_flags, 0); @@ -482,7 +482,7 @@ jalv_backend_activate_port(Jalv* jalv, uint32_t port_index) break; } -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA if (port->sys_port) { // Set port order to index char index_str[16]; @@ -1,10 +1,6 @@ // Copyright 2007-2022 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#define _POSIX_C_SOURCE 200809L // for mkdtemp -#define _XOPEN_SOURCE 600 // for S_IFMT and S_IFDIF -#define _DARWIN_C_SOURCE // for mkdtemp on Darwin - #include "backend.h" #include "control.h" #include "frontend.h" @@ -48,7 +44,7 @@ #include "zix/ring.h" #include "zix/sem.h" -#ifdef HAVE_SUIL +#if USE_SUIL # include "suil/suil.h" #endif @@ -210,7 +206,7 @@ create_port(Jalv* jalv, uint32_t port_index, float default_value) } else if (lilv_port_is_a( jalv->plugin, port->lilv_port, jalv->nodes.lv2_AudioPort)) { port->type = TYPE_AUDIO; -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA } else if (lilv_port_is_a( jalv->plugin, port->lilv_port, jalv->nodes.lv2_CVPort)) { port->type = TYPE_CV; @@ -415,7 +411,7 @@ jalv_set_control(Jalv* jalv, void jalv_ui_instantiate(Jalv* jalv, const char* native_ui_type, void* parent) { -#ifdef HAVE_SUIL +#if USE_SUIL jalv->ui_host = suil_host_new(jalv_ui_write, jalv_ui_port_index, NULL, NULL); const LV2_Feature parent_feature = {LV2_UI__parent, parent}; @@ -752,7 +748,7 @@ setup_signals(Jalv* const jalv) { exit_sem = &jalv->done; -#ifdef HAVE_SIGACTION +#if !defined(_WIN32) && USE_SIGACTION struct sigaction action; sigemptyset(&action.sa_mask); action.sa_flags = 0; @@ -780,7 +776,7 @@ jalv_select_custom_ui(const Jalv* const jalv) return ui; } -#ifdef HAVE_SUIL +#if USE_SUIL if (native_ui_type_uri) { // Try to find an embeddable UI LilvNode* native_type = lilv_new_uri(jalv->world, native_ui_type_uri); @@ -834,7 +830,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) jalv->bpm = 120.0f; jalv->control_in = (uint32_t)-1; -#ifdef HAVE_SUIL +#if USE_SUIL suil_init(argc, argv, SUIL_ARG_NONE); #endif @@ -1082,6 +1078,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) jalv->uis = lilv_plugin_get_uis(jalv->plugin); if (!jalv->opts.generic_ui) { if ((jalv->ui = jalv_select_custom_ui(jalv))) { +#if USE_SUIL const char* host_type_uri = jalv_frontend_ui_type(); if (host_type_uri) { LilvNode* host_type = lilv_new_uri(jalv->world, host_type_uri); @@ -1093,6 +1090,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) lilv_node_free(host_type); } +#endif } } @@ -1127,7 +1125,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) jalv->opts.buffer_size = jalv->midi_buf_size * N_BUFFER_CYCLES; } - if (jalv->opts.update_rate == 0.0) { + if (!jalv->opts.update_rate) { // Calculate a reasonable UI update frequency jalv->ui_update_hz = jalv_frontend_refresh_rate(jalv); } else { @@ -1136,7 +1134,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) jalv->ui_update_hz = MAX(1.0f, jalv->ui_update_hz); } - if (jalv->opts.scale_factor == 0.0) { + if (!jalv->opts.scale_factor) { // Calculate the monitor's scale factor jalv->ui_scale_factor = jalv_frontend_scale_factor(jalv); } else { @@ -1335,7 +1333,7 @@ jalv_close(Jalv* const jalv) jalv_worker_destroy(&jalv->worker); // Deactivate plugin -#ifdef HAVE_SUIL +#if USE_SUIL suil_instance_free(jalv->ui_instance); #endif if (jalv->instance) { @@ -1352,7 +1350,7 @@ jalv_close(Jalv* const jalv) } symap_free(jalv->symap); zix_sem_destroy(&jalv->symap_lock); -#ifdef HAVE_SUIL +#if USE_SUIL suil_host_free(jalv->ui_host); #endif diff --git a/src/jalv_config.h b/src/jalv_config.h new file mode 100644 index 0000000..1587d17 --- /dev/null +++ b/src/jalv_config.h @@ -0,0 +1,169 @@ +// Copyright 2021-2022 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +/* + Configuration header that defines reasonable defaults at compile time. + + This allows compile-time configuration from the command line, while still + allowing the source to be built "as-is" without any configuration. The idea + is to support an advanced build system with configuration checks, while still + allowing the code to be simply "thrown at a compiler" with features + determined from the compiler or system headers. Everything can be + overridden, so it should never be necessary to edit this file to build + successfully. + + To ensure that all configure checks are performed, the build system can + define JALV_NO_DEFAULT_CONFIG to disable defaults. In this case, it must + define all HAVE_FEATURE symbols below to 1 or 0 to enable or disable + features. Any missing definitions will generate a compiler warning. + + To ensure that this header is always included properly, all code that uses + configuration variables includes this header and checks their value with #if + (not #ifdef). Variables like USE_FEATURE are internal and should never be + defined on the command line. +*/ + +#ifndef JALV_CONFIG_H +#define JALV_CONFIG_H + +// Define version unconditionally so a warning will catch a mismatch +#define JALV_VERSION "1.6.7" + +#if !defined(JALV_NO_DEFAULT_CONFIG) + +// We need unistd.h to check _POSIX_VERSION +# ifndef JALV_NO_POSIX +# ifdef __has_include +# if __has_include(<unistd.h>) +# include <unistd.h> +# endif +# elif defined(__unix__) +# include <unistd.h> +# endif +# endif + +// POSIX.1-2001: fileno() +# ifndef HAVE_FILENO +# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L +# define HAVE_FILENO +# endif +# endif + +// POSIX.1-2001: isatty() +# ifndef HAVE_ISATTY +# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L +# define HAVE_ISATTY +# endif +# endif + +// POSIX.1-2001: mlock() +# ifndef HAVE_MLOCK +# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L +# define HAVE_MLOCK 1 +# else +# define HAVE_MLOCK 0 +# endif +# endif + +// POSIX.1-2001: posix_memalign() +# ifndef HAVE_POSIX_MEMALIGN +# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L +# define HAVE_POSIX_MEMALIGN 1 +# else +# define HAVE_POSIX_MEMALIGN 0 +# endif +# endif + +// POSIX.1-2001: sigaction() +# ifndef HAVE_SIGACTION +# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L +# define HAVE_SIGACTION +# endif +# endif + +// Suil +# ifndef HAVE_SUIL +# ifdef __has_include +# if __has_include("suil/suil.h") +# define HAVE_SUIL +# endif +# endif +# endif + +// JACK metadata API +# ifndef HAVE_JACK_METADATA +# ifdef __has_include +# if __has_include("jack/metadata.h") +# define HAVE_JACK_METADATA +# endif +# endif +# endif + +// JACK jack_port_type_get_buffer_size() function +# ifndef HAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE +# ifdef __has_include +# if __has_include("jack/midiport.h") +# define HAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE +# endif +# endif +# endif + +#endif // !defined(JALV_NO_DEFAULT_CONFIG) + +/* + Make corresponding USE_FEATURE defines based on the HAVE_FEATURE defines from + above or the command line. The code checks for these using #if (not #ifdef), + so there will be an undefined warning if it checks for an unknown feature, + and this header is always required by any code that checks for features, even + if the build system defines them all. +*/ + +#if HAVE_FILENO +# define USE_FILENO 1 +#else +# define USE_FILENO 0 +#endif + +#if HAVE_ISATTY +# define USE_ISATTY 1 +#else +# define USE_ISATTY 0 +#endif + +#if HAVE_MLOCK +# define USE_MLOCK 1 +#else +# define USE_MLOCK 0 +#endif + +#if HAVE_POSIX_MEMALIGN +# define USE_POSIX_MEMALIGN 1 +#else +# define USE_POSIX_MEMALIGN 0 +#endif + +#if HAVE_SIGACTION +# define USE_SIGACTION 1 +#else +# define USE_SIGACTION 0 +#endif + +#if HAVE_SUIL +# define USE_SUIL 1 +#else +# define USE_SUIL 0 +#endif + +#if HAVE_JACK_METADATA +# define USE_JACK_METADATA 1 +#else +# define USE_JACK_METADATA 0 +#endif + +#if HAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE +# define USE_JACK_PORT_TYPE_GET_BUFFER_SIZE 1 +#else +# define USE_JACK_PORT_TYPE_GET_BUFFER_SIZE 0 +#endif + +#endif // JALV_CONFIG_H diff --git a/src/jalv_console.c b/src/jalv_console.c index ebb9164..5c129ff 100644 --- a/src/jalv_console.c +++ b/src/jalv_console.c @@ -1,11 +1,6 @@ // Copyright 2007-2022 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#define _POSIX_C_SOURCE 200809L -#define _XOPEN_SOURCE 600 -#define _BSD_SOURCE 1 -#define _DEFAULT_SOURCE 1 - #include "control.h" #include "frontend.h" #include "jalv_config.h" @@ -18,10 +13,13 @@ #include "lilv/lilv.h" #include "lv2/ui/ui.h" -#include "suil/suil.h" #include "zix/common.h" #include "zix/sem.h" +#if USE_SUIL +# include "suil/suil.h" +#endif + #ifdef _WIN32 # include <synchapi.h> #else @@ -74,10 +72,18 @@ jalv_ui_port_event(Jalv* jalv, uint32_t protocol, const void* buffer) { +#if USE_SUIL if (jalv->ui_instance) { suil_instance_port_event( jalv->ui_instance, port_index, buffer_size, protocol, buffer); } +#else + (void)jalv; + (void)port_index; + (void)buffer_size; + (void)protocol; + (void)buffer; +#endif } int @@ -247,7 +253,7 @@ jalv_frontend_discover(Jalv* jalv) static bool jalv_run_custom_ui(Jalv* jalv) { -#ifdef HAVE_SUIL +#if USE_SUIL const LV2UI_Idle_Interface* idle_iface = NULL; const LV2UI_Show_Interface* show_iface = NULL; if (jalv->ui && jalv->opts.show_ui) { @@ -278,6 +284,8 @@ jalv_run_custom_ui(Jalv* jalv) show_iface->hide(suil_instance_get_handle(jalv->ui_instance)); return true; } +#else + (void)jalv; #endif return false; diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 5a33bf5..87c61d9 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -20,7 +20,7 @@ #include "lilv/lilv.h" #include "serd/serd.h" #include "sratom/sratom.h" -#ifdef HAVE_SUIL +#if USE_SUIL # include "suil/suil.h" #endif @@ -93,7 +93,7 @@ struct JalvImpl { const LilvUI* ui; ///< Plugin UI (RDF data) const LilvNode* ui_type; ///< Plugin UI type (unwrapped) LilvInstance* instance; ///< Plugin instance (shared library) -#ifdef HAVE_SUIL +#if USE_SUIL SuilHost* ui_host; ///< Plugin UI host support SuilInstance* ui_instance; ///< Plugin UI instance (shared library) #endif @@ -1,8 +1,6 @@ // Copyright 2007-2022 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#define _POSIX_C_SOURCE 200809L - #include "log.h" #include "jalv_config.h" @@ -14,7 +12,7 @@ #include "lv2/log/log.h" #include "lv2/urid/urid.h" -#ifdef HAVE_ISATTY +#if USE_ISATTY # include <unistd.h> #endif @@ -129,7 +127,7 @@ jalv_printf(LV2_Log_Handle handle, LV2_URID type, const char* fmt, ...) bool jalv_ansi_start(FILE* stream, int color) { -#if defined(HAVE_ISATTY) && defined(HAVE_FILENO) +#if USE_ISATTY && USE_FILENO if (isatty(fileno(stream))) { return fprintf(stream, "\033[0;%dm", color); } @@ -140,7 +138,7 @@ jalv_ansi_start(FILE* stream, int color) void jalv_ansi_reset(FILE* stream) { -#ifdef HAVE_ISATTY +#if USE_ISATTY if (isatty(fileno(stream))) { fprintf(stream, "\033[0m"); fflush(stream); diff --git a/src/portaudio.c b/src/portaudio.c index bc687b1..2d2ccfc 100644 --- a/src/portaudio.c +++ b/src/portaudio.c @@ -4,6 +4,7 @@ #include "backend.h" #include "jalv_internal.h" +#include "port.h" #include "worker.h" #include <math.h> diff --git a/src/zix/ring.c b/src/zix/ring.c index 78cc7b4..a48153a 100644 --- a/src/zix/ring.c +++ b/src/zix/ring.c @@ -6,7 +6,7 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_MLOCK +#if HAVE_MLOCK # include <sys/mman.h> # define ZIX_MLOCK(ptr, size) mlock((ptr), (size)) #elif defined(_WIN32) diff --git a/subprojects/lilv.wrap b/subprojects/lilv.wrap new file mode 100644 index 0000000..e770df3 --- /dev/null +++ b/subprojects/lilv.wrap @@ -0,0 +1,9 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +[wrap-git] +directory=lilv +url=https://gitlab.com/lv2/lilv.git +push-url=ssh://git@gitlab.com:lv2/lilv.git +revision=meson +depth=1 diff --git a/subprojects/lv2.wrap b/subprojects/lv2.wrap new file mode 100644 index 0000000..a650391 --- /dev/null +++ b/subprojects/lv2.wrap @@ -0,0 +1,9 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +[wrap-git] +directory=lv2 +url=https://gitlab.com/lv2/lv2.git +push-url=ssh://git@gitlab.com:lv2/lv2.git +revision=meson +depth=1 diff --git a/subprojects/serd.wrap b/subprojects/serd.wrap new file mode 100644 index 0000000..91c893c --- /dev/null +++ b/subprojects/serd.wrap @@ -0,0 +1,9 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +[wrap-git] +directory=serd +url=https://gitlab.com/drobilla/serd.git +push-url=ssh://git@gitlab.com:drobilla/serd.git +revision=meson +depth=1 diff --git a/subprojects/sord.wrap b/subprojects/sord.wrap new file mode 100644 index 0000000..59ff9ca --- /dev/null +++ b/subprojects/sord.wrap @@ -0,0 +1,9 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +[wrap-git] +directory=sord +url=https://gitlab.com/drobilla/sord.git +push-url=ssh://git@gitlab.com:drobilla/sord.git +revision=meson +depth=1 diff --git a/subprojects/sratom.wrap b/subprojects/sratom.wrap new file mode 100644 index 0000000..8490bef --- /dev/null +++ b/subprojects/sratom.wrap @@ -0,0 +1,9 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +[wrap-git] +directory=sratom +url=https://gitlab.com/lv2/sratom.git +push-url=ssh://git@gitlab.com:lv2/sratom.git +revision=meson +depth=1 diff --git a/subprojects/suil.wrap b/subprojects/suil.wrap new file mode 100644 index 0000000..6c2dedf --- /dev/null +++ b/subprojects/suil.wrap @@ -0,0 +1,9 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +[wrap-git] +directory=suil +url=https://gitlab.com/lv2/suil.git +push-url=ssh://git@gitlab.com:lv2/suil.git +revision=meson +depth=1 diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..30741c4 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,14 @@ +# Copyright 2019-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +if not meson.is_subproject() + # Check licensing metadata + reuse = find_program('reuse', required: false) + if reuse.found() + test( + 'REUSE', reuse, + args: ['--root', jalv_src_root, 'lint'], + suite: 'data', + ) + endif +endif @@ -1,30 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2010-2022 David Robillard <d@drobilla.net> -# SPDX-License-Identifier: CC0-1.0 OR ISC - -# Minimal waf script for projects that include waflib directly - -import sys -import inspect -import os - -try: - from waflib import Context, Scripting -except Exception as e: - sys.stderr.write('error: Failed to import waf (%s)\n' % e) - if os.path.exists('.git'): - sys.stderr.write("Are submodules up to date? " - "Try 'git submodule update --init --recursive'\n") - - sys.exit(1) - - -def main(): - script_path = os.path.abspath(inspect.getfile(inspect.getmodule(main))) - project_path = os.path.dirname(script_path) - Scripting.waf_entry_point(os.getcwd(), Context.WAFVERSION, project_path) - - -if __name__ == '__main__': - main() diff --git a/waflib b/waflib deleted file mode 160000 -Subproject aeef9f5fdf416d9b68c61c75de7dae409f1ac6a diff --git a/wscript b/wscript deleted file mode 100644 index e78baf2..0000000 --- a/wscript +++ /dev/null @@ -1,424 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2007-2022 David Robillard <d@drobilla.net> -# SPDX-License-Identifier: CC0-1.0 OR ISC - -import os - -from waflib import Build, Logs, Options, Utils -from waflib.extras import autowaf as autowaf - -# Version of this package (even if built as a child) -JALV_VERSION = '1.6.7' - -# Mandatory waf variables -APPNAME = 'jalv' # Package name for waf dist -VERSION = JALV_VERSION # Package version for waf dist -top = '.' # Source directory -out = 'build' # Build directory - -# Release variables -uri = 'http://drobilla.net/sw/jalv' -dist_pattern = 'http://download.drobilla.net/jalv-%d.%d.%d.tar.bz2' -post_tags = ['Hacking', 'LAD', 'LV2', 'Jalv'] - - -def options(ctx): - ctx.load('compiler_c') - ctx.load('compiler_cxx') - ctx.add_flags( - ctx.configuration_options(), - {'portaudio': 'use PortAudio backend, not JACK', - 'no-gui': 'do not build any GUIs', - 'no-gtk': 'do not build Gtk GUI', - 'no-gtk2': 'do not build Gtk2 GUI', - 'no-gtk3': 'do not build Gtk3 GUI', - 'no-qt': 'do not build Qt GUI', - 'no-qt5': 'do not build Qt5 GUI'}) - - -def configure(conf): - conf.load('compiler_c', cache=True) - conf.load('compiler_cxx', cache=True) - conf.load('autowaf', cache=True) - autowaf.set_c_lang(conf, 'c99') - autowaf.set_cxx_lang(conf, 'c++14') - - if Options.options.strict: - # Check for programs used by lint target - conf.find_program("flake8", var="FLAKE8", mandatory=False) - conf.find_program("clang-tidy", var="CLANG_TIDY", mandatory=False) - conf.find_program("iwyu_tool", var="IWYU_TOOL", mandatory=False) - - if Options.options.ultra_strict: - autowaf.add_compiler_flags(conf.env, 'c', { - 'clang': [ - '-Wno-bad-function-cast', - '-Wno-declaration-after-statement', - '-Wno-missing-noreturn', - ], - 'gcc': [ - '-Wno-bad-function-cast', - '-Wno-c++-compat', - ], - 'msvc': [ - '/wd4061', # enumerator in switch is not explicitly handled - '/wd4100', # unreferenced formal parameter - '/wd4191', # unsafe function conversion - '/wd4200', # zero-sized array in struct/union - '/wd4244', # possible loss of data from integer conversion - '/wd4267', # possible loss of data from size conversion - '/wd4365', # signed/unsigned mismatch - '/wd4514', # unreferenced inline function has been removed - '/wd4706', # assignment within conditional expression - '/wd4710', # function not inlined - '/wd4711', # function selected for automatic inline expansion - '/wd4800', # implicit conversion from int to bool - '/wd4820', # padding added after construct - '/wd4996', # POSIX name for this item is deprecated - '/wd5045', # compiler will insert Spectre mitigation - ], - }) - - autowaf.add_compiler_flags(conf.env, '*', { - 'clang': [ - '-Wno-atomic-implicit-seq-cst', - '-Wno-c99-extensions', - '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-disabled-macro-expansion', - '-Wno-documentation-unknown-command', - '-Wno-double-promotion', - '-Wno-float-conversion', - '-Wno-float-equal', - '-Wno-format-nonliteral', - '-Wno-implicit-fallthrough', - '-Wno-implicit-float-conversion', - '-Wno-nullability-extension', - '-Wno-padded', - '-Wno-redundant-parens', - '-Wno-reserved-id-macro', - '-Wno-reserved-identifier', - '-Wno-shorten-64-to-32', - '-Wno-sign-conversion', - '-Wno-switch-enum', - '-Wno-unknown-warning-option', - '-Wno-unused-macros', - '-Wno-unused-parameter', - ], - 'gcc': [ - '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-conversion', - '-Wno-double-promotion', - '-Wno-float-conversion', - '-Wno-float-equal', - '-Wno-padded', - '-Wno-pedantic', - '-Wno-stack-protector', - '-Wno-switch-enum', - '-Wno-unused-macros', - '-Wno-unused-parameter', - ], - }) - - autowaf.add_compiler_flags(conf.env, 'cxx', { - 'clang': [ - '-Wno-extra-semi-stmt', - '-Wno-old-style-cast', - '-Wno-weak-vtables', - '-Wno-zero-as-null-pointer-constant', - ], - 'gcc': [ - '-Wno-effc++', - ], - }) - - conf.check_pkg('lv2 >= 1.18.0', uselib_store='LV2') - conf.check_pkg('lilv-0 >= 0.24.0', uselib_store='LILV') - conf.check_pkg('serd-0 >= 0.24.0', uselib_store='SERD') - conf.check_pkg('sord-0 >= 0.14.0', uselib_store='SORD') - conf.check_pkg('sratom-0 >= 0.6.4', uselib_store='SRATOM') - if Options.options.portaudio: - conf.check_pkg('portaudio-2.0 >= 2.0.0', - uselib_store='PORTAUDIO', - system=True, - mandatory=False) - else: - conf.check_pkg('jack >= 0.120.0', - uselib_store='JACK', - system=True) - - if not Options.options.no_gui and not Options.options.no_gtk: - if not Options.options.no_gtk2: - conf.check_pkg('gtk+-2.0 >= 2.18.0', - uselib_store='GTK2', - system=True, - mandatory=False) - if not Options.options.no_gtk3: - conf.check_pkg('gtk+-3.0 >= 3.0.0', - uselib_store='GTK3', - system=True, - mandatory=False) - - if not Options.options.no_gui and not Options.options.no_qt: - if not Options.options.no_qt5: - conf.check_pkg('Qt5Widgets >= 5.1.0', - uselib_store='QT5', - system=True, - mandatory=False) - if conf.env.HAVE_QT5: - if not conf.find_program('moc-qt5', var='MOC5', - mandatory=False): - conf.find_program('moc', var='MOC5') - - have_gui = (conf.env.HAVE_GTK2 or conf.env.HAVE_GTK3 or conf.env.HAVE_QT5) - - conf.check_pkg('suil-0 >= 0.10.0', uselib_store='SUIL') - - if conf.env.HAVE_JACK: - conf.check_function( - 'c', 'jack_port_type_get_buffer_size', - header_name = 'jack/jack.h', - define_name = 'HAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE', - uselib = 'JACK', - return_type = 'size_t', - arg_types = 'jack_client_t*,const char*', - mandatory = False) - - conf.check_function('c', 'jack_set_property', - header_name = 'jack/metadata.h', - define_name = 'HAVE_JACK_METADATA', - uselib = 'JACK', - return_type = 'int', - arg_types = '''jack_client_t*, - jack_uuid_t, - const char*, - const char*, - const char*''', - mandatory = False) - - defines = ['_POSIX_C_SOURCE=200809L'] - - conf.env.PTHREAD_CFLAGS = [] - conf.env.PTHREAD_LINKFLAGS = [] - if conf.env.DEST_OS != 'win32': - if conf.check(cflags=['-pthread'], mandatory=False): - conf.env.PTHREAD_CFLAGS = ['-pthread'] - if conf.check(linkflags=['-pthread'], mandatory=False): - if not (conf.env.DEST_OS == 'darwin' - and conf.env.CXX_NAME == 'clang'): - conf.env.PTHREAD_LINKFLAGS += ['-pthread'] - elif conf.check(linkflags=['-lpthread'], mandatory=False): - conf.env.PTHREAD_LINKFLAGS += ['-lpthread'] - - conf.check_function('c', 'isatty', - header_name = 'unistd.h', - defines = defines, - define_name = 'HAVE_ISATTY', - return_type = 'int', - arg_types = 'int', - mandatory = False) - - conf.check_function('c', 'fileno', - header_name = 'stdio.h', - defines = defines, - define_name = 'HAVE_FILENO', - return_type = 'int', - arg_types = 'FILE*', - mandatory = False) - - conf.check_function('c', 'mlock', - header_name = 'sys/mman.h', - defines = defines, - define_name = 'HAVE_MLOCK', - return_type = 'int', - arg_types = 'const void*,size_t', - mandatory = False) - - conf.check_function('c', 'sigaction', - header_name = 'signal.h', - defines = defines, - define_name = 'HAVE_SIGACTION', - return_type = 'int', - arg_types = '''int, - const struct sigaction*, - struct sigaction*''', - mandatory = False) - - conf.define('JALV_VERSION', JALV_VERSION) - conf.write_config_header('jalv_config.h', remove=False) - - autowaf.display_summary( - conf, - {'Backend': 'Jack' if conf.env.HAVE_JACK else 'PortAudio', - 'Jack metadata support': conf.is_defined('HAVE_JACK_METADATA'), - 'Gtk 2.0 support': bool(conf.env.HAVE_GTK2), - 'Gtk 3.0 support': bool(conf.env.HAVE_GTK3), - 'Qt 5.0 support': bool(conf.env.HAVE_QT5), - 'Color output': bool(conf.env.JALV_WITH_COLOR)}) - - -def build(bld): - libs = 'LILV SUIL JACK SERD SORD SRATOM LV2 PORTAUDIO' - source = ''' - src/control.c - src/jalv.c - src/log.c - src/lv2_evbuf.c - src/state.c - src/symap.c - src/worker.c - src/zix/ring.c - ''' - - if bld.env.HAVE_JACK: - source += 'src/jack.c' - - # Non-GUI internal JACK client library - obj = bld(features = 'c cshlib', - source = source + ' src/jalv_console.c', - target = 'jalv', - cflags = bld.env.PTHREAD_CFLAGS, - linkflags = bld.env.PTHREAD_LINKFLAGS, - defines = ['ZIX_INTERNAL'], - includes = ['.', 'src'], - lib = ['pthread'], - uselib = libs, - install_path = '${LIBDIR}/jack') - obj.env.cshlib_PATTERN = '%s.so' - elif bld.env.HAVE_PORTAUDIO: - source += 'src/portaudio.c' - - # Non-GUI version - obj = bld(features = 'c cprogram', - source = source + ' src/jalv_console.c', - target = 'jalv', - cflags = bld.env.PTHREAD_CFLAGS, - linkflags = bld.env.PTHREAD_LINKFLAGS, - defines = ['ZIX_INTERNAL'], - includes = ['.', 'src'], - uselib = libs, - install_path = '${BINDIR}') - - # Gtk2 version - if bld.env.HAVE_GTK2: - obj = bld(features = 'c cprogram', - source = source + ' src/jalv_gtk.c', - target = 'jalv.gtk', - cflags = bld.env.PTHREAD_CFLAGS, - linkflags = bld.env.PTHREAD_LINKFLAGS, - defines = ['ZIX_INTERNAL'], - includes = ['.', 'src'], - lib = ['m'], - uselib = libs + ' GTK2', - install_path = '${BINDIR}') - - # Gtk3 version - if bld.env.HAVE_GTK3: - obj = bld(features = 'c cprogram', - source = source + ' src/jalv_gtk.c', - target = 'jalv.gtk3', - cflags = bld.env.PTHREAD_CFLAGS, - linkflags = bld.env.PTHREAD_LINKFLAGS, - defines = ['ZIX_INTERNAL'], - includes = ['.', 'src'], - lib = ['m'], - uselib = libs + ' GTK3', - install_path = '${BINDIR}') - - bld(features = 'subst', - source = 'jalv.desktop.in', - target = 'jalv.desktop', - install_path = '${DATADIR}/applications', - chmod = Utils.O644, - BINDIR = os.path.normpath(bld.env.BINDIR), - APP_INSTALL_NAME = 'jalv.gtk3', - APP_HUMAN_NAME = 'Jalv') - - # Qt5 version - if bld.env.HAVE_QT5: - obj = bld(rule = '${MOC5} ${SRC} > ${TGT}', - source = 'src/jalv_qt.hpp', - target = 'jalv_qt5_meta.cpp') - obj = bld(features = 'c cxx cxxprogram', - source = source + ' src/jalv_qt.cpp jalv_qt5_meta.cpp', - target = 'jalv.qt5', - cflags = bld.env.PTHREAD_CFLAGS, - linkflags = bld.env.PTHREAD_LINKFLAGS, - defines = ['ZIX_INTERNAL'], - includes = ['.', 'src'], - uselib = libs + ' QT5', - install_path = '${BINDIR}', - cxxflags = ['-fPIC']) - - # Man pages - bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1')) - - -class LintContext(Build.BuildContext): - fun = cmd = 'lint' - - -def lint(ctx): - "checks code for style issues" - import os - import subprocess - import sys - - st = 0 - - if "FLAKE8" in ctx.env: - Logs.info("Running flake8") - st = subprocess.call([ctx.env.FLAKE8[0], - "wscript", - "--ignore", - "E101,E129,W191,E221,W504,E251,E241,E741"]) - else: - Logs.warn("Not running flake8") - - if "IWYU_TOOL" in ctx.env: - Logs.info("Running include-what-you-use") - - qt_mapping_file = "/usr/share/include-what-you-use/qt5_11.imp" - extra_args = [] - if os.path.exists(qt_mapping_file): - extra_args += ["--", "-Xiwyu", "--mapping_file=" + qt_mapping_file] - - cmd = [ctx.env.IWYU_TOOL[0], "-o", "clang", "-p", "build"] + extra_args - output = subprocess.check_output(cmd).decode('utf-8') - if 'error: ' in output: - sys.stdout.write(output) - st += 1 - else: - Logs.warn("Not running include-what-you-use") - - if "CLANG_TIDY" in ctx.env and "clang" in ctx.env.CXX[0]: - Logs.info("Running clang-tidy") - - import json - - with open('build/compile_commands.json', 'r') as db: - commands = json.load(db) - files = [c['file'] for c in commands] - - for step_files in zip(*(iter(files),) * Options.options.jobs): - procs = [] - for f in step_files: - cmd = [ctx.env.CLANG_TIDY[0], '--quiet', '-p=.', f] - procs += [subprocess.Popen(cmd, cwd='build')] - - for proc in procs: - proc.communicate() - st += proc.returncode - else: - Logs.warn("Not running clang-tidy") - - if st != 0: - Logs.warn("Lint checks failed") - sys.exit(st) - - -def dist(ctx): - ctx.base_path = ctx.path - ctx.excl = ctx.get_excl() + ' .gitmodules' |