summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-09-23 15:47:18 +0200
committerDavid Robillard <d@drobilla.net>2018-09-23 15:47:18 +0200
commit710ba008f7c90d1f1e05254f123026ae3cc5ef4a (patch)
tree6280a3624b26acea45a01fbe655f0fc58a17b685
parentb1212baa6fd2ff00c64a779f6ee2570cf60547b0 (diff)
downloadzix-710ba008f7c90d1f1e05254f123026ae3cc5ef4a.tar.gz
zix-710ba008f7c90d1f1e05254f123026ae3cc5ef4a.tar.bz2
zix-710ba008f7c90d1f1e05254f123026ae3cc5ef4a.zip
Update waf
-rwxr-xr-xwafbin96414 -> 108918 bytes
-rw-r--r--wscript216
2 files changed, 111 insertions, 105 deletions
diff --git a/waf b/waf
index ab4ed38..a16e11e 100755
--- a/waf
+++ b/waf
Binary files differ
diff --git a/wscript b/wscript
index d3c37a2..ca93a5a 100644
--- a/wscript
+++ b/wscript
@@ -1,59 +1,48 @@
#!/usr/bin/env python
-import filecmp
-import glob
+
import os
-import shutil
import subprocess
+import sys
-from waflib.extras import autowaf as autowaf
-import waflib.Logs as Logs, waflib.Options as Options
-
-# Version of this package (even if built as a child)
-ZIX_VERSION = '0.0.2'
-ZIX_MAJOR_VERSION = '0'
+from waflib import Logs, Options
+from waflib.extras import autowaf
-# Library version (UNIX style major, minor, micro)
+# Library and package version (UNIX style major, minor, micro)
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
-# Zix uses the same version number for both library and package
-ZIX_LIB_VERSION = ZIX_VERSION
-
-# Variables for 'waf dist'
-APPNAME = 'zix'
-VERSION = ZIX_VERSION
-
-# Mandatory variables
-top = '.'
-out = 'build'
-
-def options(opt):
- autowaf.set_options(opt)
- opt.load('compiler_c')
- opt.add_option('--test', action='store_true', dest='build_tests',
- help='Build unit tests')
- opt.add_option('--bench', action='store_true', dest='build_bench',
- help='Build benchmarks')
- opt.add_option('--static', action='store_true', dest='static',
- help='Build static library')
+ZIX_VERSION = '0.0.2'
+ZIX_MAJOR_VERSION = '0'
+
+# Mandatory waf variables
+APPNAME = 'zix' # Package name for waf dist
+VERSION = ZIX_VERSION # Package version for waf dist
+top = '.' # Source directory
+out = 'build' # Build directory
+
+def options(ctx):
+ ctx.load('compiler_c')
+ autowaf.set_options(ctx, test=True)
+ opt = ctx.get_option_group('Configuration options')
+ autowaf.add_flags(opt, {'bench': 'build benchmarks',
+ 'static': 'build static library'})
opt.add_option('--page-size', type='int', default=4096, dest='page_size',
help='Page size for B-tree')
def configure(conf):
+ autowaf.display_header('Zix Configuration')
conf.load('compiler_c')
autowaf.configure(conf)
- autowaf.set_c99_mode(conf)
- autowaf.display_header('Zix Configuration')
+ autowaf.set_c_lang(conf, 'c99')
- conf.env.BUILD_BENCH = Options.options.build_bench
- conf.env.BUILD_TESTS = Options.options.build_tests
+ conf.env.BUILD_BENCH = Options.options.bench
conf.env.BUILD_STATIC = Options.options.static
# Check for mlock
- conf.check(function_name='mlock',
- header_name='sys/mman.h',
- define_name='HAVE_MLOCK',
- mandatory=False)
+ autowaf.check_function(conf, 'c', 'mlock',
+ header_name='sys/mman.h',
+ define_name='HAVE_MLOCK',
+ mandatory=False)
# Check for gcov library (for test coverage)
if conf.env.BUILD_TESTS:
@@ -61,19 +50,21 @@ def configure(conf):
define_name='HAVE_GCOV',
mandatory=False)
- if Options.options.build_bench:
+ if Options.options.bench:
autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB',
atleast_version='2.0.0', mandatory=False)
if not conf.is_defined('HAVE_GLIB'):
conf.fatal('Glib is required to build benchmarks')
- autowaf.define(conf, 'ZIX_VERSION', ZIX_VERSION)
- autowaf.define(conf, 'ZIX_BTREE_PAGE_SIZE', Options.options.page_size)
+ conf.define('ZIX_VERSION', ZIX_VERSION)
+ conf.define('ZIX_BTREE_PAGE_SIZE', Options.options.page_size)
conf.write_config_header('zix-config.h', remove=False)
- autowaf.display_msg(conf, 'Unit tests', str(conf.env.BUILD_TESTS))
- autowaf.display_msg(conf, 'Benchmarks', str(conf.env.BUILD_BENCH))
- print('')
+ autowaf.display_summary(
+ conf,
+ {'Build unit tests': bool(conf.env.BUILD_TESTS),
+ 'Build benchmarks': bool(conf.env.BUILD_BENCH),
+ 'Page size': Options.options.page_size})
tests = [
'hash_test',
@@ -96,13 +87,13 @@ def build(bld):
# Pkgconfig file
autowaf.build_pc(bld, 'ZIX', ZIX_VERSION, ZIX_MAJOR_VERSION, [],
- {'ZIX_MAJOR_VERSION' : ZIX_MAJOR_VERSION})
+ {'ZIX_MAJOR_VERSION': ZIX_MAJOR_VERSION})
framework = ''
- if Options.platform == 'darwin':
+ if sys.platform == 'darwin':
framework = ['CoreServices']
- libflags = [ '-fvisibility=hidden' ]
+ libflags = ['-fvisibility=hidden']
if bld.env.MSVC_COMPILER:
libflags = []
@@ -122,75 +113,76 @@ def build(bld):
'''
# Library
- obj = bld(features = 'c cshlib',
- export_includes = ['.'],
- source = lib_source,
- includes = ['.'],
- name = 'libzix',
- target = 'zix',
- vnum = ZIX_LIB_VERSION,
- install_path = '${LIBDIR}',
- framework = framework,
- cflags = libflags + ['-DZIX_SHARED',
- '-DZIX_INTERNAL'])
+ bld(features = 'c cshlib',
+ export_includes = ['.'],
+ source = lib_source,
+ includes = ['.'],
+ name = 'libzix',
+ target = 'zix',
+ vnum = ZIX_VERSION,
+ install_path = '${LIBDIR}',
+ framework = framework,
+ cflags = libflags + ['-DZIX_SHARED', '-DZIX_INTERNAL'])
if bld.env.BUILD_STATIC or bld.env.BUILD_BENCH:
- obj = bld(features = 'c cstlib',
- export_includes = ['.'],
- source = lib_source,
- includes = ['.'],
- name = 'libzix_static',
- target = 'zix',
- vnum = ZIX_LIB_VERSION,
- install_path = None,
- framework = framework,
- cflags = libflags + ['-DZIX_SHARED',
- '-DZIX_INTERNAL'])
+ bld(features = 'c cstlib',
+ export_includes = ['.'],
+ source = lib_source,
+ includes = ['.'],
+ name = 'libzix_static',
+ target = 'zix',
+ vnum = ZIX_VERSION,
+ install_path = None,
+ framework = framework,
+ cflags = libflags + ['-DZIX_SHARED', '-DZIX_INTERNAL'])
if bld.env.BUILD_TESTS:
- test_libs = ['pthread', 'dl']
- test_cflags = []
+ test_cflags = []
+ test_linkflags = []
+ test_libs = ['pthread', 'dl']
if bld.env.MSVC_COMPILER:
test_libs = []
if bld.is_defined('HAVE_GCOV'):
- test_libs += ['gcov']
- test_cflags += ['-fprofile-arcs', '-ftest-coverage']
+ test_cflags += ['--coverage']
+ test_linkflags += ['--coverage']
# Profiled static library (for unit test code coverage)
- obj = bld(features = 'c cstlib',
- source = lib_source,
- includes = ['.'],
- lib = test_libs,
- name = 'libzix_profiled',
- target = 'zix_profiled',
- install_path = '',
- framework = framework,
- cflags = test_cflags + ['-DZIX_INTERNAL'])
+ bld(features = 'c cstlib',
+ source = lib_source,
+ includes = ['.'],
+ lib = test_libs,
+ name = 'libzix_profiled',
+ target = 'zix_profiled',
+ install_path = '',
+ framework = framework,
+ cflags = test_cflags + ['-DZIX_INTERNAL'],
+ linkflags = test_linkflags)
# Unit test programs
for i in tests:
- obj = bld(features = 'c cprogram',
- source = ['test/%s.c' % i, 'test/test_malloc.c'],
- includes = ['.'],
- use = 'libzix_profiled',
- lib = test_libs,
- target = 'test/%s' % i,
- install_path = None,
- framework = framework,
- cflags = test_cflags)
+ bld(features = 'c cprogram',
+ source = ['test/%s.c' % i, 'test/test_malloc.c'],
+ includes = ['.'],
+ use = 'libzix_profiled',
+ lib = test_libs,
+ target = 'test/%s' % i,
+ install_path = None,
+ framework = framework,
+ cflags = test_cflags,
+ linkflags = test_linkflags)
if bld.env.BUILD_BENCH:
# Benchmark programs
for i in ['tree_bench', 'dict_bench']:
- obj = bld(features = 'c cprogram',
- source = 'test/%s.c' % i,
- includes = ['.'],
- use = 'libzix_static',
- uselib = 'GLIB',
- lib = ['rt'],
- target = 'test/%s' % i,
- framework = framework,
- install_path = '')
+ bld(features = 'c cprogram',
+ source = 'test/%s.c' % i,
+ includes = ['.'],
+ use = 'libzix_static',
+ uselib = 'GLIB',
+ lib = ['rt'],
+ target = 'test/%s' % i,
+ framework = framework,
+ install_path = '')
# Documentation
autowaf.build_dox(bld, 'ZIX', ZIX_VERSION, top, out)
@@ -200,7 +192,19 @@ def build(bld):
bld.add_post_fun(fix_docs)
def lint(ctx):
- subprocess.call('cpplint.py --filter=-whitespace/tab,-whitespace/braces,-build/header_guard,-readability/casting,-readability/todo zix/*', shell=True)
+ "checks code for style issues"
+ import subprocess
+
+ subprocess.call("flake8 --ignore E221,W504,E302,E305,E251 wscript",
+ shell=True)
+
+ cmd = ("clang-tidy -p=. -header-filter=.* -checks=\"*," +
+ "-hicpp-signed-bitwise," +
+ "-llvm-header-guard," +
+ "-misc-unused-parameters," +
+ "-readability-else-after-return\" " +
+ "../zix/*.c")
+ subprocess.call(cmd, cwd='build', shell=True)
def build_dir(ctx, subdir):
if autowaf.is_child():
@@ -213,7 +217,8 @@ def fix_docs(ctx):
autowaf.make_simple_dox(APPNAME)
def upload_docs(ctx):
- os.system('rsync -avz --delete -e ssh build/doc/html/* drobilla@drobilla.net:~/drobilla.net/docs/zix')
+ os.system('rsync -avz --delete -e ssh build/doc/html/*'
+ ' drobilla@drobilla.net:~/drobilla.net/docs/zix')
def test(ctx):
autowaf.pre_test(ctx, APPNAME)
@@ -240,11 +245,12 @@ def bench(ctx):
Logs.info('Generating random text %s' % filename)
import random
out = open(filename, 'w')
- for i in xrange(1 << 20):
+ for i in range(1 << 20):
wordlen = random.randrange(1, 64)
word = ''
- for j in xrange(wordlen):
- word += chr(random.randrange(ord('A'), min(ord('Z'), ord('A') + j + 1)))
+ for j in range(wordlen):
+ word += chr(random.randrange(ord('A'),
+ min(ord('Z'), ord('A') + j + 1)))
out.write(word + ' ')
out.close()