diff options
author | David Robillard <d@drobilla.net> | 2022-07-03 20:47:34 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-07-18 20:16:10 -0400 |
commit | 75e647def0f67647ec7ba1405e26d809a87c62fc (patch) | |
tree | 13a73ca75976824ba991c8c7d235830ce663c1e8 | |
parent | ed283b838681ed3fb28e94140a6dc5172945776f (diff) | |
download | sratom-75e647def0f67647ec7ba1405e26d809a87c62fc.tar.gz sratom-75e647def0f67647ec7ba1405e26d809a87c62fc.tar.bz2 sratom-75e647def0f67647ec7ba1405e26d809a87c62fc.zip |
Switch to meson build system
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | INSTALL.md | 70 | ||||
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | doc/c/Doxyfile.in (renamed from doc/c/Doxyfile) | 6 | ||||
-rw-r--r-- | doc/c/api/meson.build | 6 | ||||
-rw-r--r-- | doc/c/index.rst | 9 | ||||
-rw-r--r-- | doc/c/meson.build | 48 | ||||
-rw-r--r-- | doc/c/wscript | 39 | ||||
-rw-r--r-- | doc/c/xml/meson.build | 18 | ||||
-rw-r--r-- | doc/conf.py.in | 2 | ||||
-rw-r--r-- | doc/meson.build | 15 | ||||
-rw-r--r-- | doc/summary.rst (renamed from doc/sratom.rst) | 4 | ||||
-rw-r--r-- | meson.build | 116 | ||||
-rw-r--r-- | meson/library/meson.build | 31 | ||||
-rw-r--r-- | meson/suppressions/meson.build | 68 | ||||
-rw-r--r-- | meson/warnings/meson.build | 175 | ||||
-rw-r--r-- | meson_options.txt | 11 | ||||
-rw-r--r-- | sratom.pc.in | 11 | ||||
-rw-r--r-- | test/.clang-tidy | 1 | ||||
-rw-r--r-- | test/meson.build | 23 | ||||
-rwxr-xr-x | waf | 27 | ||||
m--------- | waflib | 0 | ||||
-rw-r--r-- | wscript | 238 |
25 files changed, 601 insertions, 329 deletions
diff --git a/.clang-tidy b/.clang-tidy index db3091a..f1f12ed 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,6 +5,7 @@ Checks: > -*-uppercase-literal-suffix, -altera-*, -bugprone-easily-swappable-parameters, + -bugprone-macro-parentheses, -bugprone-suspicious-string-compare, -cert-err34-c, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, @@ -1,4 +1,2 @@ build/** -.waf-* -.lock-waf* __pycache__ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index cc8b569..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "waflib"] - path = waflib - url = ../../drobilla/autowaf.git 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/ @@ -1,3 +1,9 @@ +sratom (0.6.11) unstable; + + * Switch to meson build system + + -- David Robillard <d@drobilla.net> Sat, 28 May 2022 00:54:06 +0000 + sratom (0.6.10) stable; * Fix documentation installation directory diff --git a/doc/c/Doxyfile b/doc/c/Doxyfile.in index 3252d98..9180f1f 100644 --- a/doc/c/Doxyfile +++ b/doc/c/Doxyfile.in @@ -21,6 +21,8 @@ SHOW_FILES = NO MACRO_EXPANSION = YES PREDEFINED = SRATOM_API -INPUT = ../../include/sratom/sratom.h +RECURSIVE = YES +STRIP_FROM_PATH = @SRATOM_SRCDIR@ +INPUT = @SRATOM_SRCDIR@/include -OUTPUT_DIRECTORY = . +OUTPUT_DIRECTORY = @DOX_OUTPUT@ diff --git a/doc/c/api/meson.build b/doc/c/api/meson.build new file mode 100644 index 0000000..0ece07c --- /dev/null +++ b/doc/c/api/meson.build @@ -0,0 +1,6 @@ +c_sratom_rst = custom_target( + 'sratom.rst', + command: [dox_to_sphinx, '-f', '@INPUT0@', '@OUTDIR@'], + input: [c_index_xml] + c_rst_files, + output: 'sratom.rst', +) diff --git a/doc/c/index.rst b/doc/c/index.rst index b51db16..2e02d5d 100644 --- a/doc/c/index.rst +++ b/doc/c/index.rst @@ -1,5 +1,10 @@ +###### +Sratom +###### + +.. include:: summary.rst + .. toctree:: - sratom overview - reference + api/sratom diff --git a/doc/c/meson.build b/doc/c/meson.build new file mode 100644 index 0000000..8ed81c0 --- /dev/null +++ b/doc/c/meson.build @@ -0,0 +1,48 @@ +config = configuration_data() +config.set('SRATOM_VERSION', meson.project_version()) + +conf_py = configure_file( + configuration: config, + input: files('../conf.py.in'), + output: 'conf.py', +) + +configure_file( + copy: true, + input: files('../summary.rst'), + output: 'summary.rst', +) + +c_rst_files = files( + 'index.rst', + 'overview.rst', +) + +foreach f : c_rst_files + configure_file(copy: true, input: f, output: '@PLAINNAME@') +endforeach + +subdir('xml') +subdir('api') + +docs = custom_target( + 'singlehtml', + build_by_default: true, + command: [sphinx_build, '-M', 'singlehtml', '@OUTDIR@', '@OUTDIR@', + '-E', '-q', '-t', 'singlehtml'], + input: [c_rst_files, c_sratom_rst, c_index_xml], + install: true, + install_dir: docdir / 'sratom-0', + output: 'singlehtml', +) + +docs = custom_target( + 'html', + build_by_default: true, + command: [sphinx_build, '-M', 'html', '@OUTDIR@', '@OUTDIR@', + '-E', '-q', '-t', 'html'], + input: [c_rst_files, c_sratom_rst, c_index_xml], + install: true, + install_dir: docdir / 'sratom-0', + output: 'html', +) diff --git a/doc/c/wscript b/doc/c/wscript deleted file mode 100644 index 9ea3094..0000000 --- a/doc/c/wscript +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python - -def build(bld): - dox_to_sphinx = bld.path.find_node("../../scripts/dox_to_sphinx.py") - index_xml = bld.path.get_bld().make_node("xml/index.xml") - - files = [ - ("../sratom.rst", "sphinx/sratom.rst"), - ("index.rst", "sphinx/index.rst"), - ("overview.rst", "sphinx/overview.rst"), - ("reference.rst", "sphinx/reference.rst"), - ] - - # Run Doxygen to generate XML documentation - bld(features="doxygen", doxyfile="Doxyfile") - - # Substitute variables to make Sphinx configuration file - bld(features="subst", - source="../conf.py.in", - target="sphinx/conf.py", - SERD_VERSION=bld.env.SERD_VERSION) - - # Copy static documentation files to Sphinx build directory - for f in files: - bld(features="subst", is_copy=True, source=f[0], target=f[1]) - - # Generate Sphinx markup from Doxygen XML - bld.add_group() - bld(rule="${PYTHON} " + dox_to_sphinx.abspath() + " -f ${SRC} ${TGT}", - source=index_xml, - target="sphinx/api/") - - # Run Sphinx to generate HTML documentation - doc_dir = bld.env.DOCDIR + "/sratom-%s/" % bld.env.SRATOM_MAJOR_VERSION - bld(features="sphinx", - sphinx_source=bld.path.get_bld().make_node("sphinx"), - sphinx_output_format="singlehtml", - sphinx_options=["-E", "-q", "-t", "singlehtml"], - install_path=doc_dir + "c/singlehtml/") diff --git a/doc/c/xml/meson.build b/doc/c/xml/meson.build new file mode 100644 index 0000000..eaa6bcc --- /dev/null +++ b/doc/c/xml/meson.build @@ -0,0 +1,18 @@ +doxygen = find_program('doxygen') + +config = configuration_data() +config.set('SRATOM_SRCDIR', sratom_src_root) +config.set('DOX_OUTPUT', meson.current_build_dir() / '..') + +c_doxyfile = configure_file( + configuration: config, + input: files('../Doxyfile.in'), + output: 'Doxyfile', +) + +c_index_xml = custom_target( + 'index.xml', + command: [doxygen, '@INPUT0@'], + input: [c_doxyfile] + c_headers, + output: 'index.xml', +) diff --git a/doc/conf.py.in b/doc/conf.py.in index 0e8b53f..f3aee92 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -35,9 +35,9 @@ nitpick_ignore = list(map(lambda x: ("c:identifier", x), _opaque)) # HTML output -html_theme = "sphinx_lv2_theme" html_copy_source = False html_short_title = "Sratom" +html_theme = "sphinx_lv2_theme" if tags.has("singlehtml"): html_sidebars = { diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 0000000..46fc3bb --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,15 @@ +docdir = get_option('datadir') / 'doc' + +doxygen = find_program('doxygen', required: get_option('docs')) +dox_to_sphinx = files('../scripts/dox_to_sphinx.py') +sphinx_build = find_program('sphinx-build', required: get_option('docs')) + +build_docs = doxygen.found() and sphinx_build.found() + +if build_docs + subdir('c') +endif + +if not meson.is_subproject() + summary('Documentation', build_docs, bool_yn: true) +endif diff --git a/doc/sratom.rst b/doc/summary.rst index bf37c17..94279ce 100644 --- a/doc/sratom.rst +++ b/doc/summary.rst @@ -1,7 +1,3 @@ -###### -Sratom -###### - Sratom is a small library for serializing `LV2 atoms`_. Sratom reads/writes atoms from/to RDF, allowing them to be converted between binary and text or stored in a model. diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..2128e5a --- /dev/null +++ b/meson.build @@ -0,0 +1,116 @@ +project('sratom', ['c'], + version: '0.6.11', + license: 'ISC', + meson_version: '>= 0.56.0', + default_options: [ + 'b_ndebug=if-release', + 'buildtype=release', + 'c_std=c99', + ]) + +sratom_src_root = meson.current_source_dir() +major_version = meson.project_version().split('.')[0] +version_suffix = '-@0@'.format(major_version) +versioned_name = 'sratom' + version_suffix + +####################### +# Compilers and Flags # +####################### + +# Required tools +pkg = import('pkgconfig') +cc = meson.get_compiler('c') + +# Set global warning flags +if get_option('strict') and not meson.is_subproject() + subdir('meson/warnings') +endif +subdir('meson/suppressions') + +################ +# Dependencies # +################ + +m_dep = cc.find_library('m', required: false) + +lv2_dep = dependency('lv2', + version: '>= 1.18.3', + fallback: ['lv2', 'lv2_dep']) + +serd_dep = dependency('serd-0', + version: '>= 0.30.9', + fallback: ['serd', 'serd_dep']) + +sord_dep = dependency('sord-0', + version: '>= 0.16.9', + fallback: ['sord', 'sord_dep']) + +########### +# Library # +########### + +include_dirs = include_directories('include') +c_headers = files('include/sratom/sratom.h') +sources = files('src/sratom.c') + +# Set appropriate arguments for building against the library type +extra_c_args = [] +subdir('meson/library') +if get_option('default_library') == 'static' + extra_c_args = ['-DSRATOM_STATIC'] +endif + +# Build shared and/or static library +libsratom = library( + meson.project_name() + library_suffix, + sources, + c_args: c_suppressions + extra_c_args + ['-DSRATOM_INTERNAL'], + dependencies: [m_dep, lv2_dep, serd_dep, sord_dep], + gnu_symbol_visibility: 'hidden', + include_directories: include_dirs, + install: true, + version: meson.project_version(), +) + +# Declare dependency for internal meson dependants +sratom_dep = declare_dependency( + compile_args: extra_c_args, + dependencies: [m_dep, lv2_dep, serd_dep, sord_dep], + include_directories: include_dirs, + link_with: libsratom +) + +# Generage pkg-config file for external dependants +pkg.generate( + libsratom, + description: 'Small library for serializing LV2 atoms', + extra_cflags: extra_c_args, + filebase: versioned_name, + name: 'Sratom', + subdirs: [versioned_name], + version: meson.project_version(), +) + +# Install header to a versioned include directory +install_headers(c_headers, subdir: versioned_name / 'sratom') + +########### +# Support # +########### + +if not get_option('tests').disabled() + subdir('test') +endif + +if not get_option('docs').disabled() + subdir('doc') +endif + +if not meson.is_subproject() + summary('Tests', not get_option('tests').disabled(), bool_yn: true) + + summary('Install prefix', get_option('prefix')) + + summary('Headers', get_option('prefix') / get_option('includedir')) + summary('Libraries', get_option('prefix') / get_option('libdir')) +endif diff --git a/meson/library/meson.build b/meson/library/meson.build new file mode 100644 index 0000000..fffc831 --- /dev/null +++ b/meson/library/meson.build @@ -0,0 +1,31 @@ +# Copyright 2020-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR ISC + +# General definitions for building libraries. +# +# These are essentially workarounds for Meson/Windows/MSVC. Unfortunately, +# Meson's default_library option doesn't support shared and static builds very +# well. In particular, it's often necessary to define different symbols for +# static and shared builds of libraries so that symbols can be exported. To +# work around this, default_library=both isn't supported on Windows. On other +# platforms with GCC-like compilers, we can support both because symbols can +# safely be exported in the same way (giving them default visibility) in both +# static and shared builds. + +default_library = get_option('default_library') +host_system = host_machine.system() + +# Abort on Windows with default_library=both +if host_system == 'windows' and default_library == 'both' + error('default_library=both is not supported on Windows') +endif + +# Set library_suffix to the suffix for libraries +if host_system == 'windows' and default_library == 'shared' + # Meson appends a version to the name only for DLLs, which leads to + # inconsistent library names, like `mylib-1-1`. So, provide no suffix to + # ultimately get the same name as on other platforms, like `mylib-1`. + library_suffix = '' +else + library_suffix = '-@0@'.format(meson.project_version().split('.')[0]) +endif diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build new file mode 100644 index 0000000..735c43c --- /dev/null +++ b/meson/suppressions/meson.build @@ -0,0 +1,68 @@ +# 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. + +##### +# C # +##### + +if is_variable('cc') + c_suppressions = [] + + if cc.get_id() == 'clang' + c_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-documentation-unknown-command', + '-Wno-double-promotion', + '-Wno-float-conversion', + '-Wno-implicit-float-conversion', + '-Wno-implicit-int-conversion', + '-Wno-nullability-extension', + '-Wno-nullable-to-nonnull-conversion', + '-Wno-padded', + '-Wno-shorten-64-to-32', + '-Wno-sign-conversion', + ] + + elif cc.get_id() == 'gcc' + c_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-conversion', + '-Wno-inline', + '-Wno-padded', + '-Wno-suggest-attribute=pure', + '-Wno-unsuffixed-float-constants', + '-Wno-unused-const-variable', + ] + + if host_machine.system() =='windows' + c_suppressions += [ + '-Wno-suggest-attribute=format', + ] + endif + + elif cc.get_id() == 'msvc' + c_suppressions += [ + '/wd4242', # conversion, possible loss of data + '/wd4244', # conversion from floating point, possible loss of data + '/wd4267', # conversion from size_t, possible loss of data + '/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 + '/wd4820', # padding added after construct + '/wd4996', # function or variable may be unsafe + '/wd5045', # will insert Spectre mitigation for memory load + ] + endif + + c_suppressions = cc.get_supported_arguments(c_suppressions) +endif diff --git a/meson/warnings/meson.build b/meson/warnings/meson.build new file mode 100644 index 0000000..4d23ad3 --- /dev/null +++ b/meson/warnings/meson.build @@ -0,0 +1,175 @@ +# 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 warnings that apply to all C-family languages +gcc_common_warnings = [ + '-Walloc-zero', + '-Walloca', + '-Wanalyzer-too-complex', + '-Warith-conversion', + '-Warray-bounds=2', + '-Wattribute-alias=2', + '-Wbidi-chars=ucn', + '-Wcast-align=strict', + '-Wcast-function-type', + '-Wcast-qual', + '-Wclobbered', + '-Wconversion', + '-Wdate-time', + '-Wdisabled-optimization', + '-Wdouble-promotion', + '-Wduplicated-branches', + '-Wduplicated-cond', + '-Wempty-body', + '-Wendif-labels', + '-Wfloat-equal', + '-Wformat-overflow=2', + '-Wformat-signedness', + '-Wformat-truncation=2', + '-Wformat=2', + '-Wignored-qualifiers', + '-Wimplicit-fallthrough=3', + '-Winit-self', + '-Winline', + '-Winvalid-pch', + '-Wlogical-op', + '-Wmissing-declarations', + '-Wmissing-field-initializers', + '-Wmissing-include-dirs', + '-Wmultichar', + '-Wnormalized=nfc', + '-Wnull-dereference', + '-Wopenacc-parallelism', + '-Woverlength-strings', + '-Wpacked', + '-Wpacked-bitfield-compat', + '-Wpadded', + '-Wpointer-arith', + '-Wredundant-decls', + '-Wshadow', + '-Wshift-negative-value', + '-Wshift-overflow=2', + '-Wstack-protector', + '-Wstrict-aliasing=3', + '-Wstrict-overflow=5', + '-Wstring-compare', + '-Wstringop-overflow=3', + '-Wsuggest-attribute=cold', + '-Wsuggest-attribute=const', + '-Wsuggest-attribute=format', + '-Wsuggest-attribute=malloc', + '-Wsuggest-attribute=noreturn', + '-Wsuggest-attribute=pure', + '-Wswitch-default', + '-Wswitch-enum', + '-Wtrampolines', + '-Wtrivial-auto-var-init', + '-Wtype-limits', + '-Wundef', + '-Wuninitialized', + '-Wunsafe-loop-optimizations', + '-Wunused', + '-Wunused-const-variable=2', + '-Wunused-macros', + '-Wvector-operation-performance', + '-Wvla', + '-Wwrite-strings', +] + +##### +# C # +##### + +if is_variable('cc') + # Set all_c_warnings for the current C compiler + 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', + '/experimental:external', + '/external:W0', + '/external:anglebrackets', + ] + endif + + all_c_warnings = cc.get_supported_arguments(all_c_warnings) + add_global_arguments(all_c_warnings, language: ['c']) +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..8ec1821 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,11 @@ +option('docs', type: 'feature', value: 'auto', yield: true, + description: 'Build documentation') + +option('strict', type: 'boolean', value: false, yield: true, + description: 'Enable ultra-strict warnings') + +option('tests', type: 'feature', value: 'auto', yield: true, + description: 'Build tests') + +option('title', type: 'string', value: 'Sratom', + description: 'Project title') diff --git a/sratom.pc.in b/sratom.pc.in deleted file mode 100644 index 4b53b68..0000000 --- a/sratom.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@PREFIX@ -exec_prefix=@EXEC_PREFIX@ -libdir=@LIBDIR@ -includedir=@INCLUDEDIR@ - -Name: Sratom -Version: @SRATOM_VERSION@ -Description: Small library for serializing LV2 atoms -Requires: @SRATOM_PKG_DEPS@ -Libs: -L${libdir} -l@LIB_SRATOM@ -Cflags: -I${includedir}/sratom-@SRATOM_MAJOR_VERSION@ diff --git a/test/.clang-tidy b/test/.clang-tidy index 6f36a17..53e7864 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -3,6 +3,7 @@ Checks: > -*-magic-numbers, -*-uppercase-literal-suffix, -altera-*, + -bugprone-macro-parentheses, -bugprone-suspicious-string-compare, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -hicpp-signed-bitwise, diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..3cecff6 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,23 @@ +autoship = find_program('autoship', required: false) + +unit_tests = [ + 'sratom', +] + +foreach unit : unit_tests + test( + unit, + executable( + 'test_@0@'.format(unit), + files('test_@0@.c'.format(unit)), + c_args: c_suppressions, + dependencies: [sratom_dep, serd_dep, sord_dep], + include_directories: include_directories('../src'), + ), + suite: 'unit', + ) +endforeach + +if autoship.found() + test('autoship', autoship, args: ['test', sratom_src_root], suite: 'data') +endif @@ -1,27 +0,0 @@ -#!/usr/bin/env python - -# 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 b600c928b221a001faeab7bd92786d0b25714bc diff --git a/wscript b/wscript deleted file mode 100644 index 9d7c839..0000000 --- a/wscript +++ /dev/null @@ -1,238 +0,0 @@ -#!/usr/bin/env python - -from waflib import Build, Logs, Options -from waflib.extras import autowaf - -# Library and package version (UNIX style major, minor, micro) -# major increment <=> incompatible changes -# minor increment <=> compatible changes (additions) -# micro increment <=> no interface changes -SRATOM_VERSION = '0.6.10' -SRATOM_MAJOR_VERSION = '0' - -# Mandatory waf variables -APPNAME = 'sratom' # Package name for waf dist -VERSION = SRATOM_VERSION # Package version for waf dist -top = '.' # Source directory -out = 'build' # Build directory - -# Release variables -uri = 'http://drobilla.net/sw/sratom' -dist_pattern = 'http://download.drobilla.net/sratom-%d.%d.%d.tar.bz2' -post_tags = ['Hacking', 'LAD', 'LV2', 'RDF', 'Sratom'] - - -def options(ctx): - ctx.load('compiler_c') - ctx.add_flags( - ctx.configuration_options(), - {'static': 'build static library', - 'no-shared': 'do not build shared library'}) - - -def configure(conf): - conf.load('compiler_c', cache=True) - conf.load('autowaf', cache=True) - autowaf.set_c_lang(conf, 'c99') - - conf.env.BUILD_SHARED = not Options.options.no_shared - conf.env.BUILD_STATIC = Options.options.static - conf.env.SRATOM_MAJOR_VERSION = SRATOM_MAJOR_VERSION - - if not conf.env.BUILD_SHARED and not conf.env.BUILD_STATIC: - conf.fatal('Neither a shared nor a static build requested') - - if conf.env.DOCS: - conf.load('sphinx') - - 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', { - 'gcc': [ - '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-conversion', - '-Wno-padded', - '-Wno-suggest-attribute=pure', - ], - 'clang': [ - '-Wno-cast-align', - '-Wno-cast-qual', - '-Wno-double-promotion', - '-Wno-float-conversion', - '-Wno-implicit-float-conversion', - '-Wno-implicit-int-conversion', - '-Wno-nullability-extension', - '-Wno-nullable-to-nonnull-conversion', - '-Wno-padded', - '-Wno-shorten-64-to-32', - '-Wno-sign-conversion', - ], - 'msvc': [ - '/wd4242' # conversion with possible loss of data - ] - }) - - conf.check_pkg('lv2 >= 1.16.0', uselib_store='LV2') - conf.check_pkg('serd-0 >= 0.30.0', uselib_store='SERD') - conf.check_pkg('sord-0 >= 0.14.0', uselib_store='SORD') - - # Set up environment for building/using as a subproject - autowaf.set_lib_env(conf, 'sratom', SRATOM_VERSION, - include_path=str(conf.path.find_node('include'))) - - autowaf.display_summary(conf, {'Unit tests': bool(conf.env.BUILD_TESTS)}) - - -lib_source = ['src/sratom.c'] - - -def build(bld): - # C Headers - includedir = '${INCLUDEDIR}/sratom-%s/sratom' % SRATOM_MAJOR_VERSION - bld.install_files(includedir, bld.path.ant_glob('include/sratom/*.h')) - - # Pkgconfig file - autowaf.build_pc(bld, 'SRATOM', SRATOM_VERSION, SRATOM_MAJOR_VERSION, [], - {'SRATOM_MAJOR_VERSION': SRATOM_MAJOR_VERSION, - 'SRATOM_PKG_DEPS': 'lv2 serd-0 sord-0'}) - - libflags = ['-fvisibility=hidden'] - libs = ['m'] - defines = [] - if bld.env.MSVC_COMPILER: - libflags = [] - libs = [] - defines = [] - - # Shared Library - if bld.env.BUILD_SHARED: - bld(features = 'c cshlib', - export_includes = ['include'], - source = lib_source, - includes = ['include'], - lib = libs, - uselib = 'SERD SORD LV2', - name = 'libsratom', - target = 'sratom-%s' % SRATOM_MAJOR_VERSION, - vnum = SRATOM_VERSION, - install_path = '${LIBDIR}', - defines = defines + ['SRATOM_INTERNAL'], - cflags = libflags) - - # Static library - if bld.env.BUILD_STATIC: - bld(features = 'c cstlib', - export_includes = ['include'], - source = lib_source, - includes = ['include'], - lib = libs, - uselib = 'SERD SORD LV2', - name = 'libsratom_static', - target = 'sratom-%s' % SRATOM_MAJOR_VERSION, - vnum = SRATOM_VERSION, - install_path = '${LIBDIR}', - defines = defines + ['SRATOM_STATIC', 'SRATOM_INTERNAL']) - - if bld.env.BUILD_TESTS: - test_libs = libs - test_cflags = [''] - test_linkflags = [''] - if not bld.env.NO_COVERAGE: - test_cflags += ['--coverage'] - test_linkflags += ['--coverage'] - - # Static library (for unit test code coverage) - bld(features = 'c cstlib', - source = lib_source, - includes = ['include'], - lib = test_libs, - uselib = 'SERD SORD LV2', - name = 'libsratom_profiled', - target = 'sratom_profiled', - install_path = '', - defines = defines + ['SRATOM_STATIC', 'SRATOM_INTERNAL'], - cflags = test_cflags, - linkflags = test_linkflags) - - # Unit test program - bld(features = 'c cprogram', - source = 'test/test_sratom.c', - includes = ['include'], - use = 'libsratom_profiled', - lib = test_libs, - uselib = 'SERD SORD LV2', - target = 'test_sratom', - install_path = '', - defines = defines + ['SRATOM_STATIC'], - cflags = test_cflags, - linkflags = test_linkflags) - - # Documentation - if bld.env.DOCS: - bld.recurse('doc/c') - - bld.add_post_fun(autowaf.run_ldconfig) - - -def test(tst): - import sys - - with tst.group('Integration') as check: - check(['./test_sratom']) - - -class LintContext(Build.BuildContext): - fun = cmd = 'lint' - - -def lint(ctx): - "checks code for style issues" - import glob - 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") - cmd = [ctx.env.IWYU_TOOL[0], "-o", "clang", "-p", "build"] - 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.CC[0]: - Logs.info("Running clang-tidy") - sources = glob.glob('src/*.c') + glob.glob('test/*.c') - sources = list(map(os.path.abspath, sources)) - procs = [] - for source in sources: - cmd = [ctx.env.CLANG_TIDY[0], "--quiet", "-p=.", source] - procs += [subprocess.Popen(cmd, cwd="build")] - - for proc in procs: - stdout, stderr = proc.communicate() - st += proc.returncode - else: - Logs.warn("Not running clang-tidy") - - if st != 0: - sys.exit(st) |