-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
meson.build
161 lines (143 loc) · 4.18 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
project('rz-bindgen', 'c', 'cpp',
version: '0.6.0',
license: 'LGPL3',
meson_version: '>=0.62.2',
default_options: ['python.install_env=auto'])
pymod = import('python')
fs = import('fs')
py = pymod.find_installation()
clang_path = get_option('clang_path')
clang_args = get_option('clang_args')
rizin_include_path = get_option('rizin_include_path')
targets = get_option('targets')
target_swig = targets.contains('SWIG')
target_sphinx = targets.contains('sphinx')
doxygen_path = get_option('doxygen_path')
if clang_path == ''
llvm_config = find_program('llvm-config', 'llvm-config-7', required: false)
if llvm_config.found()
clang_path = run_command(llvm_config, '--libdir', check: true).stdout().strip()
elif build_machine.system() == 'darwin'
clang_path = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/'
elif build_machine.system() == 'windows'
clang_path = import('fs').parent(find_program('clang.exe').full_path())
else
clang_path = '/usr/lib/'
endif
endif
if not fs.exists(clang_path)
error('CLang path does not exist')
endif
rz_core = disabler()
if rizin_include_path == ''
rz_core = dependency('rz_core')
if rz_core.type_name() == 'pkgconfig'
rizin_include_path = rz_core.get_variable(pkgconfig: 'includedir') / 'librz'
elif rz_core.type_name() == 'cmake'
rizin_include_path = rz_core.get_variable(cmake: 'PACKAGE_INCLUDE_DIRS').split(';')[0]
endif
endif
if clang_args == ''
clang = find_program('clang', 'clang-7', required: false)
if clang.found()
clang_args += ' -resource-dir='
clang_args += '"' + run_command(clang, '-print-resource-dir', check: true).stdout().strip() + '"'
endif
if build_machine.system() == 'darwin'
clang_args += ' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
endif
endif
bindgen_output_names = []
if target_swig
swig_source_idx = bindgen_output_names.length()
bindgen_output_names += ['rizin.i']
endif
if target_sphinx
sphinx_dir_idx = bindgen_output_names.length()
bindgen_output_names += ['sphinx']
endif
summary({
'Rizin include path': rizin_include_path,
'Clang path': clang_path,
})
if target_swig or target_sphinx
src_files = files(
'src/binding_class.py',
'src/binding_director.py',
'src/binding_enum.py',
'src/binding_func.py',
'src/binding_generic.py',
'src/binding_generic_specializations.py',
'src/binding_typemap.py',
'src/bindings.py',
'src/cparser_header.py',
'src/cparser_types.py',
'src/generator_sphinx.py',
'src/generator_swig.py',
'src/lint.py',
'src/main.py',
'src/writer.py',
)
bindgen_outputs = custom_target(
'bindgen_outputs',
input: 'src' / 'main.py',
output: bindgen_output_names,
depend_files: src_files,
command: [
py, '@INPUT@',
'-o', '@OUTDIR@',
'--clang-path', clang_path,
'--clang-args', clang_args,
'--rizin-include-path', rizin_include_path,
'--targets', ','.join(targets)
] + (doxygen_path != '' ? ['--doxygen-path', doxygen_path] : [])
)
endif
if target_swig
wheel = get_option('wheel')
swig_output = custom_target(
'swig_output',
input: bindgen_outputs[swig_source_idx],
output: ['rizin.py', 'rizin_wrap.cxx'],
command: [
find_program('swig'),
'-python', '-c++',
'-outdir', '@OUTDIR@', '@INPUT@'
],
install: wheel or host_machine.system() == 'windows',
install_dir: [py.get_install_dir(), false]
)
swig_py = swig_output[0]
swig_wrap = swig_output[1]
if not rz_core.found()
rz_core = dependency('rz_core')
endif
ext_mod = py.extension_module(
'_rizin',
swig_wrap,
dependencies: [
py.dependency(),
rz_core,
],
install: wheel or host_machine.system() == 'windows',
)
if host_machine.system() != 'windows'
meson.add_install_script('py_install.py', swig_py.full_path(), ext_mod.full_path())
endif
endif
if target_sphinx
custom_target(
'sphinx',
input: bindgen_outputs[sphinx_dir_idx],
output: 'sphinx_output',
command: [
find_program('sphinx-build'),
'@INPUT@',
'@OUTPUT@'
],
build_by_default: true
)
endif
if get_option('plugin').enabled()
subdir('plugin')
endif