forked from radareorg/sdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
137 lines (125 loc) · 3.04 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
project('sdb', 'c', meson_version: '>=0.47.0')
py3_exe = import('python').find_installation('python3')
pkgconfig_mod = import('pkgconfig')
version_cmd = '''from sys import argv
with open(argv[1]) as fd:
for line in fd:
if line.startswith('SDBVER='):
version_tuple = line.split('=')[1]
print(version_tuple)
break
'''
sdb_version = '0.0.1'
config_mk = files('config.mk')[0]
r = run_command(py3_exe, '-c', version_cmd, config_mk)
if r.returncode() == 0
sdb_version = r.stdout().strip()
else
warning('Cannot determine SDB version')
endif
message('SDB version = ' + sdb_version)
sdb_libversion = host_machine.system() == 'windows' ? '' : sdb_version
sdb_platform_inc = []
if host_machine.system() == 'windows'
sdb_platform_inc = include_directories('msvc')
endif
# Create sdb_version.h
conf_data = configuration_data()
conf_data.set_quoted('SDB_VERSION', sdb_version, description : 'From config.mk')
configure_file(
output : 'sdb_version.h',
configuration : conf_data,
install_dir : join_paths(get_option('includedir'), 'sdb')
)
libsdb_sources = [
'src/array.c',
'src/base64.c',
'src/buffer.c',
'src/cdb.c',
'src/cdb_make.c',
'src/dict.c',
'src/disk.c',
'src/fmt.c',
'src/ht_uu.c',
'src/ht_pp.c',
'src/ht_up.c',
'src/journal.c',
'src/json.c',
#'src/json/api.c',
#'src/json/indent.c',
#'src/json/js0n.c',
#'src/json/path.c',
#'src/json/rangstr.c',
'src/lock.c',
'src/ls.c',
'src/match.c',
'src/ns.c',
'src/num.c',
'src/query.c',
'src/sdb.c',
'src/sdbht.c',
'src/util.c',
]
sdb_inc = [
sdb_platform_inc,
include_directories(['.', 'src'])
]
libsdb = both_libraries('sdb', libsdb_sources,
include_directories: sdb_inc,
implicit_include_directories: false,
soversion: sdb_libversion,
install: not meson.is_subproject()
)
if meson.is_subproject()
sdb_dep = declare_dependency(
link_with: libsdb.get_static_lib(),
include_directories: sdb_inc
)
else
include_files = [
'src/buffer.h',
'src/cdb.h',
'src/cdb_make.h',
'src/config.h',
'src/dict.h',
'src/ht_inc.h',
'src/ht_pp.h',
'src/ht_up.h',
'src/ht_uu.h',
'src/ls.h',
'src/sdb.h',
'src/sdbht.h',
'src/types.h'
]
install_headers(include_files, subdir: 'sdb')
endif
if host_machine.system() == 'windows'
link_with = libsdb.get_static_lib()
else
link_with = libsdb.get_shared_lib()
endif
sdb_exe = executable('sdb', 'src/main.c',
include_directories: sdb_inc,
link_with: [link_with],
install: not meson.is_subproject(),
implicit_include_directories: false
)
if not meson.is_subproject()
install_man(['src/sdb.1'])
endif
pkgconfig_mod.generate(
name: 'sdb',
filebase: 'sdb',
libraries: [libsdb.get_shared_lib()],
description: 'Simple DataBase',
subdirs: ['sdb', '.'],
version: sdb_version,
url: 'https://github.com/radare/sdb'
)
make_test_executable = find_program('make')
test('run tests', make_test_executable,
args: 'test',
env: ['BASEDIR=' + meson.current_build_dir()],
workdir: join_paths(meson.current_build_dir(), '..'),
depends: [sdb_exe, libsdb]
)