/
SConscript
110 lines (92 loc) · 4.15 KB
/
SConscript
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#
# -*- mode: python; -*-
Import('BuildEnv')
env = BuildEnv.Clone()
env.CppDisableExceptions()
env.Append(CPPPATH = env['TOP'])
env.Append(CPPPATH = env['TOP'] + '/discovery/client')
env.Prepend(LIBS=['ds', 'sandesh', 'http', 'http_parser', 'curl', 'io', 'base'])
except_env = BuildEnv.Clone()
except_env.CppEnableExceptions()
except_env.Append(CPPPATH = env['TOP'])
SandeshGenFiles = env.SandeshGenCpp('ifmap_server_show.sandesh')
SandeshGenFiles += env.SandeshGenOnlyCpp('ifmap_server_show_internal.sandesh')
SandeshGenFiles += env.SandeshGenCpp('ifmap_log.sandesh')
SandeshGenSrcs = env.ExtractCpp(SandeshGenFiles)
sandesh_objs = []
for src in SandeshGenSrcs:
objname = src.replace('.cpp', '.o')
obj = except_env.Object(objname, src)
sandesh_objs.append(obj)
ifmap_server = except_env.Object('ifmap_server.o', 'ifmap_server.cc')
ifmap_server_show = except_env.Object('ifmap_server_show.o', 'ifmap_server_show.cc')
ifmap_xmpp = except_env.Object('ifmap_xmpp.o', 'ifmap_xmpp.cc')
ifmap_xmpp_client_show = except_env.Object('ifmap_xmpp_client_show.o', 'ifmap_xmpp_client_show.cc')
AgentSandeshGenFiles = env.SandeshGenCpp('ifmap_agent.sandesh')
AgentSandeshGenSrcs = env.ExtractCpp(AgentSandeshGenFiles)
libifmap_common = env.Library('ifmap_common',
['ifmap_dependency_tracker.cc',
'ifmap_table.cc',
'ifmap_link.cc',
'ifmap_link_table.cc',
'ifmap_node.cc',
'ifmap_object.cc',
'ifmap_log.cc'] + sandesh_objs)
# control-node
libifmap = env.Library('ifmap_server',
['ifmap_client.cc',
'ifmap_config_listener.cc',
'ifmap_encoder.cc',
'ifmap_exporter.cc',
'ifmap_factory.cc',
'ifmap_graph_walker.cc',
'ifmap_node_proxy.cc',
ifmap_server_show,
ifmap_server,
'ifmap_server_parser.cc',
'ifmap_server_table.cc',
'ifmap_update.cc',
'ifmap_update_queue.cc',
'ifmap_update_sender.cc',
'ifmap_util.cc',
'ifmap_uuid_mapper.cc',
'ifmap_whitelist.cc',
ifmap_xmpp,
ifmap_xmpp_client_show,
] + sandesh_objs)
# agent-module
libifmap_agent = env.Library('ifmap_agent',
[ 'ifmap_agent_parser.cc',
'ifmap_agent_table.cc',
'ifmap_agent_sandesh.cc',
] + AgentSandeshGenSrcs)
test_suite = env.SConscript('client/SConscript', exports='BuildEnv',
duplicate = 0)
test_suite += env.SConscript('test/SConscript', exports='BuildEnv',
duplicate = 0)
def code_coverage(target, source, env):
import shutil
shutil.rmtree(target[0].path, ignore_errors = True)
# lcov --base-directory $ROOT -- directory . --zerocounters -q
import os
os.system('lcov --base-directory . --directory ' + Dir('.').path +
' --zerocounters -q')
# execute tests
import subprocess
ShEnv = {env['ENV_SHLIB_PATH']: 'build/lib'}
for test in test_suite:
cmd = test[0].path
logfile = open(cmd + '.log', 'w')
subprocess.call([cmd], stdout=logfile, env=ShEnv)
# lcov --base-directory $ROOT -- directory . -c -o ifmap_test.info
os.system('lcov --base-directory . --directory ' + Dir('.').path +
' -c -o ifmap_test.info')
# genhtml -o ifmap/test_coverage ifmap_test.info
os.system('genhtml -o ' + target[0].path +
' -t "test coverage" --num-spaces 4 ifmap_test.info')
if env['OPT'] == 'coverage':
test_coverage = env.Command(Dir('test_coverage'), '', code_coverage)
env.AlwaysBuild(test_coverage)
env.Alias('src/ifmap:test_coverage', test_coverage)