add waf
diff --git a/waf b/waf
new file mode 100755
index 0000000..df70b3e
--- /dev/null
+++ b/waf
Binary files differ
diff --git a/waf-tools/ccnx.py b/waf-tools/ccnx.py
new file mode 100644
index 0000000..5338b5f
--- /dev/null
+++ b/waf-tools/ccnx.py
@@ -0,0 +1,77 @@
+#! /usr/bin/env python
+# encoding: utf-8
+
+'''
+
+When using this tool, the wscript will look like:
+
+ def options(opt):
+ opt.tool_options('ccnx', tooldir=["waf-tools"])
+
+ def configure(conf):
+ conf.load('compiler_cxx ccnx')
+
+ def build(bld):
+ bld(source='main.cpp', target='app', use='CCNX')
+
+Options are generated, in order to specify the location of ccnx includes/libraries.
+
+
+'''
+import sys
+import re
+from waflib import Utils,Logs,Errors
+from waflib.Configure import conf
+CCNX_DIR=['/usr','/usr/local','/opt/local','/sw']
+CCNX_VERSION_FILE='ccn/ccn.h'
+CCNX_VERSION_CODE='''
+#include <iostream>
+#include <ccn/ccn.h>
+int main() { std::cout << ((CCN_API_VERSION/100000) % 100) << "." << ((CCN_API_VERSION/1000) % 100) << "." << (CCN_API_VERSION % 1000); }
+'''
+
+def options(opt):
+ opt.add_option('--ccnx',type='string',default='',dest='ccnx_dir',help='''path to where CCNx is installed, e.g. /usr/local''')
+@conf
+def __ccnx_get_version_file(self,dir):
+ # Logs.pprint ('CYAN', ' + %s/%s/%s' % (dir, 'include', CCNX_VERSION_FILE))
+ try:
+ return self.root.find_dir(dir).find_node('%s/%s' % ('include', CCNX_VERSION_FILE))
+ except:
+ return None
+@conf
+def ccnx_get_version(self,dir):
+ val=self.check_cxx(fragment=CCNX_VERSION_CODE,includes=['%s/%s' % (dir, 'include')],execute=True,define_ret = True, mandatory=True)
+ return val
+@conf
+def ccnx_get_root(self,*k,**kw):
+ root=k and k[0]or kw.get('path',None)
+ # Logs.pprint ('RED', ' %s' %root)
+ if root and self.__ccnx_get_version_file(root):
+ return root
+ for dir in CCNX_DIR:
+ if self.__ccnx_get_version_file(dir):
+ return dir
+ if root:
+ self.fatal('CCNx not found in %s'%root)
+ else:
+ self.fatal('CCNx not found, please provide a --ccnx argument (see help)')
+@conf
+def check_ccnx(self,*k,**kw):
+ if not self.env['CXX']:
+ self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
+
+ var=kw.get('uselib_store','CCNX')
+ self.start_msg('Checking CCNx')
+ root = self.ccnx_get_root(*k,**kw);
+ self.env.CCNX_VERSION=self.ccnx_get_version(root)
+
+ self.env['INCLUDES_%s'%var]= '%s/%s' % (root, "include");
+ self.env['LIB_%s'%var] = "ccn"
+ self.env['LIBPATH_%s'%var] = '%s/%s' % (root, "lib")
+
+ self.end_msg(self.env.CCNX_VERSION)
+ if Logs.verbose:
+ Logs.pprint('CYAN',' ccnx include : %s'%self.env['INCLUDES_%s'%var])
+ Logs.pprint('CYAN',' ccnx lib : %s'%self.env['LIB_%s'%var])
+ Logs.pprint('CYAN',' ccnx libpath : %s'%self.env['LIBPATH_%s'%var])
diff --git a/waf-tools/protobuf.py b/waf-tools/protobuf.py
new file mode 100644
index 0000000..684a945
--- /dev/null
+++ b/waf-tools/protobuf.py
@@ -0,0 +1,72 @@
+# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+#! /usr/bin/env python
+# encoding: utf-8
+
+'''
+
+When using this tool, the wscript will look like:
+
+def options(opt):
+ opt.tool_options("protobuf", tooldir=["waf-tools"])
+
+def configure(conf):
+ conf.load("compiler_cxx protobuf")
+
+def build(bld):
+ bld(source="main.cpp", target="app", use="PROTOBUF")
+
+Options are generated, in order to specify the location of protobuf includes/libraries.
+
+'''
+
+from waflib import Utils, TaskGen, Task, Logs
+
+from waflib import Utils,Logs,Errors
+from waflib.Configure import conf
+
+def options(opt):
+ pass
+
+def configure(conf):
+ """
+ """
+ conf.check_cfg(package='protobuf', args=['--cflags', '--libs'], uselib_store='PROTOBUF', mandatory=True)
+
+ conf.find_program ('protoc', var='PROTOC', path_list = conf.env['PATH'], mandatory = True)
+
+@TaskGen.extension('.proto')
+def add_proto(self, node):
+ """
+ Compile PROTOBUF protocol specifications
+ """
+ prototask = self.create_task ("protobuf", node, node.change_ext (".pb"))
+ try:
+ self.compiled_tasks.append (prototask)
+ except AttributeError:
+ self.compiled_tasks = [prototask]
+
+class protobuf(Task.Task):
+ """
+ Task for compiling PROTOBUF protocol specifications
+ """
+ run_str = '${PROTOC} --cpp_out ${TGT[0].parent.abspath()} --proto_path ${SRC[0].parent.abspath()} ${SRC[0].abspath()} -o${TGT[0].abspath()}'
+ color = 'BLUE'
+
+@TaskGen.feature('cxxshlib')
+@TaskGen.before_method('process_source')
+def dynamic_post(self):
+ if not getattr(self, 'dynamic_source', None):
+ return
+ self.source = Utils.to_list(self.source)
+
+ src = self.bld.path.get_bld().ant_glob (Utils.to_list(self.dynamic_source))
+
+ for cc in src:
+ # Signature for the source
+ cc.sig = Utils.h_file (cc.abspath())
+ # Signature for the header
+ h = cc.change_ext (".h")
+ h.sig = Utils.h_file (h.abspath())
+
+ self.source.extend (src)
diff --git a/wscript b/wscript
new file mode 100644
index 0000000..585b6a9
--- /dev/null
+++ b/wscript
@@ -0,0 +1,83 @@
+# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+VERSION='0.0.1'
+APPNAME='chronoshare'
+
+from waflib import Build, Logs
+
+def options(opt):
+ opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
+ opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
+ opt.load('compiler_c')
+ opt.load('compiler_cxx')
+ opt.load('boost')
+ opt.load('gnu_dirs')
+ opt.load('ccnx protobuf', tooldir=["waf-tools"])
+
+def configure(conf):
+ conf.load("compiler_cxx")
+ conf.load('gnu_dirs')
+
+ if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
+ libcrypto = conf.check_cc(lib='crypto',
+ header_name='openssl/crypto.h',
+ define_name='HAVE_SSL',
+ uselib_store='SSL')
+ if not conf.get_define ("HAVE_SSL"):
+ conf.fatal ("Cannot find SSL libraries")
+
+ conf.load('boost')
+
+ conf.check_boost(lib='system iostreams test thread')
+
+ conf.load ('ccnx')
+ conf.check_ccnx (path=conf.options.ccnx_dir)
+
+ if conf.options.debug:
+ conf.define ('_DEBUG', 1)
+ conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
+ else:
+ conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
+
+ if conf.options._test:
+ conf.define('_TEST', 1)
+
+ conf.load('protobuf')
+
+def build (bld):
+ bld.post_mode = Build.POST_LAZY
+
+ bld.add_group ("protobuf")
+
+# x = bld (
+# features = ["protobuf"],
+# source = ["model/sync-state.proto"],
+# target = ["model/sync-state.pb"],
+# )
+
+ bld.add_group ("code")
+
+ libccnx = bld (
+ target=APPNAME,
+ features=['cxx', 'cxxshlib'],
+ source = [
+ 'src/ccnx-wrapper.cpp',
+ 'src/ccnx-tunnel.cpp',
+ ],
+ use = 'BOOST BOOST_THREAD SSL CCNX',
+ includes = ['include', ],
+ )
+
+ # Unit tests
+ if bld.get_define("_TEST"):
+ unittests = bld.program (
+ target="unit-tests",
+ source = bld.path.ant_glob(['test/**/*.cc']),
+ features=['cxx', 'cxxprogram'],
+ use = 'BOOST_TEST',
+ includes = ['include', ],
+ )
+
+
+
+