@@ -1,42 +0,0 @@ | |||
--- src/state.c | |||
+++ src/state.c | |||
@@ -415,35 +415,18 @@ | |||
LILV_API void | |||
lilv_state_restore(const LilvState* state, | |||
- LilvInstance* instance, | |||
+ const LV2_State_Interface* iface, | |||
+ LV2_Handle handle, | |||
LilvSetPortValueFunc set_value, | |||
void* user_data, | |||
uint32_t flags, | |||
const LV2_Feature *const * features) | |||
{ | |||
- if (!state) { | |||
- LILV_ERROR("lilv_state_restore() called on NULL state\n"); | |||
- return; | |||
- } | |||
- | |||
- LV2_State_Map_Path map_path = { | |||
- (LilvState*)state, abstract_path, absolute_path }; | |||
- LV2_Feature map_feature = { LV2_STATE__mapPath, &map_path }; | |||
- | |||
- const LV2_Feature** sfeatures = add_features(features, &map_feature, NULL); | |||
- | |||
- const LV2_Descriptor* desc = instance ? instance->lv2_descriptor : NULL; | |||
- const LV2_State_Interface* iface = (desc && desc->extension_data) | |||
- ? (const LV2_State_Interface*)desc->extension_data(LV2_STATE__interface) | |||
- : NULL; | |||
- | |||
if (iface) { | |||
- iface->restore(instance->lv2_handle, retrieve_callback, | |||
- (LV2_State_Handle)state, flags, sfeatures); | |||
+ iface->restore(handle, retrieve_callback, | |||
+ (LV2_State_Handle)state, flags, features); | |||
} | |||
- free(sfeatures); | |||
- | |||
if (set_value) { | |||
lilv_state_emit_port_values(state, set_value, user_data); | |||
} |
@@ -1,10 +0,0 @@ | |||
--- src/util.c | |||
+++ src/util.c | |||
@@ -29,7 +29,6 @@ | |||
#include <string.h> | |||
#ifdef _WIN32 | |||
-# define _WIN32_WINNT 0x0600 /* for CreateSymbolicLink */ | |||
# include <windows.h> | |||
# include <direct.h> | |||
# include <io.h> |
@@ -1,470 +0,0 @@ | |||
#!/usr/bin/env python | |||
import os | |||
import shutil | |||
import subprocess | |||
import sys | |||
import waflib.Options as Options | |||
import waflib.extras.autowaf as autowaf | |||
import waflib.Build as Build | |||
import waflib.Logs as Logs | |||
# Library and package version (UNIX style major, minor, micro) | |||
# major increment <=> incompatible changes | |||
# minor increment <=> compatible changes (additions) | |||
# micro increment <=> no interface changes | |||
LILV_VERSION = '0.24.0' | |||
LILV_MAJOR_VERSION = '0' | |||
# Mandatory waf variables | |||
APPNAME = 'lilv' # Package name for waf dist | |||
VERSION = LILV_VERSION # Package version for waf dist | |||
top = '.' # Source directory | |||
out = 'build' # Build directory | |||
test_plugins = [ | |||
'bad_syntax', | |||
'failed_instantiation', | |||
'failed_lib_descriptor', | |||
'lib_descriptor', | |||
'missing_descriptor', | |||
'missing_name', | |||
'missing_plugin', | |||
'missing_port', | |||
'missing_port_name', | |||
'new_version', | |||
'old_version' | |||
] | |||
def options(opt): | |||
opt.load('compiler_c') | |||
opt.load('compiler_cxx') | |||
opt.load('python') | |||
autowaf.set_options(opt, test=True) | |||
opt.add_option('--no-utils', action='store_true', dest='no_utils', | |||
help='Do not build command line utilities') | |||
opt.add_option('--bindings', action='store_true', dest='bindings', | |||
help='Build python bindings') | |||
opt.add_option('--dyn-manifest', action='store_true', dest='dyn_manifest', | |||
help='Build support for dynamic manifests') | |||
opt.add_option('--no-bash-completion', action='store_true', | |||
dest='no_bash_completion', | |||
help='Do not install bash completion script in CONFIGDIR') | |||
opt.add_option('--static', action='store_true', dest='static', | |||
help='Build static library') | |||
opt.add_option('--no-shared', action='store_true', dest='no_shared', | |||
help='Do not build shared library') | |||
opt.add_option('--static-progs', action='store_true', dest='static_progs', | |||
help='Build programs as static binaries') | |||
opt.add_option('--default-lv2-path', type='string', default='', | |||
dest='default_lv2_path', | |||
help='Default LV2 path to use if LV2_PATH is unset') | |||
def configure(conf): | |||
conf.load('compiler_c') | |||
if Options.options.bindings: | |||
try: | |||
conf.load('python') | |||
conf.load('compiler_cxx') | |||
conf.check_python_headers() | |||
autowaf.define(conf, 'LILV_PYTHON', 1); | |||
except: | |||
Logs.warn('Failed to configure Python (%s)\n' % sys.exc_info()[1]) | |||
autowaf.configure(conf) | |||
autowaf.set_c99_mode(conf) | |||
autowaf.display_header('Lilv Configuration') | |||
conf.env.BASH_COMPLETION = not Options.options.no_bash_completion | |||
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 not conf.env.BUILD_SHARED and not conf.env.BUILD_STATIC: | |||
conf.fatal('Neither a shared nor a static build requested') | |||
autowaf.check_pkg(conf, 'lv2', uselib_store='LV2', | |||
atleast_version='1.14.0', mandatory=True) | |||
autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD', | |||
atleast_version='0.14.0', mandatory=True) | |||
autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD', | |||
atleast_version='0.13.0', mandatory=True) | |||
autowaf.check_pkg(conf, 'sratom-0', uselib_store='SRATOM', | |||
atleast_version='0.4.0', mandatory=True) | |||
autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', | |||
atleast_version='1.0.0', mandatory=False) | |||
defines = ['_POSIX_C_SOURCE=200809L', '_BSD_SOURCE', '_DEFAULT_SOURCE'] | |||
if conf.env.DEST_OS == 'darwin': | |||
defines += ['_DARWIN_C_SOURCE'] | |||
conf.check_cc(function_name='flock', | |||
header_name='sys/file.h', | |||
defines=defines, | |||
define_name='HAVE_FLOCK', | |||
mandatory=False) | |||
conf.check_cc(function_name='fileno', | |||
header_name='stdio.h', | |||
defines=defines, | |||
define_name='HAVE_FILENO', | |||
mandatory=False) | |||
conf.check_cc(function_name='clock_gettime', | |||
header_name=['sys/time.h','time.h'], | |||
defines=['_POSIX_C_SOURCE=200809L'], | |||
define_name='HAVE_CLOCK_GETTIME', | |||
uselib_store='CLOCK_GETTIME', | |||
lib=['rt'], | |||
mandatory=False) | |||
conf.check_cc(define_name = 'HAVE_LIBDL', | |||
lib = 'dl', | |||
mandatory = False) | |||
autowaf.define(conf, 'LILV_VERSION', LILV_VERSION) | |||
if Options.options.dyn_manifest: | |||
autowaf.define(conf, 'LILV_DYN_MANIFEST', 1) | |||
lilv_path_sep = ':' | |||
lilv_dir_sep = '/' | |||
if conf.env.DEST_OS == 'win32': | |||
lilv_path_sep = ';' | |||
lilv_dir_sep = '\\\\' | |||
autowaf.define(conf, 'LILV_PATH_SEP', lilv_path_sep) | |||
autowaf.define(conf, 'LILV_DIR_SEP', lilv_dir_sep) | |||
# Set default LV2 path | |||
lv2_path = Options.options.default_lv2_path | |||
if lv2_path == '': | |||
if conf.env.DEST_OS == 'darwin': | |||
lv2_path = lilv_path_sep.join(['~/Library/Audio/Plug-Ins/LV2', | |||
'~/.lv2', | |||
'/usr/local/lib/lv2', | |||
'/usr/lib/lv2', | |||
'/Library/Audio/Plug-Ins/LV2']) | |||
elif conf.env.DEST_OS == 'haiku': | |||
lv2_path = lilv_path_sep.join(['~/.lv2', | |||
'/boot/common/add-ons/lv2']) | |||
elif conf.env.DEST_OS == 'win32': | |||
lv2_path = lilv_path_sep.join(['%APPDATA%\\\\LV2', | |||
'%COMMONPROGRAMFILES%\\\\LV2']) | |||
else: | |||
libdirname = os.path.basename(conf.env.LIBDIR) | |||
lv2_path = lilv_path_sep.join(['~/.lv2', | |||
'/usr/%s/lv2' % libdirname, | |||
'/usr/local/%s/lv2' % libdirname]) | |||
autowaf.define(conf, 'LILV_DEFAULT_LV2_PATH', lv2_path) | |||
autowaf.set_lib_env(conf, 'lilv', LILV_VERSION) | |||
conf.write_config_header('lilv_config.h', remove=False) | |||
autowaf.display_msg(conf, 'Default LV2_PATH', | |||
conf.env.LILV_DEFAULT_LV2_PATH) | |||
autowaf.display_msg(conf, 'Utilities', | |||
bool(conf.env.BUILD_UTILS)) | |||
autowaf.display_msg(conf, 'Unit tests', | |||
bool(conf.env.BUILD_TESTS)) | |||
autowaf.display_msg(conf, 'Dynamic manifest support', | |||
bool(conf.env.LILV_DYN_MANIFEST)) | |||
autowaf.display_msg(conf, 'Python bindings', | |||
conf.is_defined('LILV_PYTHON')) | |||
conf.undefine('LILV_DEFAULT_LV2_PATH') # Cmd line errors with VC++ | |||
print('') | |||
def build_util(bld, name, defines, libs=''): | |||
obj = bld(features = 'c cprogram', | |||
source = name + '.c', | |||
includes = ['.', './src', './utils'], | |||
use = 'liblilv', | |||
target = name, | |||
defines = defines, | |||
install_path = '${BINDIR}') | |||
autowaf.use_lib(bld, obj, 'SERD SORD SRATOM LV2 ' + libs) | |||
if not bld.env.BUILD_SHARED or bld.env.STATIC_PROGS: | |||
obj.use = 'liblilv_static' | |||
if bld.env.STATIC_PROGS: | |||
if not bld.env.MSVC_COMPILER: | |||
obj.lib = ['m'] | |||
obj.env.SHLIB_MARKER = obj.env.STLIB_MARKER | |||
obj.linkflags = ['-static', '-Wl,--start-group'] | |||
return obj | |||
def build(bld): | |||
# C/C++ Headers | |||
includedir = '${INCLUDEDIR}/lilv-%s/lilv' % LILV_MAJOR_VERSION | |||
bld.install_files(includedir, bld.path.ant_glob('lilv/*.h')) | |||
bld.install_files(includedir, bld.path.ant_glob('lilv/*.hpp')) | |||
lib_source = ''' | |||
src/collections.c | |||
src/instance.c | |||
src/lib.c | |||
src/node.c | |||
src/plugin.c | |||
src/pluginclass.c | |||
src/port.c | |||
src/query.c | |||
src/scalepoint.c | |||
src/state.c | |||
src/ui.c | |||
src/util.c | |||
src/world.c | |||
src/zix/tree.c | |||
'''.split() | |||
lib = [] | |||
libflags = ['-fvisibility=hidden'] | |||
defines = [] | |||
if bld.is_defined('HAVE_LIBDL'): | |||
lib += ['dl'] | |||
if bld.env.DEST_OS == 'win32': | |||
lib = [] | |||
if bld.env.MSVC_COMPILER: | |||
libflags = [] | |||
defines = ['snprintf=_snprintf'] | |||
# Pkgconfig file | |||
autowaf.build_pc(bld, 'LILV', LILV_VERSION, LILV_MAJOR_VERSION, [], | |||
{'LILV_MAJOR_VERSION' : LILV_MAJOR_VERSION, | |||
'LILV_PKG_DEPS' : 'lv2 serd-0 sord-0 sratom-0', | |||
'LILV_PKG_LIBS' : ' -l'.join([''] + lib)}) | |||
# Shared Library | |||
if bld.env.BUILD_SHARED: | |||
obj = bld(features = 'c cshlib', | |||
export_includes = ['.'], | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
name = 'liblilv', | |||
target = 'lilv-%s' % LILV_MAJOR_VERSION, | |||
vnum = LILV_VERSION, | |||
install_path = '${LIBDIR}', | |||
defines = ['LILV_SHARED', 'LILV_INTERNAL'], | |||
cflags = libflags, | |||
lib = lib) | |||
autowaf.use_lib(bld, obj, 'SERD SORD SRATOM LV2') | |||
# Static library | |||
if bld.env.BUILD_STATIC: | |||
obj = bld(features = 'c cstlib', | |||
export_includes = ['.'], | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
name = 'liblilv_static', | |||
target = 'lilv-%s' % LILV_MAJOR_VERSION, | |||
vnum = LILV_VERSION, | |||
install_path = '${LIBDIR}', | |||
defines = defines + ['LILV_INTERNAL']) | |||
autowaf.use_lib(bld, obj, 'SERD SORD SRATOM LV2') | |||
if bld.env.BUILD_TESTS: | |||
test_libs = lib | |||
test_cflags = [''] | |||
test_linkflags = [''] | |||
if not bld.env.NO_COVERAGE: | |||
test_cflags += ['--coverage'] | |||
test_linkflags += ['--coverage'] | |||
# Test plugin library | |||
penv = bld.env.derive() | |||
shlib_pattern = penv.cshlib_PATTERN | |||
if shlib_pattern.startswith('lib'): | |||
shlib_pattern = shlib_pattern[3:] | |||
penv.cshlib_PATTERN = shlib_pattern | |||
shlib_ext = shlib_pattern[shlib_pattern.rfind('.'):] | |||
for p in ['test'] + test_plugins: | |||
obj = bld(features = 'c cshlib', | |||
env = penv, | |||
source = 'test/%s.lv2/%s.c' % (p, p), | |||
name = p, | |||
target = 'test/%s.lv2/%s' % (p, p), | |||
install_path = None, | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags, | |||
lib = test_libs, | |||
uselib = 'LV2') | |||
for p in test_plugins: | |||
if not bld.path.find_node('test/%s.lv2/test_%s.c' % (p, p)): | |||
continue | |||
obj = bld(features = 'c cprogram', | |||
source = 'test/%s.lv2/test_%s.c' % (p, p), | |||
target = 'test/test_%s' % p, | |||
includes = ['.', './src'], | |||
use = 'liblilv_profiled', | |||
install_path = None, | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags, | |||
lib = test_libs, | |||
uselib = 'LV2') | |||
autowaf.use_lib(bld, obj, 'SERD SORD SRATOM LV2') | |||
# Test plugin data files | |||
for p in ['test'] + test_plugins: | |||
for i in [ 'manifest.ttl.in', p + '.ttl.in' ]: | |||
bundle = 'test/%s.lv2/' % p | |||
bld(features = 'subst', | |||
source = bundle + i, | |||
target = bundle + i.replace('.in', ''), | |||
install_path = None, | |||
SHLIB_EXT = shlib_ext) | |||
# Static profiled library (for unit test code coverage) | |||
obj = bld(features = 'c cstlib', | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
name = 'liblilv_profiled', | |||
target = 'lilv_profiled', | |||
install_path = None, | |||
defines = defines + ['LILV_INTERNAL'], | |||
cflags = test_cflags, | |||
linkflags = test_linkflags, | |||
lib = test_libs) | |||
autowaf.use_lib(bld, obj, 'SERD SORD SRATOM LV2') | |||
# Unit test program | |||
testdir = os.path.abspath(autowaf.build_dir(APPNAME, 'test')) | |||
bpath = os.path.join(testdir, 'test.lv2') | |||
bpath = bpath.replace('\\', '/') | |||
testdir = testdir.replace('\\', '/') | |||
obj = bld(features = 'c cprogram', | |||
source = 'test/lilv_test.c', | |||
includes = ['.', './src'], | |||
use = 'liblilv_profiled', | |||
lib = test_libs, | |||
target = 'test/lilv_test', | |||
install_path = None, | |||
defines = (defines + ['LILV_TEST_BUNDLE=\"%s/\"' % bpath] + | |||
['LILV_TEST_DIR=\"%s/\"' % testdir]), | |||
cflags = test_cflags, | |||
linkflags = test_linkflags) | |||
autowaf.use_lib(bld, obj, 'SERD SORD SRATOM LV2') | |||
if bld.is_defined('LILV_PYTHON'): | |||
# Copy Python bindings to build directory | |||
bld(features = 'subst', | |||
is_copy = True, | |||
source = 'bindings/python/lilv.py', | |||
target = 'lilv.py', | |||
install_path = '${PYTHONDIR}') | |||
# Copy Python unittest files | |||
for i in [ 'test_api.py' ]: | |||
bld(features = 'subst', | |||
is_copy = True, | |||
source = 'bindings/test/python/' + i, | |||
target = 'bindings/' + i, | |||
install_path = None) | |||
# Build bindings test plugin | |||
obj = bld(features = 'c cshlib', | |||
env = penv, | |||
source = 'bindings/test/bindings_test_plugin.c', | |||
name = 'bindings_test_plugin', | |||
target = 'bindings/bindings_test_plugin.lv2/bindings_test_plugin', | |||
install_path = None, | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags, | |||
lib = test_libs, | |||
uselib = 'LV2') | |||
# Bindings test plugin data files | |||
for i in [ 'manifest.ttl.in', 'bindings_test_plugin.ttl.in' ]: | |||
bld(features = 'subst', | |||
source = 'bindings/test/' + i, | |||
target = 'bindings/bindings_test_plugin.lv2/' + i.replace('.in', ''), | |||
install_path = None, | |||
SHLIB_EXT = shlib_ext) | |||
# Utilities | |||
if bld.env.BUILD_UTILS: | |||
utils = ''' | |||
utils/lilv-bench | |||
utils/lv2info | |||
utils/lv2ls | |||
''' | |||
for i in utils.split(): | |||
build_util(bld, i, defines) | |||
if bld.env.HAVE_SNDFILE: | |||
obj = build_util(bld, 'utils/lv2apply', defines, 'SNDFILE') | |||
# lv2bench (less portable than other utilities) | |||
if bld.is_defined('HAVE_CLOCK_GETTIME') and not bld.env.STATIC_PROGS: | |||
obj = build_util(bld, 'utils/lv2bench', defines) | |||
if not bld.env.MSVC_COMPILER: | |||
obj.lib = ['rt'] | |||
# Documentation | |||
autowaf.build_dox(bld, 'LILV', LILV_VERSION, top, out) | |||
# Man pages | |||
bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1')) | |||
# Bash completion | |||
if bld.env.BASH_COMPLETION: | |||
bld.install_as( | |||
'${SYSCONFDIR}/bash_completion.d/lilv', 'utils/lilv.bash_completion') | |||
bld.add_post_fun(autowaf.run_ldconfig) | |||
if bld.env.DOCS: | |||
bld.add_post_fun(fix_docs) | |||
def fix_docs(ctx): | |||
if ctx.cmd == 'build': | |||
autowaf.make_simple_dox(APPNAME) | |||
def upload_docs(ctx): | |||
import glob | |||
os.system('rsync -ravz --delete -e ssh build/doc/html/ drobilla@drobilla.net:~/drobilla.net/docs/lilv/') | |||
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(ctx): | |||
assert ctx.env.BUILD_TESTS, "You have run waf configure without the --test flag. No tests were run." | |||
autowaf.pre_test(ctx, APPNAME) | |||
if ctx.is_defined('LILV_PYTHON'): | |||
os.environ['LD_LIBRARY_PATH'] = os.getcwd() | |||
autowaf.run_tests(ctx, APPNAME, ['python -m unittest discover bindings/']) | |||
os.environ['PATH'] = 'test' + os.pathsep + os.getenv('PATH') | |||
Logs.pprint('GREEN', '') | |||
autowaf.run_test(ctx, APPNAME, 'lilv_test', dirs=['./src','./test'], name='lilv_test') | |||
for p in test_plugins: | |||
test_prog = 'test_' + p + ' ' + ('test/%s.lv2/' % p) | |||
if os.path.exists('test/test_' + p): | |||
autowaf.run_test(ctx, APPNAME, test_prog, 0, | |||
dirs=['./src','./test','./test/%s.lv2' % p]) | |||
autowaf.post_test(ctx, APPNAME) | |||
try: | |||
shutil.rmtree('state') | |||
except: | |||
pass | |||
def lint(ctx): | |||
subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/include,-runtime/sizeof src/* lilv/*', shell=True) | |||
def posts(ctx): | |||
path = str(ctx.path.abspath()) | |||
autowaf.news_to_posts( | |||
os.path.join(path, 'NEWS'), | |||
{'title' : 'Lilv', | |||
'description' : autowaf.get_blurb(os.path.join(path, 'README')), | |||
'dist_pattern' : 'http://download.drobilla.net/lilv-%s.tar.bz2'}, | |||
{ 'Author' : 'drobilla', | |||
'Tags' : 'Hacking, LAD, LV2, Lilv' }, | |||
os.path.join(out, 'posts')) |
@@ -1,535 +0,0 @@ | |||
#!/usr/bin/env python | |||
import glob | |||
import os | |||
import shutil | |||
import subprocess | |||
import waflib.Logs as Logs | |||
import waflib.Options as Options | |||
import waflib.extras.autowaf as autowaf | |||
# Library and package version (UNIX style major, minor, micro) | |||
# major increment <=> incompatible changes | |||
# minor increment <=> compatible changes (additions) | |||
# micro increment <=> no interface changes | |||
SERD_VERSION = '0.24.0' | |||
SERD_MAJOR_VERSION = '0' | |||
# Mandatory waf variables | |||
APPNAME = 'serd' # Package name for waf dist | |||
VERSION = SERD_VERSION # Package version for waf dist | |||
top = '.' # Source directory | |||
out = 'build' # Build directory | |||
def options(opt): | |||
opt.load('compiler_c') | |||
autowaf.set_options(opt, test=True) | |||
opt.add_option('--no-utils', action='store_true', dest='no_utils', | |||
help='Do not build command line utilities') | |||
opt.add_option('--stack-check', action='store_true', dest='stack_check', | |||
help='Include runtime stack sanity checks') | |||
opt.add_option('--static', action='store_true', dest='static', | |||
help='Build static library') | |||
opt.add_option('--no-shared', action='store_true', dest='no_shared', | |||
help='Do not build shared library') | |||
opt.add_option('--static-progs', action='store_true', dest='static_progs', | |||
help='Build programs as static binaries') | |||
opt.add_option('--largefile', action='store_true', dest='largefile', | |||
help='Build with large file support on 32-bit systems') | |||
opt.add_option('--no-posix', action='store_true', dest='no_posix', | |||
help='Do not use posix_memalign, posix_fadvise, and fileno, even if present') | |||
def configure(conf): | |||
conf.load('compiler_c') | |||
autowaf.configure(conf) | |||
autowaf.display_header('Serd Configuration') | |||
autowaf.set_c99_mode(conf) | |||
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 not conf.env.BUILD_SHARED and not conf.env.BUILD_STATIC: | |||
conf.fatal('Neither a shared nor a static build requested') | |||
if Options.options.stack_check: | |||
autowaf.define(conf, 'SERD_STACK_CHECK', SERD_VERSION) | |||
if Options.options.largefile: | |||
conf.env.append_unique('DEFINES', ['_FILE_OFFSET_BITS=64']) | |||
if not Options.options.no_posix: | |||
conf.check(function_name = 'posix_memalign', | |||
header_name = 'stdlib.h', | |||
define_name = 'HAVE_POSIX_MEMALIGN', | |||
defines = ['_POSIX_C_SOURCE=200809L'], | |||
mandatory = False) | |||
conf.check(function_name = 'posix_fadvise', | |||
header_name = 'fcntl.h', | |||
define_name = 'HAVE_POSIX_FADVISE', | |||
defines = ['_POSIX_C_SOURCE=200809L'], | |||
mandatory = False) | |||
conf.check(function_name = 'fileno', | |||
header_name = 'stdio.h', | |||
define_name = 'HAVE_FILENO', | |||
defines = ['_POSIX_C_SOURCE=200809L'], | |||
mandatory = False) | |||
autowaf.define(conf, 'SERD_VERSION', SERD_VERSION) | |||
autowaf.set_lib_env(conf, 'serd', SERD_VERSION) | |||
conf.write_config_header('serd_config.h', remove=False) | |||
autowaf.display_msg(conf, 'Utilities', bool(conf.env.BUILD_UTILS)) | |||
autowaf.display_msg(conf, 'Unit tests', bool(conf.env.BUILD_TESTS)) | |||
print('') | |||
lib_source = [ | |||
'src/env.c', | |||
'src/node.c', | |||
'src/reader.c', | |||
'src/string.c', | |||
'src/uri.c', | |||
'src/writer.c', | |||
] | |||
def build(bld): | |||
# C Headers | |||
includedir = '${INCLUDEDIR}/serd-%s/serd' % SERD_MAJOR_VERSION | |||
bld.install_files(includedir, bld.path.ant_glob('serd/*.h')) | |||
# Pkgconfig file | |||
autowaf.build_pc(bld, 'SERD', SERD_VERSION, SERD_MAJOR_VERSION, [], | |||
{'SERD_MAJOR_VERSION' : SERD_MAJOR_VERSION}) | |||
libflags = ['-fvisibility=hidden'] | |||
libs = ['m'] | |||
defines = [] | |||
if bld.env.MSVC_COMPILER: | |||
libflags = [] | |||
libs = [] | |||
defines = ['snprintf=_snprintf'] | |||
# Shared Library | |||
if bld.env.BUILD_SHARED: | |||
bld(features = 'c cshlib', | |||
export_includes = ['.'], | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
lib = libs, | |||
name = 'libserd', | |||
target = 'serd-%s' % SERD_MAJOR_VERSION, | |||
vnum = SERD_VERSION, | |||
install_path = '${LIBDIR}', | |||
defines = defines + ['SERD_SHARED', 'SERD_INTERNAL'], | |||
cflags = libflags) | |||
# Static library | |||
if bld.env.BUILD_STATIC: | |||
bld(features = 'c cstlib', | |||
export_includes = ['.'], | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
lib = libs, | |||
name = 'libserd_static', | |||
target = 'serd-%s' % SERD_MAJOR_VERSION, | |||
vnum = SERD_VERSION, | |||
install_path = '${LIBDIR}', | |||
defines = defines + ['SERD_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 | |||
bld(features = 'c cstlib', | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
lib = test_libs, | |||
name = 'libserd_profiled', | |||
target = 'serd_profiled', | |||
install_path = '', | |||
defines = defines + ['SERD_INTERNAL'], | |||
cflags = test_cflags, | |||
linkflags = test_linkflags) | |||
# Static profiled serdi for tests | |||
bld(features = 'c cprogram', | |||
source = 'src/serdi.c', | |||
includes = ['.', './src'], | |||
use = 'libserd_profiled', | |||
lib = test_libs, | |||
target = 'serdi_static', | |||
install_path = '', | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags) | |||
# Unit test program | |||
bld(features = 'c cprogram', | |||
source = 'tests/serd_test.c', | |||
includes = ['.', './src'], | |||
use = 'libserd_profiled', | |||
lib = test_libs, | |||
target = 'serd_test', | |||
install_path = '', | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags) | |||
# Utilities | |||
if bld.env.BUILD_UTILS: | |||
obj = bld(features = 'c cprogram', | |||
source = 'src/serdi.c', | |||
target = 'serdi', | |||
includes = ['.', './src'], | |||
use = 'libserd', | |||
lib = libs, | |||
install_path = '${BINDIR}') | |||
if not bld.env.BUILD_SHARED or bld.env.STATIC_PROGS: | |||
obj.use = 'libserd_static' | |||
if bld.env.STATIC_PROGS: | |||
obj.env.SHLIB_MARKER = obj.env.STLIB_MARKER | |||
obj.linkflags = ['-static'] | |||
# Documentation | |||
autowaf.build_dox(bld, 'SERD', SERD_VERSION, top, out) | |||
# Man page | |||
bld.install_files('${MANDIR}/man1', 'doc/serdi.1') | |||
bld.add_post_fun(autowaf.run_ldconfig) | |||
if bld.env.DOCS: | |||
bld.add_post_fun(fix_docs) | |||
def lint(ctx): | |||
subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/include src/* serd/*', shell=True) | |||
def amalgamate(ctx): | |||
shutil.copy('serd/serd.h', 'build/serd.h') | |||
amalgamation = open('build/serd.c', 'w') | |||
serd_internal_h = open('src/serd_internal.h') | |||
for l in serd_internal_h: | |||
if l == '#include "serd/serd.h"\n': | |||
amalgamation.write('#include "serd.h"\n') | |||
else: | |||
amalgamation.write(l) | |||
serd_internal_h.close() | |||
for f in lib_source: | |||
fd = open(f) | |||
amalgamation.write('\n/**\n @file %s\n*/' % f) | |||
header = True | |||
for l in fd: | |||
if header: | |||
if l == '*/\n': | |||
header = False | |||
else: | |||
if l != '#include "serd_internal.h"\n': | |||
amalgamation.write(l) | |||
fd.close() | |||
amalgamation.close() | |||
for i in ['c', 'h']: | |||
Logs.info('Wrote build/serd.%s' % i) | |||
def fix_docs(ctx): | |||
if ctx.cmd == 'build': | |||
autowaf.make_simple_dox(APPNAME) | |||
def upload_docs(ctx): | |||
os.system('rsync -ravz --delete -e ssh build/doc/html/ drobilla@drobilla.net:~/drobilla.net/docs/serd/') | |||
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 file_equals(patha, pathb, subst_from='', subst_to=''): | |||
fa = open(patha, 'rU') | |||
fb = open(pathb, 'rU') | |||
for line in fa: | |||
if line.replace(subst_from, subst_to) != fb.readline().replace(subst_from, subst_to): | |||
return False | |||
fa.close() | |||
fb.close() | |||
return True | |||
def earl_assertion(test, passed, asserter): | |||
import datetime | |||
asserter_str = '' | |||
if asserter is not None: | |||
asserter_str = '\n\tearl:assertedBy <%s> ;' % asserter | |||
passed_str = 'earl:failed' | |||
if passed: | |||
passed_str = 'earl:passed' | |||
return ''' | |||
[] | |||
a earl:Assertion ;%s | |||
earl:subject <http://drobilla.net/sw/serd> ; | |||
earl:test <%s> ; | |||
earl:result [ | |||
a earl:TestResult ; | |||
earl:outcome %s ; | |||
dc:date "%s"^^xsd:dateTime | |||
] . | |||
''' % (asserter_str, | |||
test, | |||
passed_str, | |||
datetime.datetime.now().replace(microsecond=0).isoformat()) | |||
def check_output(out_filename, check_filename, subst_from='', subst_to=''): | |||
if not os.access(out_filename, os.F_OK): | |||
Logs.pprint('RED', 'FAIL: output %s is missing' % out_filename) | |||
elif not file_equals(check_filename, out_filename, subst_from, subst_to): | |||
Logs.pprint('RED', 'FAIL: %s != %s' % (os.path.abspath(out_filename), | |||
check_filename)) | |||
else: | |||
return True | |||
return False | |||
def test_thru(ctx, base, path, check_filename, flags): | |||
in_filename = os.path.join(ctx.path.abspath(), path); | |||
out_filename = path + '.thru' | |||
command = ('%s %s -i turtle -o turtle -p foo "%s" "%s" | ' | |||
'%s -i turtle -o ntriples -c foo - "%s" > %s') % ( | |||
'serdi_static', flags.ljust(5), | |||
in_filename, base, | |||
'serdi_static', base, out_filename) | |||
if autowaf.run_test(ctx, APPNAME, command, 0, name=out_filename): | |||
autowaf.run_test(ctx, APPNAME, | |||
[out_filename + '.check', check_output(out_filename, check_filename, '_:docid', '_:genid')], | |||
1) | |||
else: | |||
Logs.pprint('RED', 'FAIL: error running %s' % command) | |||
def test_manifest(ctx, srcdir, testdir, report, base_uri): | |||
import rdflib | |||
import urlparse | |||
rdf = rdflib.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#') | |||
rdfs = rdflib.Namespace('http://www.w3.org/2000/01/rdf-schema#') | |||
mf = rdflib.Namespace('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#') | |||
rdft = rdflib.Namespace('http://www.w3.org/ns/rdftest#') | |||
earl = rdflib.Namespace('http://www.w3.org/ns/earl#') | |||
model = rdflib.ConjunctiveGraph() | |||
model.parse(os.path.join(srcdir, 'tests', testdir, 'manifest.ttl'), | |||
rdflib.URIRef(base_uri + 'manifest.ttl'), | |||
format='n3') | |||
asserter = '' | |||
if os.getenv('USER') == 'drobilla': | |||
asserter = 'http://drobilla.net/drobilla#me' | |||
def run_test(action_node, expected_return): | |||
output = os.path.join('tests', testdir, action_node + '.out') | |||
action = os.path.join(srcdir, 'tests', testdir, action_node) | |||
rel = os.path.relpath(action, os.path.join(srcdir, 'tests', testdir)) | |||
command = 'serdi_static -f "%s" "%s" > %s' % (action, base_uri + rel, output) | |||
return autowaf.run_test(ctx, APPNAME, command, expected_return, name=str(action)) | |||
def run_tests(test_class, expected_return, check_result=False): | |||
autowaf.begin_tests(ctx, APPNAME, str(test_class)) | |||
for i in sorted(model.triples([None, rdf.type, test_class])): | |||
test = i[0] | |||
name = model.value(test, mf.name, None) | |||
action_node = model.value(test, mf.action, None)[len(base_uri):] | |||
passed = run_test(action_node, expected_return) | |||
if passed and check_result: | |||
result_node = model.value(test, mf.result, None)[len(base_uri):] | |||
action = os.path.join('tests', testdir, action_node) | |||
output = action + '.out' | |||
result = os.path.join(srcdir, 'tests', testdir, result_node) | |||
passed = check_output(output, result) | |||
test_thru(ctx, base_uri + action_node, action, result, "") | |||
report.write(earl_assertion(test, passed, asserter)) | |||
autowaf.end_tests(ctx, APPNAME, str(test_class)) | |||
run_tests(rdft.TestTurtlePositiveSyntax, 0) | |||
run_tests(rdft.TestTurtleNegativeSyntax, 1) | |||
run_tests(rdft.TestTurtleNegativeEval, 1) | |||
run_tests(rdft.TestTurtleEval, 0, True) | |||
def test(ctx): | |||
blddir = autowaf.build_dir(APPNAME, 'tests') | |||
for i in ['', 'bad', 'good', 'new', 'TurtleTests', 'extra']: | |||
try: | |||
os.makedirs(os.path.join(blddir, i)) | |||
except: | |||
pass | |||
for i in glob.glob(blddir + '/*.*'): | |||
os.remove(i) | |||
srcdir = ctx.path.abspath() | |||
orig_dir = os.path.abspath(os.curdir) | |||
os.chdir(os.path.join(srcdir, 'tests', 'good')) | |||
old_good_tests = glob.glob('*.ttl') | |||
old_good_tests.sort() | |||
old_good_tests.remove('manifest.ttl') | |||
good_tests = { 'good': old_good_tests } | |||
os.chdir(orig_dir) | |||
os.chdir(srcdir) | |||
bad_tests = glob.glob('tests/bad/*.ttl') | |||
bad_tests.sort() | |||
os.chdir(orig_dir) | |||
autowaf.pre_test(ctx, APPNAME) | |||
os.environ['PATH'] = '.' + os.pathsep + os.getenv('PATH') | |||
autowaf.run_test(ctx, APPNAME, 'serd_test', dirs=['.']) | |||
autowaf.run_tests(ctx, APPNAME, [ | |||
'serdi_static -q -o turtle "%s/tests/good/base.ttl" "base.ttl" > tests/good/base.ttl.out' % srcdir | |||
], 0, name='base') | |||
if not file_equals('%s/tests/good/base.ttl' % srcdir, 'tests/good/base.ttl.out'): | |||
Logs.pprint('RED', 'FAIL: build/tests/base.ttl.out is incorrect') | |||
nul = os.devnull | |||
autowaf.run_tests(ctx, APPNAME, [ | |||
'serdi_static "file://%s/tests/good/manifest.ttl" > %s' % (srcdir, nul), | |||
# 'serdi_static %s/tests/good/UTF-8.ttl > %s' % (srcdir, nul), | |||
'serdi_static -v > %s' % nul, | |||
'serdi_static -h > %s' % nul, | |||
'serdi_static -s "<foo> a <#Thingie> ." > %s' % nul, | |||
'serdi_static %s > %s' % (nul, nul) | |||
], 0, name='serdi-cmd-good') | |||
# Test read error by reading a directory | |||
autowaf.run_test(ctx, APPNAME, 'serdi_static "file://%s/"' % srcdir, | |||
1, name='read_error') | |||
# Test write error by writing to /dev/full | |||
if os.path.exists('/dev/full'): | |||
autowaf.run_test(ctx, APPNAME, | |||
'serdi_static "file://%s/tests/good/manifest.ttl" > /dev/full' % srcdir, | |||
1, name='write_error') | |||
autowaf.run_tests(ctx, APPNAME, [ | |||
'serdi_static -q "file://%s/tests/bad-id-clash.ttl" > %s' % (srcdir, nul), | |||
'serdi_static > %s' % nul, | |||
'serdi_static ftp://example.org/unsupported.ttl > %s' % nul, | |||
'serdi_static -i > %s' % nul, | |||
'serdi_static -o > %s' % nul, | |||
'serdi_static -z > %s' % nul, | |||
'serdi_static -p > %s' % nul, | |||
'serdi_static -c > %s' % nul, | |||
'serdi_static -r > %s' % nul, | |||
'serdi_static -i illegal > %s' % nul, | |||
'serdi_static -o illegal > %s' % nul, | |||
'serdi_static -i turtle > %s' % nul, | |||
'serdi_static /no/such/file > %s' % nul], | |||
1, name='serdi-cmd-bad') | |||
def test_base(test): | |||
return ('http://www.w3.org/2001/sw/DataAccess/df1/tests/' | |||
+ test.replace('\\', '/')) | |||
# Good tests | |||
for tdir, tests in good_tests.items(): | |||
commands = [] | |||
for test in tests: | |||
for lax in ['', '-l']: | |||
path = os.path.join('tests', tdir, test) | |||
commands += [ 'serdi_static %s -f "%s" "%s" > %s.out' % ( | |||
lax, os.path.join(srcdir, path), test_base(test), path) ] | |||
autowaf.run_tests(ctx, APPNAME, commands, 0, name=tdir) | |||
verify_tests = [] | |||
for test in tests: | |||
check_filename = os.path.join( | |||
srcdir, 'tests', tdir, test.replace('.ttl', '.nt')) | |||
out_filename = os.path.join('tests', tdir, test + '.out') | |||
if check_output(out_filename, check_filename): | |||
verify_tests += [[out_filename, 0]] | |||
else: | |||
verify_tests += [[out_filename, 1]] | |||
autowaf.run_tests(ctx, APPNAME, verify_tests, name='verify_turtle_to_ntriples') | |||
# Bad tests | |||
commands = [] | |||
for test in bad_tests: | |||
for lax in ['', '-l']: | |||
commands += [ 'serdi_static %s -q "%s" "%s" > %s.out' % ( | |||
lax, os.path.join(srcdir, test), test_base(test), test) ] | |||
autowaf.run_tests(ctx, APPNAME, commands, 1, name='bad') | |||
# Don't do a round-trip test for test-id.ttl, IDs have changed | |||
good_tests['good'].remove('test-id.ttl') | |||
# Round-trip good tests | |||
autowaf.begin_tests(ctx, APPNAME, 'round_trip_good') | |||
for tdir, tests in good_tests.items(): | |||
thru_tests = tests; | |||
commands = [] | |||
num = 0 | |||
for test in thru_tests: | |||
num += 1 | |||
flags = '' | |||
if (num % 2 == 0): | |||
flags += '-b' | |||
if (num % 5 == 0): | |||
flags += ' -f' | |||
if (num % 3 == 0): | |||
flags += ' -r http://www.w3.org/' | |||
if (num % 7 == 0): | |||
flags += ' -e' | |||
path = os.path.join('tests', tdir, test) | |||
check = os.path.join(srcdir, path.replace('.ttl', '.nt')) | |||
test_thru(ctx, test_base(test), path, check, flags) | |||
autowaf.end_tests(ctx, APPNAME, 'round_trip_good') | |||
# New manifest-driven tests | |||
try: | |||
report = open('earl.ttl', 'w') | |||
report.write('''@prefix earl: <http://www.w3.org/ns/earl#> . | |||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n''') | |||
serd_ttl = open(os.path.join(srcdir, 'serd.ttl')) | |||
for line in serd_ttl: | |||
report.write(line) | |||
serd_ttl.close() | |||
turtle_tests = 'http://www.w3.org/2013/TurtleTests/' | |||
test_manifest(ctx, srcdir, 'TurtleTests', report, turtle_tests) | |||
report.close() | |||
except: | |||
pass | |||
autowaf.post_test(ctx, APPNAME) | |||
def posts(ctx): | |||
path = str(ctx.path.abspath()) | |||
autowaf.news_to_posts( | |||
os.path.join(path, 'NEWS'), | |||
{'title' : 'Serd', | |||
'description' : autowaf.get_blurb(os.path.join(path, 'README')), | |||
'dist_pattern' : 'http://download.drobilla.net/serd-%s.tar.bz2'}, | |||
{ 'Author' : 'drobilla', | |||
'Tags' : 'Hacking, RDF, Serd' }, | |||
os.path.join(out, 'posts')) |
@@ -1,356 +0,0 @@ | |||
#!/usr/bin/env python | |||
import glob | |||
import os | |||
import subprocess | |||
import sys | |||
import waflib.Logs as Logs | |||
import waflib.Options as Options | |||
import waflib.extras.autowaf as 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.0' | |||
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 | |||
def options(opt): | |||
opt.load('compiler_c') | |||
opt.load('compiler_cxx') | |||
autowaf.set_options(opt, test=True) | |||
opt.add_option('--no-utils', action='store_true', dest='no_utils', | |||
help='Do not build command line utilities') | |||
opt.add_option('--static', action='store_true', dest='static', | |||
help='Build static library') | |||
opt.add_option('--no-shared', action='store_true', dest='no_shared', | |||
help='Do not build shared library') | |||
opt.add_option('--static-progs', action='store_true', dest='static_progs', | |||
help='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') | |||
if Options.options.build_tests: | |||
try: | |||
conf.load('compiler_cxx') | |||
except: | |||
Logs.warn("No C++ compiler, sordmm.hpp compile test skipped") | |||
pass | |||
autowaf.configure(conf) | |||
autowaf.set_c99_mode(conf) | |||
autowaf.display_header('Sord configuration') | |||
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) | |||
autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD', | |||
atleast_version='0.22.4', mandatory=True) | |||
autowaf.check_pkg(conf, 'libpcre', uselib_store='PCRE', mandatory=False) | |||
if conf.env.HAVE_PCRE: | |||
if conf.check(cflags=['-pthread'], mandatory=False): | |||
conf.env.PTHREAD_CFLAGS = ['-pthread'] | |||
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: | |||
autowaf.define(conf, 'SORD_DEBUG_ITER', 1) | |||
if all or 'search' in dump: | |||
autowaf.define(conf, 'SORD_DEBUG_SEARCH', 1) | |||
if all or 'write' in dump: | |||
autowaf.define(conf, 'SORD_DEBUG_WRITE', 1) | |||
autowaf.define(conf, 'SORD_VERSION', SORD_VERSION) | |||
autowaf.set_lib_env(conf, 'sord', SORD_VERSION) | |||
conf.write_config_header('sord_config.h', remove=False) | |||
autowaf.display_msg(conf, 'Utilities', bool(conf.env.BUILD_UTILS)) | |||
autowaf.display_msg(conf, 'Unit tests', bool(conf.env.BUILD_TESTS)) | |||
autowaf.display_msg(conf, 'Debug dumping', dump) | |||
print('') | |||
def build(bld): | |||
# C/C++ Headers | |||
includedir = '${INCLUDEDIR}/sord-%s/sord' % SORD_MAJOR_VERSION | |||
bld.install_files(includedir, bld.path.ant_glob('sord/*.h')) | |||
bld.install_files(includedir, bld.path.ant_glob('sord/*.hpp')) | |||
# Pkgconfig file | |||
autowaf.build_pc(bld, 'SORD', SORD_VERSION, SORD_MAJOR_VERSION, 'SERD', | |||
{'SORD_MAJOR_VERSION' : SORD_MAJOR_VERSION}) | |||
source = 'src/sord.c src/syntax.c' | |||
libflags = ['-fvisibility=hidden'] | |||
libs = ['m'] | |||
defines = [] | |||
if bld.env.MSVC_COMPILER: | |||
libflags = [] | |||
libs = [] | |||
defines = ['snprintf=_snprintf'] | |||
# Shared Library | |||
if bld.env.BUILD_SHARED: | |||
obj = bld(features = 'c cshlib', | |||
source = source, | |||
includes = ['.', './src'], | |||
export_includes = ['.'], | |||
name = 'libsord', | |||
target = 'sord-%s' % SORD_MAJOR_VERSION, | |||
vnum = SORD_VERSION, | |||
install_path = '${LIBDIR}', | |||
libs = libs, | |||
defines = defines + ['SORD_SHARED', 'SORD_INTERNAL'], | |||
cflags = libflags) | |||
autowaf.use_lib(bld, obj, 'SERD') | |||
# Static Library | |||
if bld.env.BUILD_STATIC: | |||
obj = bld(features = 'c cstlib', | |||
source = source, | |||
includes = ['.', './src'], | |||
export_includes = ['.'], | |||
name = 'libsord_static', | |||
target = 'sord-%s' % SORD_MAJOR_VERSION, | |||
vnum = SORD_VERSION, | |||
install_path = '${LIBDIR}', | |||
libs = libs, | |||
defines = ['SORD_INTERNAL']) | |||
autowaf.use_lib(bld, obj, 'SERD') | |||
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 = ['.', './src'], | |||
name = 'libsord_profiled', | |||
target = 'sord_profiled', | |||
install_path = '', | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags, | |||
lib = test_libs) | |||
autowaf.use_lib(bld, obj, 'SERD') | |||
# Unit test program | |||
obj = bld(features = 'c cprogram', | |||
source = 'src/sord_test.c', | |||
includes = ['.', './src'], | |||
use = 'libsord_profiled', | |||
lib = test_libs, | |||
target = 'sord_test', | |||
install_path = '', | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags) | |||
autowaf.use_lib(bld, obj, 'SERD') | |||
# Static profiled sordi for tests | |||
obj = bld(features = 'c cprogram', | |||
source = 'src/sordi.c', | |||
includes = ['.', './src'], | |||
use = 'libsord_profiled', | |||
lib = test_libs, | |||
target = 'sordi_static', | |||
install_path = '', | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags) | |||
autowaf.use_lib(bld, obj, 'SERD') | |||
# C++ build test | |||
if bld.env.COMPILER_CXX: | |||
obj = bld(features = 'cxx cxxprogram', | |||
source = 'src/sordmm_test.cpp', | |||
includes = ['.', './src'], | |||
use = 'libsord_profiled', | |||
lib = test_libs, | |||
target = 'sordmm_test', | |||
install_path = '', | |||
defines = defines, | |||
cxxflags = test_cflags, | |||
linkflags = test_linkflags) | |||
autowaf.use_lib(bld, obj, '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 = ['.', './src'], | |||
use = 'libsord', | |||
lib = libs, | |||
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'] | |||
autowaf.use_lib(bld, obj, 'SERD') | |||
if i == 'sord_validate': | |||
autowaf.use_lib(bld, obj, '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) | |||
if bld.env.DOCS: | |||
bld.add_post_fun(fix_docs) | |||
def lint(ctx): | |||
subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/include src/*.* sord/* src/zix/*.*', shell=True) | |||
def fix_docs(ctx): | |||
if ctx.cmd == 'build': | |||
autowaf.make_simple_dox(APPNAME) | |||
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(ctx): | |||
blddir = autowaf.build_dir(APPNAME, 'tests') | |||
try: | |||
os.makedirs(blddir) | |||
except: | |||
pass | |||
for i in glob.glob(blddir + '/*.*'): | |||
os.remove(i) | |||
srcdir = ctx.path.abspath() | |||
orig_dir = os.path.abspath(os.curdir) | |||
os.chdir(srcdir) | |||
good_tests = glob.glob('tests/test-*.ttl') | |||
good_tests.sort() | |||
os.chdir(orig_dir) | |||
autowaf.pre_test(ctx, APPNAME) | |||
os.environ['PATH'] = '.' + os.pathsep + os.getenv('PATH') | |||
nul = os.devnull | |||
snippet = '<s> <p> <o> .' | |||
if sys.platform == "win32": | |||
snippet = snippet.replace('<', '^<').replace('>', '^>') | |||
else: | |||
snippet = '"%s"' % snippet | |||
autowaf.run_tests(ctx, APPNAME, [ | |||
'sordi_static "file://%s/tests/manifest.ttl" > %s' % (srcdir, nul), | |||
'sordi_static "%s/tests/UTF-8.ttl" > %s' % (srcdir, nul), | |||
'sordi_static -v > %s' % nul, | |||
'sordi_static -h > %s' % nul, | |||
'sordi_static -s "<foo> a <#Thingie> ." file:///test > %s' % nul, | |||
'echo %s | sordi_static - http://example.org/' % snippet, | |||
'echo %s | sordi_static -o turtle - http://example.org/' % snippet, | |||
'sordi_static %s > %s' % (nul, nul)], | |||
0, name='sordi-cmd-good') | |||
# Test read error by reading a directory | |||
autowaf.run_test(ctx, APPNAME, 'sordi_static "file://%s/"' % srcdir, | |||
1, name='read_error') | |||
# Test write error by writing to /dev/full | |||
if os.path.exists('/dev/full'): | |||
autowaf.run_test(ctx, APPNAME, | |||
'sordi_static "file://%s/tests/good/manifest.ttl" > /dev/full' % srcdir, | |||
1, name='write_error') | |||
autowaf.run_tests(ctx, APPNAME, [ | |||
'sordi_static > %s' % nul, | |||
'sordi_static ftp://example.org/unsupported.ttl > %s' % nul, | |||
'sordi_static -i > %s' % nul, | |||
'sordi_static -o > %s' % nul, | |||
'sordi_static -z > %s' % nul, | |||
'sordi_static -p > %s' % nul, | |||
'sordi_static -c > %s' % nul, | |||
'sordi_static -i illegal > %s' % nul, | |||
'sordi_static -o illegal > %s' % nul, | |||
'sordi_static -i turtle > %s' % nul, | |||
'sordi_static -i ntriples > %s' % nul, | |||
'echo "<s> <p> <o> ." | sordi_static -', | |||
'sordi_static /no/such/file > %s' % nul], | |||
1, name='sordi-cmd-bad') | |||
Logs.pprint('GREEN', '') | |||
autowaf.run_test(ctx, APPNAME, 'sord_test', name='sord_test') | |||
commands = [] | |||
for test in good_tests: | |||
base_uri = 'http://www.w3.org/2001/sw/DataAccess/df1/' + test.replace('\\', '/') | |||
commands += [ 'sordi_static "%s" "%s" > %s.out' % ( | |||
os.path.join(srcdir, test), base_uri, test) ] | |||
autowaf.run_tests(ctx, APPNAME, commands, 0, name='good') | |||
verify_tests = [] | |||
for test in good_tests: | |||
out_filename = test + '.out' | |||
cmp_filename = srcdir + '/' + test.replace('.ttl', '.out') | |||
if not os.access(out_filename, os.F_OK): | |||
Logs.pprint('RED', '** FAIL %s output is missing' % test) | |||
verify_tests += [[out_filename, 1]] | |||
else: | |||
out_lines = sorted(open(out_filename).readlines()) | |||
cmp_lines = sorted(open(cmp_filename).readlines()) | |||
if out_lines != cmp_lines: | |||
verify_tests += [[out_filename, 1]] | |||
else: | |||
verify_tests += [[out_filename, 0]] | |||
autowaf.run_tests(ctx, APPNAME, verify_tests, name='verify_turtle_to_ntriples') | |||
autowaf.post_test(ctx, APPNAME) | |||
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')) |
@@ -1,172 +0,0 @@ | |||
#!/usr/bin/env python | |||
import os | |||
import subprocess | |||
import waflib.Logs as Logs | |||
import waflib.Options as Options | |||
import waflib.extras.autowaf as 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.0' | |||
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 | |||
def options(opt): | |||
opt.load('compiler_c') | |||
autowaf.set_options(opt, test=True) | |||
opt.add_option('--static', action='store_true', dest='static', | |||
help="Build static library") | |||
opt.add_option('--no-shared', action='store_true', dest='no_shared', | |||
help='Do not build shared library') | |||
def configure(conf): | |||
conf.load('compiler_c') | |||
autowaf.configure(conf) | |||
autowaf.set_c99_mode(conf) | |||
autowaf.display_header('Sratom Configuration') | |||
conf.env.BUILD_SHARED = not Options.options.no_shared | |||
conf.env.BUILD_STATIC = Options.options.static | |||
if not conf.env.BUILD_SHARED and not conf.env.BUILD_STATIC: | |||
conf.fatal('Neither a shared nor a static build requested') | |||
autowaf.check_pkg(conf, 'lv2', uselib_store='LV2', | |||
atleast_version='1.10.0', mandatory=True) | |||
autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD', | |||
atleast_version='0.23.0', mandatory=True) | |||
autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD', | |||
atleast_version='0.12.0', mandatory=True) | |||
autowaf.define(conf, 'SRATOM_VERSION', SRATOM_VERSION) | |||
autowaf.set_lib_env(conf, 'sratom', SRATOM_VERSION) | |||
conf.write_config_header('sratom_config.h', remove=False) | |||
autowaf.display_msg(conf, "Unit tests", bool(conf.env.BUILD_TESTS)) | |||
print('') | |||
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('sratom/*.h')) | |||
# Pkgconfig file | |||
autowaf.build_pc(bld, 'SRATOM', SRATOM_VERSION, SRATOM_MAJOR_VERSION, | |||
['SERD', 'SORD', 'LV2'], | |||
{'SRATOM_MAJOR_VERSION' : SRATOM_MAJOR_VERSION}) | |||
libflags = ['-fvisibility=hidden'] | |||
libs = ['m'] | |||
defines = [] | |||
if bld.env.MSVC_COMPILER: | |||
libflags = [] | |||
libs = [] | |||
defines = ['snprintf=_snprintf'] | |||
# Shared Library | |||
if bld.env.BUILD_SHARED: | |||
obj = bld(features = 'c cshlib', | |||
export_includes = ['.'], | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
lib = libs, | |||
name = 'libsratom', | |||
target = 'sratom-%s' % SRATOM_MAJOR_VERSION, | |||
vnum = SRATOM_VERSION, | |||
install_path = '${LIBDIR}', | |||
defines = defines + ['SRATOM_SHARED', 'SRATOM_INTERNAL'], | |||
cflags = libflags) | |||
autowaf.use_lib(bld, obj, 'SERD SORD LV2') | |||
# Static library | |||
if bld.env.BUILD_STATIC: | |||
obj = bld(features = 'c cstlib', | |||
export_includes = ['.'], | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
lib = libs, | |||
name = 'libsratom_static', | |||
target = 'sratom-%s' % SRATOM_MAJOR_VERSION, | |||
vnum = SRATOM_VERSION, | |||
install_path = '${LIBDIR}', | |||
defines = defines + ['SRATOM_INTERNAL']) | |||
autowaf.use_lib(bld, obj, 'SERD SORD LV2') | |||
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) | |||
obj = bld(features = 'c cstlib', | |||
source = lib_source, | |||
includes = ['.', './src'], | |||
lib = test_libs, | |||
name = 'libsratom_profiled', | |||
target = 'sratom_profiled', | |||
install_path = '', | |||
defines = defines + ['SRATOM_INTERNAL'], | |||
cflags = test_cflags, | |||
linkflags = test_linkflags) | |||
autowaf.use_lib(bld, obj, 'SERD SORD LV2') | |||
# Unit test program | |||
obj = bld(features = 'c cprogram', | |||
source = 'tests/sratom_test.c', | |||
includes = ['.', './src'], | |||
use = 'libsratom_profiled', | |||
lib = test_libs, | |||
target = 'sratom_test', | |||
install_path = '', | |||
defines = defines, | |||
cflags = test_cflags, | |||
linkflags = test_linkflags) | |||
autowaf.use_lib(bld, obj, 'SERD SORD LV2') | |||
# Documentation | |||
autowaf.build_dox(bld, 'SRATOM', SRATOM_VERSION, top, out) | |||
bld.add_post_fun(autowaf.run_ldconfig) | |||
if bld.env.DOCS: | |||
bld.add_post_fun(fix_docs) | |||
def test(ctx): | |||
autowaf.pre_test(ctx, APPNAME) | |||
os.environ['PATH'] = '.' + os.pathsep + os.getenv('PATH') | |||
Logs.pprint('GREEN', '') | |||
autowaf.run_test(ctx, APPNAME, 'sratom_test', dirs=['./src','./tests']) | |||
autowaf.post_test(ctx, APPNAME) | |||
def lint(ctx): | |||
subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/include src/* sratom/*', shell=True) | |||
def fix_docs(ctx): | |||
if ctx.cmd == 'build': | |||
autowaf.make_simple_dox(APPNAME) | |||
def upload_docs(ctx): | |||
os.system("rsync -ravz --delete -e ssh build/doc/html/ drobilla@drobilla.net:~/drobilla.net/docs/sratom/") | |||
def posts(ctx): | |||
path = str(ctx.path.abspath()) | |||
autowaf.news_to_posts( | |||
os.path.join(path, 'NEWS'), | |||
{'title' : 'Sratom', | |||
'description' : autowaf.get_blurb(os.path.join(path, 'README')), | |||
'dist_pattern' : 'http://download.drobilla.net/sratom-%s.tar.bz2'}, | |||
{ 'Author' : 'drobilla', | |||
'Tags' : 'Hacking, LAD, LV2, RDF, Sratom' }, | |||
os.path.join(out, 'posts')) |