90 lines
2 KiB
Meson
90 lines
2 KiB
Meson
project('bubel-ecs', 'd', version : '0.5.0')
|
|
|
|
# Options
|
|
betterC_opt = get_option('betterC')
|
|
BuildDemos_opt = get_option('BuildDemos')
|
|
BuildTests_opt = get_option('BuildTests')
|
|
LTO_otp = get_option('LTO')
|
|
|
|
summary('betterC enabled', betterC_opt)
|
|
summary('build demos', BuildDemos_opt)
|
|
summary('build tests', BuildTests_opt)
|
|
summary('LTO enabled', LTO_otp)
|
|
|
|
meson_minimum_version = '>=0.57.1'
|
|
assert(meson.version().version_compare(meson_minimum_version), 'Newer verson of meson required, current version: @0@, required: @1@'.format(meson.version(), meson_minimum_version))
|
|
|
|
# Files
|
|
src = files()
|
|
subdir('source')
|
|
|
|
inc = include_directories('source/')
|
|
|
|
# Arguments
|
|
args = []
|
|
link_args = []
|
|
|
|
comp = meson.get_compiler('d')
|
|
comp_id = comp.get_id()
|
|
|
|
if LTO_otp
|
|
if comp_id == 'gcc'
|
|
args += '-flto'
|
|
link_args += '-flto'
|
|
elif comp_id == 'llvm'
|
|
args += '-flto=thin'
|
|
link_args += '-flto=thin'
|
|
else
|
|
assert(false, 'Compiler "@0@" doesn\'t support LTO'.format(comp_id))
|
|
endif
|
|
endif
|
|
|
|
if betterC_opt
|
|
if comp_id == 'gcc'
|
|
args += ['-fno-druntime']
|
|
link_args += ['-fno-druntime']
|
|
else
|
|
args += '-betterC'
|
|
link_args += '-betterC'
|
|
endif
|
|
endif
|
|
|
|
add_project_arguments(args, language : 'd')
|
|
add_project_link_arguments(link_args, language : 'd')
|
|
|
|
# Dependencies
|
|
threads_dep = dependency('threads')
|
|
|
|
d_versions = []
|
|
deps = []
|
|
if host_machine.cpu_family() == 'wasm32'
|
|
d_versions += 'ECSEmscripten'
|
|
else
|
|
# meson incorectly adds "-s USE_PTHREADS=1" to ldc2 invocation whe pthreads is added as dependency
|
|
# add it for non wasm builds
|
|
deps += threads_dep
|
|
endif
|
|
|
|
ecs_lib = library('BubelECS',
|
|
src,
|
|
d_module_versions : d_versions,
|
|
include_directories : [inc],
|
|
)
|
|
|
|
bubel_ecs_dep = declare_dependency(
|
|
include_directories : [inc],
|
|
link_with : ecs_lib,
|
|
dependencies : deps,
|
|
)
|
|
|
|
meson.override_dependency('bubel-ecs', bubel_ecs_dep)
|
|
|
|
# Tests
|
|
if BuildTests_opt
|
|
subdir('tests')
|
|
endif
|
|
|
|
# Demos
|
|
if BuildDemos_opt
|
|
subdir('demos')
|
|
endif
|