Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | #!/usr/bin/env python |
| 3 | # encoding: utf-8 |
| 4 | # Alexander Afanasyev, 2013 |
| 5 | |
| 6 | from waflib.Task import Task |
| 7 | from waflib.TaskGen import extension |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 8 | from waflib import Logs |
| 9 | from waflib import Node |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame] | 10 | |
| 11 | """ |
| 12 | A simple tool to integrate zeroc ICE into your build system. |
| 13 | |
| 14 | def configure(conf): |
| 15 | conf.load('compiler_cxx cxx ice_cxx') |
| 16 | |
| 17 | def build(bld): |
| 18 | bld( |
| 19 | features = 'cxx cxxprogram' |
| 20 | source = 'main.cpp file1.ice', |
| 21 | include = '.', |
| 22 | target = 'executable') |
| 23 | |
| 24 | """ |
| 25 | |
| 26 | class ice_cxx(Task): |
| 27 | run_str = '${SLICE2CPP} --header-ext ice.h --source-ext ice.cc --output-dir ${SRC[0].parent.get_bld().abspath()} ${SRC[0].abspath()}' |
| 28 | color = 'BLUE' |
| 29 | ext_out = ['.ice.h', '.ice.cc'] |
| 30 | |
| 31 | @extension('.ice') |
| 32 | def process_protoc(self, node): |
| 33 | cpp_node = node.change_ext('.ice.cc') |
| 34 | hpp_node = node.change_ext('.ice.h') |
| 35 | self.create_task('ice_cxx', node, [cpp_node, hpp_node]) |
| 36 | self.source.append(cpp_node) |
| 37 | |
| 38 | use = getattr(self, 'use', '') |
| 39 | if not 'ICE' in use: |
| 40 | self.use = self.to_list(use) + ['ICE'] |
| 41 | |
| 42 | ICE_PATHS = ['/usr', '/usr/local', '/opt/local', '/sw'] |
| 43 | |
| 44 | def options(opt): |
| 45 | opt.add_option('--ice',action='store',dest='ICE_PATH',help='''path to ZeroC installation''') |
| 46 | |
| 47 | |
| 48 | def configure(conf): |
| 49 | # conf.check_cfg(package="", uselib_store="PROTOBUF", args=['--cflags', '--libs']) |
| 50 | if conf.options.ICE_PATH: |
| 51 | conf.find_program('slice2cpp', var='SLICE2CPP', path_list="%s/bin" % conf.options.ICE_PATH, mandatory=True) |
| 52 | else: |
| 53 | conf.find_program('slice2cpp', var='SLICE2CPP', path_list=["%s/bin" % path for path in ICE_PATHS], mandatory=True) |
| 54 | |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 55 | ICE_PATH = conf.env.SLICE2CPP[:-14] |
| 56 | |
| 57 | conf.env['LIB_ICE'] = ["Ice", "ZeroCIce", "IceUtil"] |
| 58 | conf.env['INCLUDES_ICE']= '%s/include' % ICE_PATH |
| 59 | conf.env['LIBPATH_ICE'] = '%s/lib' % ICE_PATH |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame] | 60 | |