-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
65 lines (58 loc) · 1.66 KB
/
SConstruct
File metadata and controls
65 lines (58 loc) · 1.66 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
import os
import pdb
debug = False
pybind11 = True
cwd = os.getcwd()
srcDir = os.path.join(cwd, 'src')
headerDir = os.path.join(cwd, 'include')
pyHeaderDir = '/home/exarkun/anaconda3/include/python3.8'
pybind11HeaderDir = '/home/exarkun/anaconda3/lib/python3.8/site-packages/pybind11/include'
binDir = os.path.join(cwd, 'bin')
if not os.path.isdir(binDir):
os.mkdir(binDir)
libDir = os.path.join(cwd, 'lib')
if not os.path.isdir(libDir):
os.mkdir(libDir)
initFile = os.path.join(libDir, '__init__.py')
if not os.path.isfile(initFile):
with open(initFile, 'w') as initFile:
pass
headers = ['%s'%(headerDir)]
if pybind11:
headers += [pyHeaderDir, pybind11HeaderDir]
cc = 'gcc-11'
cxx = 'g++-11'
ccflags = ['-std=c++20', '-Wall']
if debug:
ccflags += ['-g','-O0']
else:
ccflags += ['-O3']
if pybind11:
ccflags += ['-shared', '-fPIC']
ActionStr = '%s'%(cxx)
for flag in ccflags:
ActionStr += ' %s'%(flag)
for header in headers:
ActionStr += ' -I%s'%(header)
ActionStr += ' $SOURCE'
ActionStr += ' -o $TARGET'
libName = 'chartmaster'
libFile = os.path.join(srcDir, libName)
libOut = os.path.join(libDir, libName)
execName = 'radec'
execFile = os.path.join(srcDir, execName + '.cpp')
execOut = os.path.join(binDir, execName)
env = Environment(ENV = os.environ, CPPPATH = [cwd])
env.Replace(CC = "gcc-11")
env.Replace(CXX = "g++-11")
env.Append(CCFLAGS=ccflags)
env.Repository(headerDir, pyHeaderDir, pybind11HeaderDir)
env.Program(execOut, execFile)
pyExtEnv = Environment(ENV = os.environ, CPPPATH = [cwd])
PyExt = Builder(
action=ActionStr,
suffix='.cpython-38-x86_64-linux-gnu.so',
src_suffix='.cpp',
)
pyExtEnv.Append(BUILDERS={'PyExt': PyExt})
pyExtEnv.PyExt(libOut, libFile)