-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
64 lines (55 loc) · 1.7 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
import os
import platform
env = DefaultEnvironment()
debug = ARGUMENTS.get('debug', 0)
release = ARGUMENTS.get('release', 0)
if int(release) == 1:
env['objroot'] = env.Dir('build/release').abspath
env['DEBUG'] = False
src_env.Append(CCFLAGS=' -g -O -DNDEBUG')
else:
env['objroot'] = env.Dir('build/debug').abspath
env['DEBUG'] = True
env.Append(CCFLAGS=' -g -Wall -Werror')
env['srcroot'] = env.Dir('.').abspath
objroot = env['objroot']
srcroot = env['srcroot']
env.Append(CPPPATH=[env['objroot'], env['srcroot']])
Export('env')
deps_libs = ['pthread', 'protobuf', 'zmq']
def CheckDependencies():
global env
conf = Configure(env)
for lib in deps_libs:
if not conf.CheckLib(lib):
print 'Did not find lib' + lib + ' existing'
Exit(1)
env = conf.Finish()
CheckDependencies()
def ProtoEmitter(target, source, env):
ret_source = []
ret_target = []
for s in source:
s_abspath = s.abspath
target_prefix = s_abspath[:s_abspath.find('.proto')]
ret_target += [
target_prefix + ".pb.cc",
target_prefix + ".pb.h"
]
output = s_abspath.replace(env.Dir('$objroot').abspath,
env.Dir('$srcroot').abspath)
ret_source += [output]
return ret_target, ret_source
def ProtoGenerator(target, source, env, for_signature):
action = "protoc " + "--proto_path=$srcroot " + \
"--cpp_out=$objroot "
for s in source:
action += s.abspath + " "
return action
proto_builder = Builder(generator = ProtoGenerator,
emitter=ProtoEmitter)
env['BUILDERS']['ProtocolBuffer'] = proto_builder
subdir = ['src', 'sample']
for x in subdir:
target_dir = '%s/%s' % (env['objroot'], x)
SConscript('%s/%s/SConscript' % (env['srcroot'], x), variant_dir=target_dir, duplicate=0)