blob: c87bf89960fd7d7fba6d7a025778e845eee58084 [file] [log] [blame]
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev182fdc22012-03-05 18:06:52 -08003VERSION='0.0.1'
4APPNAME='sync'
5
Alexander Afanasyeve76f2632012-03-05 00:18:42 -08006def options(opt):
Zhenkai Zhu699d7402012-05-29 16:47:39 -07007 opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -07008 opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx/native NS3 logging support''')
9 opt.add_option('--ns3', action='store_true',default=False,dest='ns3_enable',help='''Compile as NS-3 module''')
Alexander Afanasyev983b0e92012-04-26 12:44:18 -070010 opt.add_option('--ns3-debug', action='store_true',default=False,dest='ns3_debug',help='''Link against debug NS3 libraries. Optimized version will be used otherwise''')
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070011 opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080012 opt.load('compiler_c')
13 opt.load('compiler_cxx')
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080014 opt.load('boost')
15 opt.load('doxygen')
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -070016 opt.load('ccnx protobuf ns3', tooldir=["waf-tools"])
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080017
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080018def configure(conf):
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080019 conf.load("compiler_cxx")
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080020
21 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
22 libcrypto = conf.check_cc(lib='crypto',
23 header_name='openssl/crypto.h',
24 define_name='HAVE_SSL',
25 uselib_store='SSL')
26 if not conf.get_define ("HAVE_SSL"):
27 conf.fatal ("Cannot find SSL libraries")
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080028
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080029 conf.load('boost')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070030
31 if conf.options.ns3_enable:
32 conf.load('ns3')
33 conf.define('NS3_MODULE', 1)
34 conf.check_modules(['core', 'network', 'internet'], mandatory = True)
35 conf.check_modules(['NDNabstraction'], mandatory = True)
36 conf.check_modules(['point-to-point'], mandatory = False)
37 conf.check_modules(['point-to-point-layout'], mandatory = False)
38
39 conf.check_boost(lib='system iostreams thread')
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -070040 conf.define ('NS3_LOG_ENABLE', 1)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070041 else:
42 conf.check_boost(lib='system iostreams test thread')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070043
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070044 conf.load ('ccnx')
45 conf.check_ccnx (path=conf.options.ccnx_dir)
46
47 if conf.options.log4cxx:
48 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
49
Zhenkai Zhu699d7402012-05-29 16:47:39 -070050 if conf.options.debug:
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070051 conf.define ('_DEBUG', 1)
Alexander Afanasyeva0c8a1d2012-04-05 13:55:42 -070052 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
53 else:
Zhenkai Zhudc70a292012-06-01 14:00:59 -070054 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070055
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070056 if conf.options._test:
57 conf.define('_TEST', 1)
58
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080059 try:
60 conf.load('doxygen')
61 except:
62 pass
63
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -070064 conf.load('protobuf')
65 conf.check_protobuf (path=conf.options.protobuf_dir)
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070066
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -070067
68def pre(bld):
69 bld.exec_command('protoc --cpp_out=. sync-state.proto')
70 bld.exec_command('mv sync-state.pb.h include/')
71 bld.exec_command('mv sync-state.pb.cc model/')
72
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080073def build (bld):
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -070074 bld.add_pre_fun(pre)
75
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070076 if bld.get_define ("NS3_MODULE"):
77 sync_ns3 = bld.shlib (
78 target = "sync-ns3",
79 features=['cxx', 'cxxshlib'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070080 source = [
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070081 'ns3/sync-ccnx-wrapper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070082 'ns3/sync-ns3-name-info.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070083 'ns3/sync-scheduler.cc',
Alexander Afanasyev09e8d752012-04-10 16:05:55 -070084 'ns3/sync-logic-helper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070085
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070086 # 'model/sync-app-data-fetch.cc',
87 # 'model/sync-app-data-publish.cc',
88 # 'ns3/sync-app.cc',
89
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070090 'model/sync-diff-leaf.cc',
91 'model/sync-diff-state.cc',
92 'model/sync-digest.cc',
93 'model/sync-full-leaf.cc',
94 'model/sync-full-state.cc',
95 'model/sync-interest-table.cc',
96 'model/sync-leaf.cc',
97 'model/sync-logic.cc',
98 'model/sync-name-info.cc',
99 'model/sync-seq-no.cc',
100 'model/sync-state.cc',
101 'model/sync-std-name-info.cc',
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -0700102 'model/sync-state.pb.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700103 ],
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -0700104 use = 'BOOST BOOST_IOSTREAMS SSL PROTOBUF ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (),
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700105 includes = ['include', 'include/ns3', 'helper'],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700106 )
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -0700107
108 example = bld.program (
109 target = "sync-example",
110 features=['cxx', 'cxxprogram'],
111 source = ['examples/sync-example.cc'],
112 use = 'sync-ns3',
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700113 includes = ['include', 'include/ns3', 'helper'],
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -0700114 )
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700115
116 sync_eval = bld.program (
117 target = "sync-eval",
118 features=['cxx', 'cxxprogram'],
119 source = ['evaluation/sync-eval.cc',
120 'evaluation/standard-muc.cc',
Alexander Afanasyev40942f42012-04-21 20:53:16 -0700121 'evaluation/sync-muc.cc',
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700122 ],
123 use = 'sync-ns3',
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700124 includes = ['include', 'include/ns3', 'helper'],
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700125 )
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700126 # from waflib import Utils,Logs,Errors
127 # Logs.pprint ('CYAN', program.use)
128
129 else:
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700130 libsync = bld.shlib (
131 target=APPNAME,
132 features=['cxx', 'cxxshlib'],
133 source = [
134 'ccnx/sync-ccnx-wrapper.cc',
135 'ccnx/sync-scheduler.cc',
136 'ccnx/sync-log.cc',
Chaoyi Bian2f2d6412012-06-04 16:53:08 -0700137 'ccnx/sync-app-socket-c.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -0700138 'ccnx/sync-app-socket.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700139 'model/sync-diff-leaf.cc',
140 'model/sync-diff-state.cc',
141 'model/sync-digest.cc',
142 'model/sync-full-leaf.cc',
143 'model/sync-full-state.cc',
144 'model/sync-interest-table.cc',
145 'model/sync-leaf.cc',
146 'model/sync-logic.cc',
147 'model/sync-name-info.cc',
148 'model/sync-seq-no.cc',
149 'model/sync-state.cc',
150 'model/sync-std-name-info.cc',
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -0700151 'model/sync-state.pb.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700152 ],
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -0700153 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL PROTOBUF CCNX',
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700154 includes = ['include', 'helper'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700155 )
156
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700157 # Unit tests
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -0700158 if bld.get_define("_TEST"):
159 unittests = bld.program (
160 target="unit-tests",
161 source = bld.path.ant_glob(['test/**/*.cc']),
162 features=['cxx', 'cxxprogram'],
163 use = 'BOOST_TEST sync',
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700164 includes = ['include', 'helper'],
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -0700165 )
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -0700166
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700167 if bld.get_define ("HAVE_LOG4CXX"):
168 libsync.use += ' LOG4CXX'
169 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -0800170
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800171# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800172from waflib.Build import BuildContext
173class doxy (BuildContext):
174 cmd = "doxygen"
175 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800176
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800177def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800178 if not bld.env.DOXYGEN:
179 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800180 bld (features="doxygen",
181 doxyfile='doc/doxygen.conf',
182 output_dir = 'doc')