-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConstruct
73 lines (59 loc) · 2.61 KB
/
SConstruct
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
import glob
import os
import pipes
import subprocess
import shlex
import sys
# colorize output
colors = {
'cyan' : '\033[96m',
'purple' : '\033[95m',
'blue' : '\033[94m',
'green' : '\033[92m',
'yellow' : '\033[93m',
'red' : '\033[91m',
'end' : '\033[0m'
}
if not sys.stdout.isatty():
for key, value in colors.iteritems():
colors[key] = ''
# construct environment
env = Environment(
#CXXCOMSTR='%scxx: $SOURCE -> $TARGET%s' % (colors['green'], colors['end']),
CCCOMSTR='%scc: $SOURCE -> $TARGET%s' % (colors['green'], colors['end']),
#SHCXXCOMSTR='%scxx: $SOURCE -> $TARGET%s' % (colors['green'], colors['end']),
SHCCCOMSTR='%scc: $SOURCE -> $TARGET%s' % (colors['green'], colors['end']),
LINKCOMSTR='%sld: $TARGET%s' % (colors['yellow'], colors['end']),
SHLINKCOMSTR='%sld: $TARGET%s' % (colors['yellow'], colors['end']),
#tools=["default"],
ENV = {'PATH' : os.environ['PATH'],
'TERM' : os.environ['TERM']}
)
# check environ
#if 'CXX' in os.environ:
env['CXX'] = 'clang++'
#print("%sconfigure: using CXX: %s%s" % (colors['blue'], os.environ['CXX'], colors['end']))
if 'CXXFLAGS' in os.environ:
env.Append(CXXFLAGS=os.environ['CXXFLAGS'])
print("%sconfigure: using CXXFLAGS: %s%s" % (colors['blue'], os.environ['CXXFLAGS'], colors['end']))
if 'LDFLAGS' in os.environ:
env.Append(LINKFLAGS=os.environ['LDFLAGS'])
print("%sconfigure: using LDFLAGS: %s%s" % (colors['blue'], os.environ['LDFLAGS'], colors['end']))
def _mapnik_config(*args):
(output, _) = subprocess.Popen(('mapnik-config',) + args, stdout=subprocess.PIPE).communicate()
return shlex.split(output.strip())
# configure
mapnik_cflags = _mapnik_config('--cflags')
mapnik_ldflags = _mapnik_config('--libs', '--ldflags', '--dep-libs')
(plugin_path,) = _mapnik_config('--input-plugins')
# hacky fix for boost library suffixes
boost_libs = [x for x in _mapnik_config('--dep-libs') if x.find("-lboost_") != -1 ]
boost_suff = ""
if boost_libs[0].rfind("-") > 0:
boost_suff = "-"+boost_libs[0].split("-")[-1]
env.Append(CPPPATH=[ 'include', 'agg/include' ])
env.Append(CXXFLAGS=mapnik_cflags + [ '-Wno-deprecated-declarations', '-DMAPNIKDIR="\\"{0}\\""'.format(pipes.quote(plugin_path)) ])# + [ '-Wall', '-pedantic', '-Wfatal-errors', '-Werror', '-Wno-unused-but-set-variable', '-Wno-format' ])
env.Append(LINKFLAGS=mapnik_ldflags + [ '-lboost_program_options'+boost_suff ])
objects = env.Object(source=[ fn for fn in glob.glob('src/*.cpp') + glob.glob('src/**/*.cpp') if fn != 'src/xml2carto.cpp' ])
env.Program(target='xml2carto',
source=objects + [ 'src/xml2carto.cpp' ])