Repository navigation
Expand file tree
/
Copy pathSConstruct
More file actions
64 lines (56 loc) · 1.62 KB
/
Copy pathSConstruct
File metadata and controls
64 lines (56 loc) · 1.62 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
import os
import platform
import subprocess
import sysconfig
import nanobind
import eigen
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
common = ''
python_path = sysconfig.get_paths()['include']
cpppath = [
'#',
'#rednose',
'#rednose/examples/generated',
'/usr/lib/include',
python_path,
eigen.INCLUDE_DIR,
]
env = Environment(
ENV=os.environ,
CCFLAGS=[
"-g",
"-fPIC",
"-O2",
"-Werror=implicit-function-declaration",
"-Werror=incompatible-pointer-types",
"-Werror=int-conversion",
"-Werror=return-type",
"-Werror=format-extra-args",
"-Wshadow",
],
LIBPATH=["#rednose/examples/generated"],
CFLAGS="-std=gnu11",
CXXFLAGS="-std=c++1z",
CPPPATH=cpppath,
REDNOSE_ROOT=Dir("#").abspath,
tools=["default", "rednose_filter"],
)
# Python extension build environment
envNanobind = env.Clone()
nanobind_dir = os.path.dirname(nanobind.__file__)
envNanobind.Append(
CPPPATH=[os.path.join(eigen.INCLUDE_DIR, "eigen3"), nanobind.include_dir(), os.path.join(nanobind_dir, "ext", "robin_map", "include")],
CCFLAGS=["-fvisibility=hidden", "-Wno-shadow"],
)
envNanobind["NANOBIND_SOURCE"] = os.path.join(nanobind_dir, "src", "nb_combined.cpp")
envNanobind["LIBS"] = []
if platform.system() == "Darwin":
envNanobind["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"]
elif arch == "aarch64":
envNanobind["LINKFLAGS"] = ["-shared"]
envNanobind["LIBS"] = [os.path.basename(python_path)]
else:
envNanobind["LINKFLAGS"] = ["-pthread", "-shared"]
Export('env', 'envNanobind', 'common')
SConscript(['#rednose/SConscript'])
SConscript(['#examples/SConscript'])