-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathmeson.build
81 lines (74 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
# This file is part of xtb.
#
# Copyright (C) 2020 Sebastian Ehlert
#
# xtb is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# xtb is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with xtb. If not, see <https://www.gnu.org/licenses/>.
project(
'xtb-python',
'c',
version: '0.1',
license: 'LGPL3',
)
cc = meson.get_compiler('c')
# Import xtb as subproject, we need the API of version 6.3 or newer,
# also we disable the internal ctypes Python API of xtb since we provide our own
# and force xtb to provide a _static_ library to avoid depending on xtb at runtime
xtb_prj = subproject(
'xtb',
version: '>=6.3',
default_options: [
'default_library=static',
'python=false',
'static=false',
'openmp=@0@'.format(get_option('openmp')),
'la_backend=@0@'.format(get_option('la_backend')),
],
)
xtb_dep = xtb_prj.get_variable('xtb_dep')
xtb_header = xtb_prj.get_variable('xtb_header')
pymod = import('python')
python = pymod.find_installation(
'python@0@'.format(get_option('py')),
modules: [
'cffi',
'numpy',
],
)
python_dep = python.dependency(required: true)
# Python's CFFI is horrible in working with preprocessor statements,
# therefore, we have to preprocess the header before passing it to the ffibuilder
xtb_pp = configure_file(
command: [cc, '-E', '@INPUT@'],
input: xtb_header,
output: '_libxtb.h',
capture: true,
)
# This is the actual out-of-line API processing of the ffibuilder
xtb_cffi_srcs = configure_file(
command: [python, files('ffibuilder.py'), '@INPUT@', '@BASENAME@'],
input: xtb_pp,
output: '@[email protected]',
)
# Actual generation of the Python extension, since the shared_module does not work
# well with dependency objects, we will trick it by linking a whole static lib
xtb_pyext = python.extension_module(
'_libxtb',
link_whole: static_library(
'_libxtb',
xtb_cffi_srcs,
dependencies: [xtb_dep, python_dep],
),
dependencies: [xtb_dep, python_dep],
install: true,
)