Browse Source

WIP: Switch to Meson

zrythm_meson
David Robillard 1 year ago
parent
commit
9802a68353
  1. 3
      .gitmodules
  2. 194
      meson.build
  3. 196
      meson/meson.build
  4. 11
      meson_options.txt
  5. 11
      sord.pc.in
  6. 2
      src/sord.c
  7. 2
      src/syntax.c
  8. 18
      test/meson.build
  9. 6
      test/test_sord.c
  10. 27
      waf
  11. 1
      waflib
  12. 407
      wscript

3
.gitmodules

@ -1,3 +0,0 @@
[submodule "waflib"]
path = waflib
url = ../autowaf.git

194
meson.build

@ -0,0 +1,194 @@
project('sord', ['c'],
version: '0.16.9',
license: 'ISC',
meson_version: '>= 0.49.2',
default_options: [
'b_ndebug=if-release',
'buildtype=release',
'c_std=c99',
'default_library=shared',
'warning_level=2',
])
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
# Load build tools
pkg = import('pkgconfig')
cc = meson.get_compiler('c')
# Set ultra strict warnings for developers, if requested
if get_option('strict')
subdir('meson')
c_warnings = all_c_warnings
if cc.get_id() == 'clang'
c_warnings += [
'-Wno-bad-function-cast',
'-Wno-cast-align',
'-Wno-cast-qual',
'-Wno-conversion',
'-Wno-covered-switch-default',
'-Wno-disabled-macro-expansion',
'-Wno-double-promotion',
'-Wno-format-nonliteral',
'-Wno-implicit-fallthrough',
'-Wno-nullability-extension',
'-Wno-nullable-to-nonnull-conversion',
'-Wno-padded',
'-Wno-reserved-id-macro',
'-Wno-sign-conversion',
]
elif cc.get_id() == 'gcc'
c_warnings += [
'-Wno-bad-function-cast',
'-Wno-cast-align',
'-Wno-cast-qual',
'-Wno-float-conversion',
'-Wno-format-nonliteral',
'-Wno-inline',
'-Wno-padded',
'-Wno-sign-conversion',
'-Wno-switch-default',
'-Wno-unsuffixed-float-constants',
'-Wno-unused-const-variable',
]
elif cc.get_id() == 'msvc'
c_warnings += [
'/wd4061', # enumerator in switch is not explicitly handled
'/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', # POSIX name for this item is deprecated
'/wd5045', # will insert Spectre mitigation for memory load
]
endif
add_project_arguments(cc.get_supported_arguments(c_warnings),
language: ['c'])
endif
# Add special arguments for MSVC
if cc.get_id() == 'msvc'
msvc_args = [
'/D_CRT_SECURE_NO_WARNINGS',
'/TP',
'/experimental:external',
'/external:W0',
'/external:anglebrackets',
]
add_project_arguments(msvc_args, language: ['c'])
endif
c_headers = ['include/sord/sord.h']
c_header_files = files(c_headers)
sources = [
'src/sord.c',
'src/syntax.c',
]
# System libraries
m_dep = cc.find_library('m', required: false)
# Depdencies
serd_dep = dependency('serd-0', version: '>= 0.30.9')
# Determine library type and the flags needed to build it
if get_option('default_library') == 'both'
if host_machine.system() == 'windows'
error('default_library=both is not supported on Windows')
endif
library_type = 'both_libraries'
library_args = ['-DSORD_INTERNAL']
prog_args = []
elif get_option('default_library') == 'shared'
library_type = 'shared_library'
library_args = ['-DSORD_INTERNAL']
prog_args = []
else
library_type = 'static_library'
library_args = ['-DSORD_INTERNAL', '-DSORD_STATIC']
prog_args = ['-DSORD_STATIC']
endif
# Build shared and/or static library/libraries
libsord = build_target(
versioned_name,
sources,
version: meson.project_version(),
include_directories: include_directories(['include', 'src']),
c_args: library_args,
dependencies: [m_dep, serd_dep],
gnu_symbol_visibility: 'hidden',
install: true,
target_type: library_type)
sord_dep = declare_dependency(
include_directories: include_directories(['include']),
dependencies: [m_dep, serd_dep],
link_with: libsord)
pkg.generate(
libsord,
name: 'Sord',
filebase: versioned_name,
subdirs: [versioned_name],
version: meson.project_version(),
description: 'A lightweight library for storing RDF in memory')
# Build sordi command line utility
if get_option('utils')
sordi = executable('sordi', 'src/sordi.c',
c_args: prog_args,
install: true,
dependencies: sord_dep)
pcre_dep = dependency('libpcre', required: false)
if pcre_dep.found()
sordi = executable('sord_validate', 'src/sord_validate.c',
c_args: prog_args,
install: true,
dependencies: [sord_dep, pcre_dep])
endif
if not get_option('docs').disabled()
install_man('doc/sordi.1')
install_man('doc/sord_validate.1')
endif
endif
# Install header to a versioned include directory
install_headers(c_headers, subdir: versioned_name / 'sord')
# if not get_option('docs').disabled()
# subdir('doc')
# endif
if get_option('tests')
subdir('test')
endif
if meson.version().version_compare('>=0.53.0')
summary('Tests', get_option('tests'), bool_yn: true)
summary('Utilities', get_option('utils'), 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 get_option('utils')
summary('Executables', get_option('prefix') / get_option('bindir'))
summary('Man pages', get_option('prefix') / get_option('mandir'))
endif
endif

196
meson/meson.build

@ -0,0 +1,196 @@
# General code to enable approximately all warnings.
#
# This is trivial for clang and MSVC, but GCC does not have such an option, and
# has several esoteric warnings, so we need to enable everything we want
# explicitly. We enable everything that does not require a value argument,
# except for warnings that are only relevant for very old languages (earlier
# than C99 or C++11) or non-standard extensions.
#
# Omitted common warnings:
#
# 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
#
# Omitted C warnings:
#
# Wc90-c99-compat
# Wdeclaration-after-statement
# Wtraditional
# Wtraditional-conversion
#
# Omitted C++ warnings:
#
# Wnamespaces
# Wtemplates
gcc_common_warnings = [
'-Walloc-zero',
'-Walloca',
'-Wanalyzer-too-complex',
'-Warith-conversion',
'-Warray-bounds=2',
'-Wattribute-alias=2',
'-Wcast-align=strict',
'-Wcast-qual',
'-Wconversion',
'-Wdate-time',
'-Wdisabled-optimization',
'-Wdouble-promotion',
'-Wduplicated-branches',
'-Wduplicated-cond',
'-Wfloat-equal',
'-Wformat-overflow=2',
'-Wformat-signedness',
'-Wformat-truncation=2',
'-Wformat=2',
'-Wimplicit-fallthrough=2',
'-Winit-self',
'-Winline',
'-Winvalid-pch',
'-Wlogical-op',
'-Wmissing-declarations',
'-Wmissing-include-dirs',
'-Wmultichar',
'-Wnormalized=nfc',
'-Wnull-dereference',
'-Wpacked',
'-Wpadded',
'-Wredundant-decls',
'-Wscalar-storage-order',
'-Wshadow',
'-Wshift-overflow=2',
'-Wsizeof-array-argument',
'-Wstack-protector',
'-Wstrict-aliasing=3',
'-Wstrict-overflow=5',
'-Wstringop-overflow=3',
'-Wsuggest-attribute=cold',
'-Wsuggest-attribute=const',
'-Wsuggest-attribute=format',
'-Wsuggest-attribute=malloc',
'-Wsuggest-attribute=noreturn',
'-Wsuggest-attribute=pure',
'-Wswitch-default',
'-Wswitch-enum',
'-Wsync-nand',
'-Wundef',
'-Wunused-const-variable=2',
'-Wunused-macros',
'-Wvarargs',
'-Wvector-operation-performance',
'-Wvla',
'-Wwrite-strings',
]
gcc_c_warnings = [
'-Wbad-function-cast',
'-Wc++-compat',
'-Wc99-c11-compat',
'-Wdesignated-init',
'-Wdiscarded-array-qualifiers',
'-Wdiscarded-qualifiers',
'-Wincompatible-pointer-types',
'-Wjump-misses-init',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-definition',
'-Wstrict-prototypes',
'-Wunsuffixed-float-constants',
]
# Set all_c_warnings for the current C compiler
if is_variable('cc')
if cc.get_id() == 'clang'
all_c_warnings = ['-Weverything']
elif cc.get_id() == 'gcc'
all_c_warnings = gcc_common_warnings + [
'-Wbad-function-cast',
'-Wc++-compat',
'-Wc99-c11-compat',
'-Wdesignated-init',
'-Wdiscarded-array-qualifiers',
'-Wdiscarded-qualifiers',
'-Wincompatible-pointer-types',
'-Wjump-misses-init',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-definition',
'-Wstrict-prototypes',
'-Wunsuffixed-float-constants',
]
elif cc.get_id() == 'msvc'
all_c_warnings = ['/Wall']
else
all_c_warnings = []
endif
endif
# Set all_cpp_warnings for the current C++ compiler
if is_variable('cpp')
if cpp.get_id() == 'clang'
all_cpp_warnings = [
'-Weverything',
'-Wno-c++98-compat',
'-Wno-c++98-compat-pedantic'
]
elif cpp.get_id() == 'gcc'
all_cpp_warnings = gcc_common_warnings + [
'-Wabi-tag',
'-Waligned-new=all',
'-Wcatch-value=3',
'-Wcomma-subscript',
'-Wconditionally-supported',
'-Wctor-dtor-privacy',
'-Wdeprecated-copy-dtor',
'-Weffc++',
'-Wextra-semi',
'-Wmismatched-tags',
'-Wmultiple-inheritance',
'-Wnoexcept',
'-Wnoexcept-type',
'-Wnon-virtual-dtor',
'-Wold-style-cast',
'-Woverloaded-virtual',
'-Wplacement-new=2',
'-Wredundant-tags',
'-Wregister',
'-Wsign-promo',
'-Wstrict-null-sentinel',
'-Wsuggest-final-methods',
'-Wsuggest-final-types',
'-Wsuggest-override',
'-Wuseless-cast',
'-Wvirtual-inheritance',
'-Wvolatile',
'-Wzero-as-null-pointer-constant',
]
elif cpp.get_id() == 'msvc'
all_cpp_warnings = ['/Wall']
else
all_cpp_warnings = []
endif
endif
# Set all_objc_warnings for the current Objective C compiler
if is_variable('objcc')
all_objc_warnings = []
if objcc.get_id() == 'clang'
all_objc_warnings = ['-Weverything']
elif objc.get_id() == 'gcc'
all_objc_warnings = gcc_common_warnings + [
'-Wno-direct-ivar-access',
]
else
all_objc_warnings = []
endif
endif

11
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: 'boolean', value: true, yield: true,
description: 'Build tests')
option('utils', type: 'boolean', value: true, yield: true,
description: 'Build command line utilities')

11
sord.pc.in

@ -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@

2
src/sord.c

@ -751,6 +751,8 @@ sord_node_free_internal(SordWorld* world, SordNode* node)
static void
sord_add_quad_ref(SordModel* model, const SordNode* node, SordQuadIndex i)
{
(void)model;
if (node) {
assert(node->refs > 0);
++((SordNode*)node)->refs;

2
src/syntax.c

@ -66,6 +66,8 @@ sord_inserter_write_statement(SordInserter* inserter,
const SerdNode* object_datatype,
const SerdNode* object_lang)
{
(void)flags;
SordWorld* world = sord_get_world(inserter->model);
SerdEnv* env = inserter->env;

18
test/meson.build

@ -0,0 +1,18 @@
autoship = find_program('autoship', required: false)
unit_tests = [
'sord',
]
foreach unit : unit_tests
test(unit,
executable('test_@0@'.format(unit),
'test_@0@.c'.format(unit),
c_args: prog_args,
dependencies: sord_dep),
suite: 'unit')
endforeach
if autoship.found()
test('autoship', autoship, args: ['test', sord_src_root], suite: 'data')
endif

6
src/sord_test.c → test/test_sord.c

@ -372,6 +372,8 @@ test_read(SordWorld* world, SordModel* sord, SordNode* g, const size_t n_quads)
static SerdStatus
unexpected_error(void* handle, const SerdError* error)
{
(void)handle;
fprintf(stderr, "unexpected error: ");
vfprintf(stderr, error->fmt, *error->args);
return SERD_SUCCESS;
@ -380,6 +382,8 @@ unexpected_error(void* handle, const SerdError* error)
static SerdStatus
expected_error(void* handle, const SerdError* error)
{
(void)handle;
fprintf(stderr, "expected error: ");
vfprintf(stderr, error->fmt, *error->args);
++n_expected_errors;
@ -395,7 +399,7 @@ finished(SordWorld* world, SordModel* sord, int status)
}
int
main(int argc, char** argv)
main(void)
{
static const size_t n_quads = 300;

27
waf

@ -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()

1
waflib

@ -1 +0,0 @@
Subproject commit b600c928b221a001faeab7bd92786d0b25714bc8

407
wscript

@ -1,407 +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.8'
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++11')
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'],
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'])
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'],
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'],
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'],
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'],
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'))
Loading…
Cancel
Save