libcruft-util/meson.build

723 lines
16 KiB
Meson
Raw Normal View History

2019-02-22 12:41:19 +11:00
project('cruft', 'cpp')
pymod = import('python')
python = pymod.find_installation('python3')
ragel = generator(
find_program('ragel'),
output: '@BASENAME@.cpp',
arguments: [ '@INPUT@', '-o@OUTPUT@', '-G2' ]
)
2019-02-22 12:41:19 +11:00
if host_machine.endian() == 'big'
add_project_arguments('-DWORDS_BIGENDIAN')
endif
add_project_arguments('-std=c++2a', language: 'cpp')
add_project_link_arguments('-lstdc++fs', language: 'cpp')
2019-02-22 12:41:19 +11:00
add_project_arguments('-Drestrict=__restrict', language: 'cpp')
2019-02-22 12:41:19 +11:00
sources = [
ragel.process('uri.cpp.rl'),
ragel.process('version.cpp.rl'),
ragel.process('format.cpp.rl'),
ragel.process('time/parse8601.cpp.rl'),
]
dependencies = [
dependency('threads')
]
2019-02-22 12:41:19 +11:00
### Preemptively define an identity panic macro so that TCL doens't fuck us over
### by renaming a commonly used symbol.
add_project_arguments('-Dpanic=panic', language: 'cpp')
2019-02-22 12:41:19 +11:00
#################################################################################
cpp = meson.get_compiler('cpp')
execinfo = cpp.find_library('execinfo', required: false) # sym:backtrace
dbghelp = cpp.find_library('dbghelp', required: false) # sym:SymFromAddr
capture_stack_backtrace = cpp.has_function('RtlCaptureStackBackTrace')
if execinfo.found()
sources += 'backtrace_execinfo.cpp'
elif dbghelp.found()
sources += 'backtrace_stackwalk.cpp'
dependencies += dbghelp
else
sources += 'backtrace_null.cpp'
endif
sources += custom_target(
2019-02-22 12:41:19 +11:00
'preprocessor.hpp',
output: 'preprocessor.hpp',
input: 'preprocessor.py',
command: [python, '@INPUT@', '@OUTPUT@', '480'],
2019-02-22 12:41:19 +11:00
)
2019-02-22 12:41:19 +11:00
#################################################################################
### Platform wrappers
systems = {
'linux': 'linux',
'freebsd': 'freebsd',
'windows': 'win32'
}
# TODO: handle missing system
sources += 'exe_@0@.cpp'.format(systems[host_machine.system()])
sources += [
'posix/dir.cpp',
'posix/dir.hpp',
'posix/except.cpp',
'posix/except.hpp',
'posix/fd.cpp',
'posix/fd.hpp',
]
if host_machine.system() == 'linux'
sources += [
'thread/event_futex.cpp',
'thread/flag_futex.cpp',
]
endif
if host_machine.system() != 'windows'
sources += [
'buffer/circular.cpp',
'buffer/circular.hpp',
'buffer/paged.cpp',
'buffer/paged.hpp',
'memory/system.cpp',
'memory/system.hpp',
'debug_posix.cpp',
'io_posix.cpp',
'io_posix.hpp',
'library_posix.hpp',
'library_posix.cpp',
'posix/fwd.hpp',
'posix/map.cpp',
'posix/map.hpp',
'posix/socket.cpp',
'posix/socket.hpp',
'time_posix.cpp',
]
endif
####-----------------------------------------------------------------------------
if host_machine.system() == 'windows'
sources += [
'debug_win32.cpp',
'exe_win32.cpp',
'io_win32.cpp',
'io_win32.hpp',
'thread/event_win32.cpp',
'library_win32.cpp',
'library_win32.hpp',
'time_win32.cpp',
'win32/windows.hpp',
'win32/except.cpp',
'win32/except.hpp',
'win32/file.cpp',
'win32/file.hpp',
'win32/handle.cpp',
'win32/handle.hpp',
'win32/registry.cpp',
'win32/registry.hpp',
]
dependencies += cpp.find_library('ws2_32')
endif
2019-02-22 12:41:19 +11:00
sources += [
'thread/event.hpp',
'thread/semaphore.hpp',
'thread/flag.hpp',
]
if host_machine.system() == 'linux'
sources += [
'thread/event_futex.cpp',
'thread/event_futex.hpp',
'thread/semaphore_linux.hpp',
'thread/semaphore_linux.cpp',
'thread/flag_futex.cpp',
'thread/flag_futex.hpp',
]
elif host_name.system() == 'windows'
sources += [
'thread/event_std.cpp',
'thread/event_std.hpp',
'thread/semaphore_win32.hpp',
'thread/semaphore_win32.cpp',
'thread/flag_std.cpp',
'thread/flag_std.hpp',
]
2019-02-22 12:41:19 +11:00
else
error('Unknown platform for threading')
endif
if host_machine.cpu_family() == 'x86_64'
sources += [
'cpuid/x86.cpp',
'cpuid/x86.cpp',
]
else
warning('Unknown architecture @0@. Defaulting to null cpuid'.format(host_machine.cpu_family()))
sources += [
'cpuid/none.cpp',
'cpuid/none.hpp',
]
endif
if host_machine.system() == 'linux'
sources += [
'rand/system_linux.cpp',
'rand/system_linux.hpp',
]
elif host_machine.system() == 'windows'
sources += [
'rand/system_win32.cpp',
'rand/system_win32.hpp',
]
else
error('Unsupported system for rand')
endif
if host_machine.system() == 'linux'
sources += [ 'sysinfo_posix.cpp' ]
elif host_machine.system() == 'windows'
sources += [ 'sysinfo_win32.cpp' ]
else
error('Unsupported system for sysinfo')
endif
2019-02-22 12:41:19 +11:00
#################################################################################
### Common files
sources += [
'adapter.hpp',
'adapter.cpp',
'algo/search.hpp',
'algo/sort.cpp',
'algo/sort.hpp',
'alloc/fwd.hpp',
'alloc/affix.cpp',
'alloc/affix.hpp',
'alloc/aligned/direct.hpp',
'alloc/aligned/foreign.hpp',
'alloc/allocator.cpp',
'alloc/allocator.hpp',
'alloc/easy.hpp',
'alloc/fallback.cpp',
'alloc/fallback.hpp',
'alloc/linear.cpp',
'alloc/linear.hpp',
'alloc/malloc.cpp',
'alloc/malloc.hpp',
'alloc/null.cpp',
'alloc/null.hpp',
'alloc/stack.cpp',
'alloc/stack.hpp',
'alloc/std.hpp',
'alloc/traits.hpp',
'alloc/traits.hpp',
'annotation.hpp',
'array/darray.hpp',
'array/sarray.cpp',
'array/sarray.hpp',
'array/parray.cpp',
'array/parray.hpp',
'array/varray.hpp',
2019-02-22 12:41:19 +11:00
'ascii.hpp',
'backtrace.hpp',
'bezier.cpp',
'bezier1.cpp',
'bezier2.cpp',
'bezier3.cpp',
'bezier.hpp',
'bitwise.cpp',
'bitwise.hpp',
'buffer/simple.cpp',
'buffer/simple.hpp',
'buffer/traits.hpp',
'cast.hpp',
'cmdopt.cpp',
'cmdopt.hpp',
'colour.cpp',
'colour.hpp',
'coord.hpp',
2019-02-22 12:41:19 +11:00
'coord/fwd.hpp',
'coord/base.hpp',
'coord/comparator.hpp',
2019-02-22 12:41:19 +11:00
'coord/init.hpp',
'coord/iostream.hpp',
'coord/ops.hpp',
'coord/store.hpp',
'coord/traits.hpp',
'cpp.cpp',
'cpp.hpp',
'cpuid.cpp',
'cpuid.hpp',
'debug/assert.cpp',
'debug/assert.hpp',
'debug/compiler.cpp',
'debug/compiler.hpp',
'debug/debugger.cpp',
'debug/debugger.hpp',
'debug/panic.cpp',
'debug/panic.hpp',
'debug/system.cpp',
'debug/system.hpp',
'debug/validate.cpp',
'debug/validate.hpp',
2019-02-22 12:41:19 +11:00
'encode/number.hpp',
'encode/base.cpp',
'encode/base.hpp',
'endian.cpp',
'endian.hpp',
'except.cpp',
'except.hpp',
'exe.hpp',
'expected.hpp',
2019-02-22 12:41:19 +11:00
'extent.cpp',
'extent.hpp',
'fixed.cpp',
'fixed.hpp',
'float.cpp',
'float.hpp',
'format.hpp',
'fourcc.cpp',
'fourcc.hpp',
'functor.hpp',
'geom/fwd.hpp',
'geom/aabb.cpp',
'geom/aabb.hpp',
'geom/cylinder.cpp',
'geom/cylinder.hpp',
'geom/ellipse.cpp',
'geom/ellipse.hpp',
'geom/frustum.cpp',
'geom/frustum.hpp',
'geom/iostream.cpp',
'geom/iostream.hpp',
'geom/line.hpp',
'geom/line.cpp',
'geom/ops.cpp',
'geom/ops.hpp',
'geom/plane.cpp',
'geom/plane.hpp',
'geom/ray.cpp',
'geom/ray.hpp',
'geom/rect.cpp',
'geom/rect.hpp',
'geom/sample/fwd.hpp',
'geom/sample/surface.hpp',
'geom/sample/volume.hpp',
'geom/segment.cpp',
'geom/segment.hpp',
'geom/sphere.cpp',
'geom/sphere.hpp',
'geom/tri.cpp',
'geom/tri.hpp',
'hash.hpp',
'hash/fwd.hpp',
'hash/adler.cpp',
'hash/adler.hpp',
'hash/buzhash.hpp',
2019-02-22 12:41:19 +11:00
'hash/bsdsum.cpp',
'hash/bsdsum.hpp',
'hash/crc.cpp',
'hash/crc.hpp',
'hash/fasthash.cpp',
'hash/fasthash.hpp',
'hash/fletcher.cpp',
'hash/fletcher.hpp',
'hash/fnv1a.cpp',
'hash/fnv1a.hpp',
'hash/murmur/common.cpp',
'hash/murmur/common.hpp',
'hash/murmur.hpp',
'hash/murmur/murmur1.cpp',
'hash/murmur/murmur1.hpp',
'hash/murmur/murmur2.cpp',
'hash/murmur/murmur2.hpp',
'hash/murmur/murmur3.cpp',
'hash/murmur/murmur3.hpp',
'hash/siphash.cpp',
'hash/siphash.hpp',
'hash/table.cpp',
'hash/table.hpp',
2019-02-22 12:41:19 +11:00
'hash/wang.hpp',
'hash/xxhash.cpp',
'hash/xxhash.hpp',
'introspection.cpp',
'introspection.hpp',
'io.cpp',
'io.hpp',
'iterator/constant.hpp',
'iterator/counting.hpp',
'iterator/dereference.hpp',
'iterator/discard.hpp',
'iterator/indices.hpp',
'iterator/infix.hpp',
'iterator/iota.hpp',
'iterator/numeric.hpp',
'iterator/referencing.hpp',
'iterator/transform.hpp',
'iterator/unequal.hpp',
'iterator/zip.hpp',
2019-02-22 12:41:19 +11:00
'job/fwd.hpp',
'job/dispatch.hpp',
'job/queue.cpp',
'job/queue.hpp',
'kmeans.hpp',
'library.hpp',
'log.cpp',
'log.hpp',
'map/fixed.cpp',
'map/fixed.hpp',
2019-02-22 12:41:19 +11:00
'maths.cpp',
'maths.hpp',
'maths/fast.hpp',
'matrix.cpp',
'matrix2.cpp',
'matrix3.cpp',
'matrix4.cpp',
'matrix.hpp',
'memory/deleter.cpp',
'memory/deleter.hpp',
'parallel/queue.cpp',
'parallel/queue.hpp',
'parallel/stack.cpp',
'parallel/stack.hpp',
'parse/fwd.hpp',
'parse/enum.cpp',
'parse/enum.hpp',
'parse/time.cpp',
'parse/time.hpp',
'parse/value.cpp',
'parse/value.hpp',
'parse/si.cpp',
'parse/si.hpp',
2019-02-22 12:41:19 +11:00
'platform.hpp',
'point.cpp',
'point.hpp',
'pointer.hpp',
'polynomial.cpp',
'polynomial.hpp',
'pool.cpp',
'pool.hpp',
'quaternion.cpp',
'quaternion.hpp',
'rand/lcg.cpp',
'rand/lcg.hpp',
'rand/xorshift.cpp',
'rand/xorshift.hpp',
'rand/mwc64x.cpp',
'rand/mwc64x.hpp',
'rand/pcg.cpp',
'rand/pcg.hpp',
'rand/rdrand.cpp',
'rand/rdrand.hpp',
'rand/system.hpp',
2019-02-22 12:41:19 +11:00
'random.cpp',
'random.hpp',
'range.cpp',
'range.hpp',
'rational.cpp',
'rational.hpp',
'region.cpp',
'region.hpp',
'registrar.cpp',
'registrar.hpp',
2019-02-22 12:41:19 +11:00
'roots/bisection.hpp',
'scoped.hpp',
'signal.cpp',
'signal.hpp',
'singleton.hpp',
'stats.cpp',
'stats.hpp',
'std.hpp',
'stream.cpp',
'stream.hpp',
'string.cpp',
'string.hpp',
'stringid.cpp',
'stringid.hpp',
'strongdef.cpp',
'strongdef.hpp',
'sysinfo.hpp',
2019-02-22 12:41:19 +11:00
'tap.cpp',
'tap.hpp',
'term.cpp',
'term.hpp',
'thread/event.hpp',
'thread/flag.hpp',
'thread/monitor.cpp',
'thread/monitor.hpp',
'thread/ticketlock.cpp',
'thread/ticketlock.hpp',
'thread/spinlock.cpp',
'thread/spinlock.hpp',
'time.cpp',
'time.hpp',
'time/parse.hpp',
'tuple/index.hpp',
'tuple/type.hpp',
'tuple/value.hpp',
'typeidx.cpp',
'typeidx.hpp',
'types.hpp',
'types/bits.hpp',
'types/comparator.hpp',
'types/description.cpp',
'types/description.hpp',
'types/dispatch.hpp',
2019-02-22 12:41:19 +11:00
'types/string.cpp',
'types/string.hpp',
'types/tagged.hpp',
'types/traits.hpp',
'uri.hpp',
'utf8.cpp',
'utf8.hpp',
'variadic.cpp',
'variadic.hpp',
'vector.cpp',
'vector.hpp',
'version.hpp',
'view.cpp',
'view.hpp',
]
if get_option('simd')
sources += [
'coord/simd.cpp',
'coord/simd.hpp',
'coord/simd_sse.hpp',
'coord/simd_neon.hpp',
]
endif
2019-02-22 12:41:19 +11:00
#################################################################################
rt = cpp.find_library('rt', required: false)
if not cpp.has_function('shm_open', dependencies: [rt])
error('Cannot find shm library')
endif
dependencies += rt
dl = cpp.find_library('dl', required: false)
if not cpp.has_function('dlopen', dependencies: dl)
error ('Cannot find dl library')
endif
dependencies += dl
if not cpp.has_function('clock_gettime', dependencies: rt)
error('Cannot find clock_gettime library')
endif
m = cpp.find_library('m', required: false)
if not cpp.has_function('cos', dependencies: m)
error('Cannot find maths library')
endif
dependencies += m
libcruft = library('cruft', sources, dependencies: dependencies)
2019-06-22 08:19:42 +10:00
libcruft_dep = declare_dependency(
include_directories: include_directories('.'),
link_with: libcruft
)
2019-02-22 12:41:19 +11:00
#################################################################################
foreach tool: ['cpuid', 'poisson', 'macro', 'scratch']
executable(tool, 'tools/@0@.cpp'.format(tool), link_with: libcruft)
endforeach
2019-02-22 12:41:19 +11:00
#################################################################################
tests = [
'ascii',
'algo/search',
'algo/sort',
'alloc/aligned/foreign',
'alloc/aligned/direct',
'alloc/easy',
'alloc/linear',
'alloc/stack',
'affine',
'array/darray',
'array/sarray',
'array/parray',
'backtrace',
'bezier',
'bitwise',
'buffer/simple',
'cmdopt',
'colour',
'comparator',
'coord',
'encode/number',
'encode/base',
'endian',
'exe',
'expected',
'extent',
'fixed',
'float',
'format',
'geom/aabb',
'geom/ellipse',
'geom/frustum',
'geom/line',
'geom/plane',
'geom/ray',
'geom/segment',
'geom/sphere',
'hash/buzhash',
'hash/checksum',
'hash/crc',
'hash/fasthash',
'hash/fnv1a',
'hash/murmur',
'hash/siphash',
'hash/table',
'hash/xxhash',
'hton',
'io',
'introspection',
'iterator',
'job/dispatch',
'job/queue',
'kmeans',
'map/fixed',
'maths',
'maths/fast',
'matrix',
'memory/deleter',
'parallel/queue',
'parallel/stack',
'parse/enum',
'parse/value',
'parse/time',
'parse/si',
'point',
'polynomial',
'pool',
'preprocessor',
'quaternion',
'rand/buckets',
'random',
'range',
'rational',
'region',
'registrar',
'roots/bisection',
'scoped',
'signal',
'singleton',
'stream',
'string',
'stringid',
'strongdef',
'thread/event',
'thread/flag',
'thread/monitor',
'thread/semaphore',
'thread/spinlock',
'thread/ticketlock',
'time/8601',
'traits',
'tuple/index',
'tuple/value',
'tuple/type',
'typeidx',
'types/description',
'types/tagged',
'uri',
'utf8',
'vector',
'version',
'view',
]
if host_machine.system() != 'windows'
tests += [
'buffer/circular',
'buffer/paged',
]
endif
if get_option('simd')
tests += [
'coord/simd'
]
endif
foreach t: tests
test(
t.underscorify(),
executable(
'test_@0@'.format(t.underscorify()),
'test/@0@.cpp'.format(t),
link_with: libcruft,
dependencies: dependencies
),
protocol: 'tap'
)
endforeach
2019-02-22 12:41:19 +11:00
##
## configure_file (test/cpp.py.in util_test_cpp.py @ONLY)
## add_test (NAME util_test_cpp COMMAND ${PYTHON_EXECUTABLE} util_test_cpp.py)
## set_property (TEST util_test_cpp APPEND PROPERTY DEPENDS util_macro)
## set_tests_properties(util_test_cpp PROPERTIES FAIL_REGULAR_EXPRESSION "not ok -")
##endif ()
##
##
#################################################################################
cmake_config = configuration_data()
pkg = import('pkgconfig')
pkg.generate(
libraries: dependencies,
version: meson.project_version(),
name: meson.project_name(),
filebase: 'cruft',
description: 'A simple utility library for C++'
)
configure_file(
input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: {
'CMAKE_PROJECT_NAME': meson.project_name(),
'CMAKE_PROJECT_VERSION': meson.project_version(),
'CMAKE_CURRENT_SOURCE_DIR': meson.current_source_dir(),
'CMAKE_CURRENT_BINARY_DIR': meson.current_build_dir(),
}
)