-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
71 lines (60 loc) · 1.71 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
project(
'bencode2',
'cpp',
default_options: [
'cpp_std=c++17',
'buildtype=release',
'debug=false',
],
meson_version: '>= 1.3.0',
)
py_inter = import('python').find_installation()
PURE_PY = run_command(
py_inter,
'-c', 'import os; print(os.environ.get("PY_BENCODE2_PURE_PYTHON", "0"))',
check: true,
).stdout().strip()
PY_IMPL = run_command(
py_inter,
'-c', 'import sys; print(sys.implementation.name)',
check: true,
).stdout().strip()
pure_py = not ((PURE_PY != '1') and (PY_IMPL == 'cpython'))
py = import('python').find_installation(pure: pure_py)
py.install_sources(
'src/bencode2/__init__.py',
'src/bencode2/__init__.pyi',
'src/bencode2/__encoder.py',
'src/bencode2/__decoder.py',
'src/bencode2/py.typed',
subdir: 'bencode2',
)
if not pure_py
fs = import('fs')
pybind11_path = run_command(
py,
'-c', 'import pybind11; print(pybind11.get_include());',
check: true,
).stdout().strip()
pybind11_includes = fs.relative_to(pybind11_path, meson.current_source_dir())
if get_option('buildtype').startswith('debug')
add_project_arguments('-DBENCODE_CPP_DEBUG', language: 'cpp')
endif
add_global_arguments('-DFMT_HEADER_ONLY', language: 'cpp')
incdir = include_directories(
[
pybind11_includes,
'./vendor/fmt/include',
'./vendor/portable-snippets/',
'./vendor/small_vector/source/include',
],
)
py.extension_module(
'__bencode',
'src/bencode2/bencode.cpp',
install: true,
include_directories: incdir,
subdir: 'bencode2',
dependencies: py.dependency(),
)
endif