forked from piqueserver/piqueserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
91 lines (73 loc) · 2.53 KB
/
Copy pathsetup.py
File metadata and controls
91 lines (73 loc) · 2.53 KB
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
import os
from typing import Dict, List, NamedTuple
from setuptools import setup, Extension, find_packages
from Cython.Build import cythonize
from Cython.Compiler import Options
class Descriptor(NamedTuple):
extension_name: str
sources: List[str]
compile_flags: List[str] = []
link_flags: List[str] = []
macros: Dict[str, str] = {}
use_static = (os.environ.get('STDCPP_STATIC') == '1')
use_asan = (os.environ.get('USE_ASAN') == '1')
use_ubsan = (os.environ.get('USE_UBSAN') == '1')
use_linetrace = (os.environ.get('CYTHON_TRACE') == '1')
compile_flags: List[str] = []
link_flags: List[str] = []
macros: Dict[str, str] = {}
if use_static:
link_flags += ['-static-libstdc++', '-static-libgcc']
# Compile the server with AddressSanitizer
if use_asan:
link_flags += ['-lasan']
compile_flags += ['-fsanitize=address']
# Compile the server with UndefinedBehaviourSanitizer
if use_ubsan:
link_flags += ['-lubsan']
compile_flags += ['-fsanitize=undefined']
if use_linetrace:
macros['CYTHON_TRACE'] = '1'
Options.generate_cleanup_code = True
extension_descriptors = [
Descriptor('pyspades.world',
sources=['pyspades/world.pyx'],
compile_flags=['-std=c++11']),
Descriptor('pyspades.mapmaker',
sources=['pyspades/mapmaker.pyx'],
compile_flags=['-std=c++11']),
Descriptor('pyspades.bytes',
sources=['pyspades/bytes.pyx']),
Descriptor('pyspades.common',
sources=['pyspades/common.pyx']),
Descriptor('pyspades.contained',
sources=['pyspades/contained.pyx']),
Descriptor('pyspades.loaders',
sources=['pyspades/loaders.pyx']),
Descriptor('pyspades.packet',
sources=['pyspades/packet.pyx']),
Descriptor('pyspades.vxl',
sources=['pyspades/vxl.pyx']),
]
extensions: List[Extension] = []
for descriptor in extension_descriptors:
extension = Extension(
name=descriptor.extension_name,
sources=descriptor.sources,
language='c++',
include_dirs=['pyspades/'],
define_macros=list({**macros, **descriptor.macros}.items()),
extra_link_args=[*link_flags, *descriptor.link_flags],
extra_compile_args=[*compile_flags, *descriptor.compile_flags],
)
extensions += [extension]
setup(
packages=find_packages(exclude=('tests', 'tests.*')),
ext_modules=cythonize(
extensions,
compiler_directives={
'language_level': 3,
'embedsignature': True,
}
),
)