-
Notifications
You must be signed in to change notification settings - Fork 9
/
meson.build
90 lines (75 loc) · 2.38 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
project('io', 'd', default_options: ['optimization=3'], version: '0.3.2', license: 'BSL-1.0' )
common_project_arguments = ['-release'] #, '--d-debug'
add_project_arguments(common_project_arguments, language: 'd')
# semver
version = meson.project_version().split('.')
major_version = version[0].to_int()
minor_version = version[1].to_int()
micro_version = version[2].to_int()
# base
dc = meson.get_compiler('d')
# Source files
sources = [ 'src/std/io/driver/package.d',
'src/std/io/driver/sync.d',
'src/std/io/exception.d',
'src/std/io/file.d',
'src/std/io/internal/iovec.d',
'src/std/io/internal/string.d',
'src/std/io/net/addr.d',
'src/std/io/net/dns.d',
'src/std/io/net/package.d',
'src/std/io/net/socket.d',
'src/std/io/net/tcp.d',
'src/std/io/net/udp.d',
'src/std/io/package.d'
]
inc_dir = include_directories('src/')
# Compiler and linker flags
common_dflags = []
common_ldflags = []
# library
if host_machine.system() == 'linux'
common_ldflags += [ '-Wl,-z,relro', '-Wl,-z,now' ]
endif
lib_type = get_option('default_library')
if lib_type == 'shared'
libio_soname = 'lib@[email protected].@1@'.format(meson.project_name(), major_version)
common_ldflags += ['-shared' ]
if dc.get_id() == 'llvm'
common_ldflags += [ '-soname', libio_soname ]
endif
endif
io_lib = library(meson.project_name(),
sources,
include_directories: inc_dir,
link_args : common_ldflags,
install: true,
version: meson.project_version(),
d_unittest: false
)
io_dep = declare_dependency(
link_with: [io_lib],
include_directories: inc_dir,
dependencies: [],
)
if get_option('run_test')
configure_file(input: 'LICENSE.txt', output:'LICENSE.txt', copy: true)
io_test_exe = executable(meson.project_name() + '-test',
sources, include_directories: inc_dir,
d_unittest: true,
link_args: ['-main'],
d_args: ['-cov']
)
test(meson.project_name() + '-test', io_test_exe)
endif
# Compat variables for pkgconfig
pkg = import('pkgconfig')
pkg.generate(io_lib,
description: 'Core I/O functionality.',
subdirs: 'd/' + meson.project_name(),
url: 'https://github.com/MartinNowak/io'
)
install_subdir('src/',
strip_directory : true,
install_dir: 'include/d/' + meson.project_name(),
)