summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules3
-rw-r--r--INSTALL66
-rw-r--r--INSTALL.md70
-rw-r--r--NEWS3
-rw-r--r--doc/meson.build36
-rw-r--r--doc/reference.doxygen.in4
-rw-r--r--meson.build154
-rw-r--r--meson/library/meson.build31
-rw-r--r--meson/suppressions/meson.build92
-rw-r--r--meson/warnings/meson.build175
-rw-r--r--meson_options.txt14
-rw-r--r--sord.pc.in11
-rw-r--r--src/sord.c2
-rw-r--r--test/meson.build22
-rw-r--r--test/test_sord.c (renamed from src/sord_test.c)0
-rwxr-xr-xwaf27
m---------waflib0
-rw-r--r--wscript413
19 files changed, 599 insertions, 526 deletions
diff --git a/.gitignore b/.gitignore
index 204c242..467d5b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,2 @@
build/**
-.waf-*
-.lock-waf*
__pycache__
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/INSTALL b/INSTALL
deleted file mode 100644
index 9b54f51..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,66 +0,0 @@
-Installation Instructions
-=========================
-
-Basic Installation
-------------------
-
-Building this software requires only Python. To install with default options:
-
- ./waf configure
- ./waf
- ./waf install # or 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
-
-Library Versioning
-------------------
-
-This library uses semantic versioning <http://semver.org/>.
-
-Several major versions can be installed in parallel. The shared library name,
-include directory, and pkg-config file are suffixed with the major version
-number. For example, a library named "foo" at version 1.x.y might install:
-
- /usr/include/foo-1/foo/foo.h
- /usr/lib/foo-1.so.1.x.y
- /usr/lib/pkgconfig/foo-1.pc
-
-Dependencies can check for the package "foo-1" with pkg-config.
-
-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
-
-Packages should allow parallel installation of several major versions. For
-example, the above would be packaged as "foo-1". \ No newline at end of file
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/
diff --git a/NEWS b/NEWS
index bf55edc..19a82bc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,9 @@
sord (0.16.11) unstable;
* Fix various warnings
+ * Switch to meson build system
- -- David Robillard <d@drobilla.net> Sun, 17 Jul 2022 21:21:11 +0000
+ -- David Robillard <d@drobilla.net> Sun, 17 Jul 2022 21:22:04 +0000
sord (0.16.10) stable;
diff --git a/doc/meson.build b/doc/meson.build
new file mode 100644
index 0000000..a354f30
--- /dev/null
+++ b/doc/meson.build
@@ -0,0 +1,36 @@
+docdir = get_option('datadir') / 'doc'
+
+doxygen = find_program('doxygen', required: get_option('docs'))
+
+build_docs = doxygen.found()
+
+if build_docs
+ config = configuration_data()
+ config.set('SORD_VERSION', meson.project_version())
+ config.set('SORD_SRCDIR', sord_src_root)
+ config.set('DOX_OUTPUT', meson.current_build_dir())
+
+ c_doxyfile = configure_file(
+ configuration: config,
+ input: files('reference.doxygen.in'),
+ output: 'reference.doxygen',
+ )
+
+ custom_target(
+ 'html',
+ build_by_default: true,
+ command: [doxygen, '@INPUT0@'],
+ input: [c_doxyfile] + c_headers,
+ install: true,
+ install_dir: docdir / versioned_name,
+ output: 'html',
+ )
+endif
+
+if not get_option('docs').disabled()
+ install_man(files('sord_validate.1', 'sordi.1'))
+endif
+
+if not meson.is_subproject()
+ summary('API Documentation', build_docs, bool_yn: true)
+endif
diff --git a/doc/reference.doxygen.in b/doc/reference.doxygen.in
index 9a685c5..a9e62eb 100644
--- a/doc/reference.doxygen.in
+++ b/doc/reference.doxygen.in
@@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.
-OUTPUT_DIRECTORY = .
+OUTPUT_DIRECTORY = @DOX_OUTPUT@
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
@@ -1788,7 +1788,7 @@ RTF_EXTENSIONS_FILE =
# classes and files.
# The default value is: NO.
-GENERATE_MAN = YES
+GENERATE_MAN = NO
# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..9a77653
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,154 @@
+# Copyright 2021-2022 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: CC0-1.0 OR ISC
+
+project('sord', ['c'],
+ version: '0.16.11',
+ license: 'ISC',
+ meson_version: '>= 0.56.0',
+ default_options: [
+ 'b_ndebug=if-release',
+ 'buildtype=release',
+ 'c_std=c99',
+ ])
+
+sord_src_root = meson.current_source_dir()
+major_version = meson.project_version().split('.')[0]
+version_suffix = '-@0@'.format(major_version)
+versioned_name = 'sord' + 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')
+
+# Build as C++ with MSVC
+if cc.get_id() == 'msvc'
+ add_project_arguments(['/TP'], language: ['c'])
+endif
+
+################
+# Dependencies #
+################
+
+m_dep = cc.find_library('m', required: false)
+
+serd_dep = dependency('serd-0',
+ version: '>= 0.30.9',
+ fallback: ['serd', 'serd_dep'])
+
+###########
+# Library #
+###########
+
+c_headers = files('include/sord/sord.h')
+cpp_headers = files('include/sord/sordmm.hpp')
+
+sources = files(
+ 'src/sord.c',
+ 'src/syntax.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 = ['-DSORD_STATIC']
+endif
+
+# Build shared and/or static library
+libsord = library(
+ meson.project_name() + library_suffix,
+ sources,
+ c_args: c_suppressions + extra_c_args + [
+ '-DSORD_INTERNAL',
+ '-DSORD_VERSION="@0@"'.format(meson.project_version()),
+ ],
+ dependencies: [m_dep, serd_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories('include', 'src'),
+ install: true,
+ version: meson.project_version(),
+)
+
+# Declare dependency for internal meson dependants
+sord_dep = declare_dependency(
+ compile_args: extra_c_args,
+ dependencies: [m_dep, serd_dep],
+ include_directories: include_directories('include'),
+ link_with: libsord,
+)
+
+# Generage pkg-config file for external dependants
+pkg.generate(
+ libsord,
+ description: 'Lightweight C library for storing RDF in memory',
+ extra_cflags: extra_c_args,
+ filebase: versioned_name,
+ name: 'Sord',
+ subdirs: [versioned_name],
+ version: meson.project_version(),
+)
+
+# Install headers to a versioned include directory
+install_headers(c_headers, subdir: versioned_name / 'sord')
+install_headers(cpp_headers, subdir: versioned_name / 'sord')
+
+#########
+# Tools #
+#########
+
+# Build sordi command line utility
+if not get_option('tools').disabled()
+ sordi = executable('sordi',
+ files('src/sordi.c'),
+ c_args: c_suppressions,
+ install: true,
+ dependencies: sord_dep)
+
+ pcre_dep = dependency('libpcre', required: false)
+
+ if pcre_dep.found()
+ sordi = executable('sord_validate',
+ files('src/sord_validate.c'),
+ c_args: c_suppressions,
+ install: true,
+ dependencies: [sord_dep, pcre_dep])
+ endif
+
+ if not get_option('docs').disabled()
+ install_man(files('doc/sordi.1'))
+ install_man(files('doc/sord_validate.1'))
+ endif
+endif
+
+if not get_option('docs').disabled()
+ subdir('doc')
+endif
+
+if not get_option('tests').disabled()
+ subdir('test')
+endif
+
+if not meson.is_subproject()
+ summary('Tests', not get_option('tests').disabled(), bool_yn: true)
+ summary('Utilities', not get_option('tools').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'))
+
+ if not get_option('tools').disabled()
+ summary('Executables', get_option('prefix') / get_option('bindir'))
+ summary('Man pages', get_option('prefix') / get_option('mandir'))
+ endif
+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..77de770
--- /dev/null
+++ b/meson/suppressions/meson.build
@@ -0,0 +1,92 @@
+# 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 get_option('strict')
+ if cc.get_id() == 'clang'
+ c_suppressions += [
+ '-Wno-cast-align',
+ '-Wno-cast-qual',
+ '-Wno-conversion',
+ '-Wno-declaration-after-statement',
+ '-Wno-double-promotion',
+ '-Wno-format-nonliteral',
+ '-Wno-nullability-extension',
+ '-Wno-nullable-to-nonnull-conversion',
+ '-Wno-padded',
+ '-Wno-reserved-id-macro',
+ '-Wno-sign-conversion',
+ '-Wno-switch-enum',
+ '-Wno-unused-macros',
+ ]
+
+ if host_machine.system() == 'freebsd'
+ c_suppressions += [
+ '-Wno-c11-extensions',
+ ]
+ endif
+
+ elif cc.get_id() == 'gcc'
+ c_suppressions += [
+ '-Wno-cast-align',
+ '-Wno-cast-qual',
+ '-Wno-format-nonliteral',
+ '-Wno-inline',
+ '-Wno-padded',
+ '-Wno-sign-conversion',
+ '-Wno-strict-overflow',
+ '-Wno-suggest-attribute=const',
+ '-Wno-suggest-attribute=pure',
+ '-Wno-switch-default',
+ '-Wno-switch-enum',
+ '-Wno-unsuffixed-float-constants',
+ '-Wno-unused-const-variable',
+ '-Wno-unused-macros',
+ ]
+
+ if host_machine.system() == 'windows'
+ c_suppressions += [
+ '-Wno-float-conversion',
+ '-Wno-suggest-attribute=format',
+ ]
+ endif
+
+ elif cc.get_id() == 'msvc'
+ c_suppressions += [
+ '/wd4061', # enumerator in switch is not explicitly handled
+ '/wd4200', # zero-sized array in struct/union
+ '/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
+ '/wd4996', # function or variable may be unsafe
+ '/wd5045', # will insert Spectre mitigation for memory load
+ ]
+ endif
+ endif
+
+ if cc.get_id() == 'gcc' and host_machine.system() == 'windows'
+ c_suppressions += [
+ '-Wno-format',
+ ]
+ 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..4fb4168
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,14 @@
+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: 'Sord',
+ description: 'Project title')
+
+option('tools', type: 'feature', value: 'auto', yield: true,
+ description: 'Build command line utilities')
diff --git a/sord.pc.in b/sord.pc.in
deleted file mode 100644
index 64395c5..0000000
--- a/sord.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=@EXEC_PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: Sord
-Version: @SORD_VERSION@
-Description: A lightweight C library for storing RDF statements in memory.
-Requires: @SORD_PKG_DEPS@
-Libs: -L${libdir} -l@LIB_SORD@
-Cflags: -I${includedir}/sord-@SORD_MAJOR_VERSION@
diff --git a/src/sord.c b/src/sord.c
index 4ca022f..a80ab40 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -20,7 +20,7 @@
#include "serd/serd.h"
#include "sord/sord.h"
-#define ZIX_INLINE
+#define ZIX_STATIC
#include "zix/btree.c"
#include "zix/btree.h"
#include "zix/common.h"
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..72a4870
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,22 @@
+autoship = find_program('autoship', required: false)
+
+unit_tests = [
+ 'sord',
+]
+
+foreach unit : unit_tests
+ test(
+ unit,
+ executable(
+ 'test_@0@'.format(unit),
+ files('test_@0@.c'.format(unit)),
+ c_args: c_suppressions,
+ dependencies: sord_dep,
+ ),
+ suite: 'unit',
+ )
+endforeach
+
+if autoship.found()
+ test('autoship', autoship, args: ['test', sord_src_root], suite: 'data')
+endif
diff --git a/src/sord_test.c b/test/test_sord.c
index e451049..e451049 100644
--- a/src/sord_test.c
+++ b/test/test_sord.c
diff --git a/waf b/waf
deleted file mode 100755
index 887215c..0000000
--- a/waf
+++ /dev/null
@@ -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 e7d35dd..0000000
--- a/wscript
+++ /dev/null
@@ -1,413 +0,0 @@
-#!/usr/bin/env python
-
-import glob
-import os
-import sys
-
-from waflib import 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
-SORD_VERSION = '0.16.11'
-SORD_MAJOR_VERSION = '0'
-
-# Mandatory waf variables
-APPNAME = 'sord' # Package name for waf dist
-VERSION = SORD_VERSION # Package version for waf dist
-top = '.' # Source directory
-out = 'build' # Build directory
-
-# Release variables
-uri = 'http://drobilla.net/sw/sord'
-dist_pattern = 'http://download.drobilla.net/sord-%d.%d.%d.tar.bz2'
-post_tags = ['Hacking', 'RDF', 'Sord']
-
-def options(ctx):
- ctx.load('compiler_c')
- ctx.load('compiler_cxx')
- opt = ctx.configuration_options()
-
- ctx.add_flags(
- opt,
- {'no-utils': 'do not build command line utilities',
- 'static': 'build static library',
- 'no-shared': 'do not build shared library',
- 'static-progs': 'build programs as static binaries'})
-
- opt.add_option('--dump', type='string', default='', dest='dump',
- help='dump debugging output (iter, search, write, all)')
-
-def configure(conf):
- conf.load('compiler_c', cache=True)
- if Options.options.build_tests:
- try:
- conf.load('compiler_cxx', cache=True)
- except:
- Logs.warn("No C++ compiler, sordmm.hpp compile test skipped")
- pass
-
- conf.load('autowaf', cache=True)
- autowaf.set_c_lang(conf, 'c99')
- autowaf.set_cxx_lang(conf, 'c++14')
-
- conf.env.BUILD_UTILS = not Options.options.no_utils
- conf.env.BUILD_SHARED = not Options.options.no_shared
- conf.env.STATIC_PROGS = Options.options.static_progs
- conf.env.BUILD_STATIC = (Options.options.static or
- Options.options.static_progs)
-
- if Options.options.ultra_strict:
- autowaf.add_compiler_flags(conf.env, '*', {
- 'gcc': [
- '-Wno-cast-align',
- '-Wno-cast-qual',
- '-Wno-conversion',
- '-Wno-inline',
- '-Wno-padded',
- '-Wno-sign-conversion',
- '-Wno-stack-protector',
- '-Wno-suggest-attribute=const',
- '-Wno-suggest-attribute=pure',
- '-Wno-switch-enum',
- '-Wno-unused-macros',
- '-Wno-unused-parameter',
- '-Wno-vla',
- ],
- 'clang': [
- '-Wno-cast-align',
- '-Wno-cast-qual',
- '-Wno-format-nonliteral',
- '-Wno-nullability-extension',
- '-Wno-padded',
- '-Wno-reserved-id-macro',
- '-Wno-shorten-64-to-32',
- '-Wno-sign-conversion',
- '-Wno-switch-enum',
- '-Wno-unused-macros',
- '-Wno-unused-parameter',
- '-Wno-vla',
- ],
- 'msvc': [
- '/wd4061', # enumerator in switch is not explicitly handled
- '/wd4100', # unreferenced formal parameter
- '/wd4200', # zero-sized array in struct/union
- '/wd4244', # conversion with possible loss of data
- '/wd4267', # conversion from size_t to a smaller type
- '/wd4365', # signed/unsigned mismatch
- '/wd4389', # '==': signed/unsigned mismatch
- '/wd4514', # unreferenced inline function has been removed
- '/wd4702', # unreachable code
- '/wd4706', # assignment within conditional expression
- '/wd4820', # padding added after construct
- '/wd5045', # will insert Spectre mitigation for memory load
- ],
- })
-
- autowaf.add_compiler_flags(conf.env, 'cxx', {
- 'gcc': [
- '-Wno-effc++',
- '-Wno-multiple-inheritance',
- ],
- 'clang': [
- '-Wno-implicit-float-conversion',
- ],
- 'msvc': [
- '/wd4571', # catch semantics changed
- '/wd4625', # copy constructor implicitly deleted
- '/wd4626', # assignment opreator implicitly deleted
- ],
- })
-
- conf.check_pkg('serd-0 >= 0.30.0', uselib_store='SERD')
- conf.check_pkg('libpcre', uselib_store='PCRE', mandatory=False)
-
- if conf.env.HAVE_PCRE:
- if conf.check(cflags=['-pthread'], mandatory=False):
- conf.env.PTHREAD_CFLAGS = ['-pthread']
- if conf.env.CC_NAME != 'clang':
- conf.env.PTHREAD_LINKFLAGS = ['-pthread']
- elif conf.check(linkflags=['-lpthread'], mandatory=False):
- conf.env.PTHREAD_CFLAGS = []
- conf.env.PTHREAD_LINKFLAGS = ['-lpthread']
- else:
- conf.env.PTHREAD_CFLAGS = []
- conf.env.PTHREAD_LINKFLAGS = []
-
- # Parse dump options and define things accordingly
- dump = Options.options.dump.split(',')
- all = 'all' in dump
- if all or 'iter' in dump:
- conf.define('SORD_DEBUG_ITER', 1)
- if all or 'search' in dump:
- conf.define('SORD_DEBUG_SEARCH', 1)
- if all or 'write' in dump:
- conf.define('SORD_DEBUG_WRITE', 1)
-
- # Set up environment for building/using as a subproject
- autowaf.set_lib_env(conf, 'sord', SORD_VERSION,
- include_path=str(conf.path.find_node('include')))
-
- if conf.env.BUILD_UTILS and conf.env.HAVE_PCRE:
- sord_validate_node = conf.path.get_bld().make_node('sord_validate')
- conf.env.SORD_VALIDATE = [sord_validate_node.abspath()]
-
- conf.define('SORD_NO_DEFAULT_CONFIG', 1)
-
- autowaf.display_summary(
- conf,
- {'Static library': bool(conf.env.BUILD_STATIC),
- 'Shared library': bool(conf.env.BUILD_SHARED),
- 'Utilities': bool(conf.env.BUILD_UTILS),
- 'Unit tests': bool(conf.env.BUILD_TESTS),
- 'Debug dumping': dump})
-
-def build(bld):
- # C/C++ Headers
- includedir = '${INCLUDEDIR}/sord-%s/sord' % SORD_MAJOR_VERSION
- bld.install_files(includedir, bld.path.ant_glob('include/sord/*.h'))
- bld.install_files(includedir, bld.path.ant_glob('include/sord/*.hpp'))
-
- # Pkgconfig file
- autowaf.build_pc(bld, 'SORD', SORD_VERSION, SORD_MAJOR_VERSION, [],
- {'SORD_MAJOR_VERSION' : SORD_MAJOR_VERSION,
- 'SORD_PKG_DEPS' : 'serd-0'})
-
- source = 'src/sord.c src/syntax.c'
-
- libflags = ['-fvisibility=hidden']
- libs = ['m']
- defines = []
- if bld.env.MSVC_COMPILER:
- libflags = []
- libs = []
- defines = []
-
- # Shared Library
- if bld.env.BUILD_SHARED:
- obj = bld(features = 'c cshlib',
- source = source,
- includes = ['.', 'include', './src'],
- export_includes = ['.', 'include'],
- name = 'libsord',
- target = 'sord-%s' % SORD_MAJOR_VERSION,
- vnum = SORD_VERSION,
- install_path = '${LIBDIR}',
- libs = libs,
- uselib = 'SERD',
- defines = defines + ['SORD_INTERNAL', 'ZIX_STATIC'],
- cflags = libflags)
-
- # Static Library
- if bld.env.BUILD_STATIC:
- obj = bld(features = 'c cstlib',
- source = source,
- includes = ['.', 'include', './src'],
- export_includes = ['.', 'include'],
- name = 'libsord_static',
- target = 'sord-%s' % SORD_MAJOR_VERSION,
- vnum = SORD_VERSION,
- install_path = '${LIBDIR}',
- libs = libs,
- uselib = 'SERD',
- defines = ['SORD_STATIC',
- 'SORD_INTERNAL',
- 'ZIX_STATIC',
- 'ZIX_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']
-
- # Profiled static library for test coverage
- obj = bld(features = 'c cstlib',
- source = source,
- includes = ['.', 'include', './src'],
- name = 'libsord_profiled',
- target = 'sord_profiled',
- install_path = '',
- defines = defines + ['SORD_STATIC',
- 'SORD_INTERNAL',
- 'ZIX_STATIC',
- 'ZIX_INTERNAL'],
- cflags = test_cflags,
- linkflags = test_linkflags,
- lib = test_libs,
- uselib = 'SERD')
-
- # Unit test program
- obj = bld(features = 'c cprogram',
- source = 'src/sord_test.c',
- includes = ['.', 'include', './src'],
- use = 'libsord_profiled',
- lib = test_libs,
- target = 'sord_test',
- install_path = '',
- defines = defines + ['SORD_STATIC', 'ZIX_STATIC'],
- cflags = test_cflags,
- linkflags = test_linkflags,
- uselib = 'SERD')
-
- # Static profiled sordi for tests
- obj = bld(features = 'c cprogram',
- source = 'src/sordi.c',
- includes = ['.', 'include', './src'],
- use = 'libsord_profiled',
- lib = test_libs,
- target = 'sordi_static',
- install_path = '',
- defines = defines + ['SORD_STATIC', 'ZIX_STATIC'],
- cflags = test_cflags,
- linkflags = test_linkflags,
- uselib = 'SERD')
-
- # C++ build test
- if bld.env.COMPILER_CXX:
- obj = bld(features = 'cxx cxxprogram',
- source = 'src/sordmm_test.cpp',
- includes = ['.', 'include', './src'],
- use = 'libsord_profiled',
- lib = test_libs,
- target = 'sordmm_test',
- install_path = '',
- defines = defines + ['SORD_STATIC', 'ZIX_STATIC'],
- cxxflags = test_cflags,
- linkflags = test_linkflags,
- uselib = 'SERD')
-
- # Utilities
- if bld.env.BUILD_UTILS:
- utils = ['sordi']
- if bld.env.HAVE_PCRE:
- utils += ['sord_validate']
- for i in utils:
- obj = bld(features = 'c cprogram',
- source = 'src/%s.c' % i,
- includes = ['.', 'include', './src'],
- use = 'libsord',
- lib = libs,
- uselib = 'SERD',
- target = i,
- install_path = '${BINDIR}',
- defines = defines)
- if not bld.env.BUILD_SHARED or bld.env.STATIC_PROGS:
- obj.use = 'libsord_static'
- if bld.env.STATIC_PROGS:
- obj.env.SHLIB_MARKER = obj.env.STLIB_MARKER
- obj.linkflags = ['-static', '-Wl,--start-group']
- if i == 'sord_validate':
- obj.uselib += ' PCRE'
- obj.cflags = bld.env.PTHREAD_CFLAGS
- obj.linkflags = bld.env.PTHREAD_LINKFLAGS
-
- # Documentation
- autowaf.build_dox(bld, 'SORD', SORD_VERSION, top, out)
-
- # Man pages
- bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1'))
-
- bld.add_post_fun(autowaf.run_ldconfig)
-
-def lint(ctx):
- "checks code for style issues"
- import subprocess
- cmd = ("clang-tidy -p=. -header-filter=.* -checks=\"*," +
- "-cert-dcl03-c," +
- "-clang-analyzer-alpha.*," +
- "-google-readability-todo," +
- "-llvm-header-guard," +
- "-llvm-include-order," +
- "-misc-static-assert," +
- "-misc-unused-parameters," +
- "-readability-else-after-return\" " +
- "../src/*.c")
- subprocess.call(cmd, cwd='build', shell=True)
-
-def upload_docs(ctx):
- os.system('rsync -ravz --delete -e ssh build/doc/html/ drobilla@drobilla.net:~/drobilla.net/docs/sord/')
- for page in glob.glob('doc/*.[1-8]'):
- os.system('soelim %s | pre-grohtml troff -man -wall -Thtml | post-grohtml > build/%s.html' % (page, page))
- os.system('rsync -avz --delete -e ssh build/%s.html drobilla@drobilla.net:~/drobilla.net/man/' % page)
-
-def test(tst):
- import tempfile
- try:
- test_dir = os.path.join
- os.mkdir('tests')
- for i in glob.glob('tests/*.*'):
- os.remove(i)
- except:
- pass
-
- srcdir = tst.path.abspath()
- sordi = './sordi_static'
- base = 'http://example.org/'
- snippet = '<{0}s> <{0}p> <{0}o> .\n'.format(base)
- manifest = 'file://%s/tests/manifest.ttl' % srcdir.replace('\\', '/')
-
- with tst.group('Unit') as check:
- check(['./sord_test'])
-
- with tst.group('GoodCommands') as check:
- check([sordi, manifest])
- check([sordi, '%s/tests/UTF-8.ttl' % srcdir])
- check([sordi, '-v'])
- check([sordi, '-h'])
- check([sordi, '-s', '<foo> a <#Thingie> .', 'file:///test'])
- check([sordi, os.devnull], stdout=os.devnull)
- with tempfile.TemporaryFile(mode='r+') as stdin:
- stdin.write(snippet + '\n')
- check([sordi, '-', 'http://example.org/'], stdin=stdin)
- check([sordi, '-o', 'turtle', '-', 'http://example.org/'], stdin=stdin)
-
- with tst.group('BadCommands', expected=1) as check:
- check([sordi])
- check([sordi, 'ftp://example.org/unsupported.ttl'])
- check([sordi, '-i'])
- check([sordi, '-o'])
- check([sordi, '-z'])
- check([sordi, '-p'])
- check([sordi, '-c'])
- check([sordi, '-i illegal'])
- check([sordi, '-o illegal'])
- check([sordi, '-i turtle'])
- check([sordi, '-i ntriples'])
- check([sordi, '/no/such/file'])
-
- with tst.group('IoErrors', expected=1) as check:
- check([sordi, 'file://%s/' % srcdir], name='Read directory')
- if os.path.exists('/dev/full'):
- check([sordi, manifest], stdout='/dev/full', name='Write error')
-
- with tst.group('good', verbosity=0) as check:
- suite_base = 'http://www.w3.org/2001/sw/DataAccess/df1/'
- good_tests = glob.glob(os.path.join(srcdir, 'tests', 'test-*.ttl'))
- for test in good_tests:
- path = os.path.relpath(test, srcdir)
- base_uri = suite_base + path.replace('\\', '/')
-
- out_path = path + '.out'
- check([sordi, test, base_uri], stdout=out_path)
-
- check_path = test.replace('.ttl', '.out')
- out_lines = sorted(open(out_path).readlines())
- cmp_lines = sorted(open(check_path).readlines())
- check(lambda: out_lines == cmp_lines,
- name='%s check' % path)
-
-def posts(ctx):
- path = str(ctx.path.abspath())
- autowaf.news_to_posts(
- os.path.join(path, 'NEWS'),
- {'title' : 'Sord',
- 'description' : autowaf.get_blurb(os.path.join(path, 'README')),
- 'dist_pattern' : 'http://download.drobilla.net/sord-%s.tar.bz2'},
- { 'Author' : 'drobilla',
- 'Tags' : 'Hacking, RDF, Sord' },
- os.path.join(out, 'posts'))