-
Notifications
You must be signed in to change notification settings - Fork 6
/
common.scons
85 lines (71 loc) · 2.54 KB
/
common.scons
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
import os
import sys
import re
Import('env')
def SWIGSharedLibrary(env, library, sources, **args):
swigre = re.compile('(.*).i')
if env.WhereIs('swig') is None:
sourcesbis = []
for source in sources:
cName = swigre.sub(r'\1_wrap.c', source)
cppName = swigre.sub(r'\1_wrap.cc', source)
if os.path.exists(cName):
sourcesbis.append(cName)
elif os.path.exists(cppName):
sourcesbis.append(cppName)
else:
sourcesbis.append(source)
else:
sourcesbis = sources
if 'SWIGFLAGS' in args:
args['SWIGFLAGS'] += ['-python']
else:
args['SWIGFLAGS'] = ['-python'] + env['SWIGFLAGS']
args['SHLIBPREFIX']=""
if sys.platform[:3] == "win":
if sys.version >= '2.5':
args['SHLIBSUFFIX']=".pyd"
cat=env.SharedLibrary(library, sourcesbis, **args)
return cat
env['BUILDERS']['PythonModule'] = SWIGSharedLibrary
if env['optimized']:
env.Append(CFLAGS='-DNDEBUG')
env.Append(CPPDEFINES=['NDEBUG', ])
def AddProgram(env, name, sources, CFLAGS=[], CCFLAGS=[], CXXFLAGS=[], CPPDEFINES=[], CPATH=[], LIBPATH=[], LIBS=[], **kwargs):
return env.Program(name, sources,
CFLAGS = CFLAGS + env['CFLAGS'],
CCFLAGS = CCFLAGS + env['CCFLAGS'],
CXXFLAGS = CXXFLAGS + env['CXXFLAGS'],
CPPDEFINES = CPPDEFINES + env['CPPDEFINES'],
CPATH = CPATH + env['CPATH'],
CPPPATH = CPPPATH + env['CPPPATH'],
LIBPATH = LIBPATH + env['LIBPATH'],
**kwargs
)
env['BUILDERS']['AddProgram'] = AddProgram
def AddSharedLibrary(env, name, sources, CFLAGS=[], CCFLAGS=[], CXXFLAGS=[], CPPDEFINES=[], CPATH=[], LIBPATH=[], LIBS=[], **kwargs):
return env.SharedLibrary(name, sources,
CFLAGS = CFLAGS + env['CFLAGS'],
CCFLAGS = CCFLAGS + env['CCFLAGS'],
CXXFLAGS = CXXFLAGS + env['CXXFLAGS'],
CPPDEFINES = CPPDEFINES + env['CPPDEFINES'],
CPATH = CPATH + env['CPATH'],
CPPPATH = CPPPATH + env['CPPPATH'],
LIBPATH = LIBPATH + env['LIBPATH'],
**kwargs
)
env['BUILDERS']['AddSharedLibrary'] = AddSharedLibrary
def AddStaticLibrary(env, name, sources, CFLAGS=[], CCFLAGS=[], CXXFLAGS=[], CPPDEFINES=[], CPATH=[], LIBPATH=[], LIBS=[], **kwargs):
return env.StaticLibrary(name, sources,
CFLAGS = CFLAGS + env['CFLAGS'],
CCFLAGS = CCFLAGS + env['CCFLAGS'],
CXXFLAGS = CXXFLAGS + env['CXXFLAGS'],
CPPDEFINES = CPPDEFINES + env['CPPDEFINES'],
CPATH = CPATH + env['CPATH'],
CPPPATH = CPPPATH + env['CPPPATH'],
LIBPATH = LIBPATH + env['LIBPATH'],
**kwargs
)
env['BUILDERS']['AddStaticLibrary'] = AddStaticLibrary
Export('env')
Return('env')