blob: 7af03ca37ea34b4335fdb768015aebf1432ddb08 [file] [log] [blame]
Alexander Afanasyev749f0652013-09-22 13:03:21 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2VERSION='1.0'
3APPNAME='ndnx-control-center'
4
5from waflib import Logs, Utils, Task, TaskGen
6
7def options(opt):
Alexander Afanasyeveb111572013-11-08 22:59:43 -08008 opt.load('compiler_c compiler_cxx qt4 gnu_dirs')
Alexander Afanasyevd1a75b82013-09-25 16:50:04 -07009 opt.load('sparkle xcode', tooldir='waf-tools')
Alexander Afanasyev749f0652013-09-22 13:03:21 -070010
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070011 grp = opt.add_option_group ('NDNx Control Center options')
Alexander Afanasyev506d0ab2013-10-29 19:18:10 -070012 grp.add_option ('--ndnx', help='''Root path to NDNx installation (default: /usr/local/ndn)''',
13 dest='ndnx_root', type=str, default='/usr/local/ndn')
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070014
Alexander Afanasyeva822b572013-11-04 12:36:34 -080015 if Utils.unversioned_sys_platform () == "darwin":
16 grp.add_option ('--qt4', help='''Build QT4 app, instead of native one''',
17 action='store_true', dest='build_qt', default=False)
18
19
Alexander Afanasyev749f0652013-09-22 13:03:21 -070020def configure(conf):
21 conf.load('compiler_c compiler_cxx')
22
Alexander Afanasyev1dddc3f2014-01-22 23:36:19 -080023 conf.start_msg('Checking for ndnd-tlv in %s' % conf.options.ndnx_root)
24 if not conf.find_file('ndnd-tlv ndnd-tlv-status ndnd-tlv-start ndnd-tlv-stop', path_list='%s/bin' % conf.options.ndnx_root, mandatory=False):
Alexander Afanasyev506d0ab2013-10-29 19:18:10 -070025 conf.fatal ('not found', 'RED')
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070026 else:
27 conf.end_msg ('ok')
Alexander Afanasyev6cacb972013-10-03 23:39:06 -070028
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070029 conf.define('NDNX_ROOT', conf.options.ndnx_root)
Alexander Afanasyev6cacb972013-10-03 23:39:06 -070030 conf.define('NDND_STATUS_COMMAND', '%s/bin/ndndsmoketest' % conf.options.ndnx_root)
31 conf.define('NDND_FIB_COMMAND', '%s/bin/ndndc' % conf.options.ndnx_root)
Alexander Afanasyevb9024d12013-10-14 18:10:18 +030032 conf.define('NDND_AUTOCONFIG_COMMAND', '%s/bin/ndnd-autoconfig' % conf.options.ndnx_root)
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070033
Alexander Afanasyeva822b572013-11-04 12:36:34 -080034 if Utils.unversioned_sys_platform () == "darwin" and not conf.options.build_qt:
Alexander Afanasyev1dddc3f2014-01-22 23:36:19 -080035 conf.define('NDND_START_COMMAND', '%s/bin/ndnd-tlv-start' % conf.options.ndnx_root)
36 conf.define('NDND_STOP_COMMAND', '%s/bin/ndnd-tlv-stop' % conf.options.ndnx_root)
Alexander Afanasyev86240d02013-11-08 23:32:53 -080037
Alexander Afanasyeva822b572013-11-04 12:36:34 -080038 conf.env.BUILD_OSX_NATIVE = 1
39
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070040 conf.find_program('ibtool', var='IBTOOL', mandatory=False)
Alexander Afanasyev749f0652013-09-22 13:03:21 -070041
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070042 conf.check_cxx(framework_name='Foundation', uselib_store='FOUNDATION', compile_filename='test.mm')
43 conf.check_cxx(framework_name='AppKit', uselib_store='APPKIT', compile_filename='test.mm')
44 conf.check_cxx(framework_name='Cocoa', uselib_store='COCOA', compile_filename='test.mm')
45
46 conf.env.ARCH_OSX = 'x86_64'
Alexander Afanasyev506d0ab2013-10-29 19:18:10 -070047 conf.env.CXXFLAGS_OSX += ['-fobjc-arc', '-mmacosx-version-min=10.7']
Alexander Afanasyeva822b572013-11-04 12:36:34 -080048 conf.env.LINKFLAGS_OSX += ['-mmacosx-version-min=10.7']
Alexander Afanasyev506d0ab2013-10-29 19:18:10 -070049 conf.env.MACOSX_DEPLOYMENT_TARGET = '10.7'
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070050
Alexander Afanasyev749f0652013-09-22 13:03:21 -070051 conf.load('sparkle')
Alexander Afanasyeva822b572013-11-04 12:36:34 -080052 else:
53 conf.load('qt4')
Alexander Afanasyeveb111572013-11-08 22:59:43 -080054 conf.load('gnu_dirs')
Alexander Afanasyev669ea1a2013-11-08 22:25:23 -080055 conf.find_program('xsltproc', mandatory=True)
56 conf.define('XSLTPROC', conf.env['XSLTPROC'])
Alexander Afanasyeveb111572013-11-08 22:59:43 -080057
58 conf.define('RESOURCES_DIR', Utils.subst_vars("${DATAROOTDIR}/ndnx-control-center", conf.env))
Alexander Afanasyeva822b572013-11-04 12:36:34 -080059
60 if Utils.unversioned_sys_platform () == "darwin":
61 conf.define('OSX_BUILD', 1)
62
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070063 conf.write_config_header('config.h')
64
Alexander Afanasyev749f0652013-09-22 13:03:21 -070065def build (bld):
Alexander Afanasyeva822b572013-11-04 12:36:34 -080066 if bld.env.BUILD_OSX_NATIVE:
Alexander Afanasyev749f0652013-09-22 13:03:21 -070067 bld (
68 target = "NDNx Control Center",
69 features=['cxxprogram', 'cxx'],
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070070 includes = ". osx",
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070071 source = bld.path.ant_glob (['osx/**/*.mm', 'osx/MainMenu.xib']),
72
73 mac_app = True,
74 use = "OSX COCOA FOUNDATION APPKIT SPARKLE",
Alexander Afanasyev749f0652013-09-22 13:03:21 -070075
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070076 mac_plist = 'osx/Info.plist',
Ilya Moiseenko350b9b52013-09-25 16:38:41 -070077 mac_resources = [i.path_from(bld.path) for i in bld.path.ant_glob ('osx/Resources/**/*')],
Alexander Afanasyev749f0652013-09-22 13:03:21 -070078 mac_frameworks = "osx/Frameworks/Sparkle.framework",
79 )
Alexander Afanasyeva822b572013-11-04 12:36:34 -080080 else:
Alexander Afanasyeveb111572013-11-08 22:59:43 -080081 bld (features = "subst",
Alexander Afanasyevbb985e92013-11-09 20:50:33 -080082 source = 'linux/ndnxcontrolcenter.desktop.in',
83 target = 'linux/ndnxcontrolcenter.desktop',
84 BINARY = "ndnx-control-center",
Alexander Afanasyeveb111572013-11-08 22:59:43 -080085 install_path = "${DATAROOTDIR}/ndnx-control-center"
86 )
Alexander Afanasyevbb985e92013-11-09 20:50:33 -080087 bld (features = "subst",
88 source = 'linux/ndnx-control-center.desktop.in',
89 target = 'linux/ndnx-control-center.desktop',
90 BINARY = "ndnx-control-center",
91 install_path = "${DATAROOTDIR}/applications"
92 )
Alexander Afanasyeveb111572013-11-08 22:59:43 -080093 bld.install_files("${DATAROOTDIR}/ndnx-control-center",
94 bld.path.ant_glob(['linux/Resources/*']))
95
Alexander Afanasyeva822b572013-11-04 12:36:34 -080096 bld (
Alexander Afanasyevbb985e92013-11-09 20:50:33 -080097 target = "ndnx-control-center",
Alexander Afanasyeva822b572013-11-04 12:36:34 -080098 features=['qt4', 'cxxprogram', 'cxx'],
99 includes = ". linux",
100
101 use = "QTCORE QTGUI QTXML QTXMLPATTERNS QTDBUS",
102
103 defines = "WAF",
104 source = bld.path.ant_glob (['linux/**/*.cpp', 'linux/**/*.ui', 'linux/**/*.qrc']),
105 )
Alexander Afanasyev749f0652013-09-22 13:03:21 -0700106
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -0700107
Alexander Afanasyev749f0652013-09-22 13:03:21 -0700108from waflib import TaskGen
109@TaskGen.extension('.mm')
110def m_hook(self, node):
111 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
112 return self.create_compiled_task('cxx', node)
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -0700113
114@TaskGen.extension('.m')
115def m_hook(self, node):
116 """Alias .m files to be compiled the same as .c files, gcc/clang will do the right thing."""
117 return self.create_compiled_task('c', node)
118
119
120def bundle_name_for_output(name):
121 k = name.rfind('.')
122 if k >= 0:
123 name = name[:k] + '.app'
124 else:
125 name = name + '.app'
126 return name
127
128@TaskGen.extension('.xib')
129def xib(self,node):
130 out = node.change_ext ('.nib')
131
132 name = self.path.get_bld ().find_or_declare (bundle_name_for_output(self.target))
133 resources = name.find_or_declare(['Contents', 'Resources'])
134 resources.mkdir()
135 real_out = resources.make_node (out.name)
136
137 self.create_task('xib', node, real_out)
Alexander Afanasyev5906b832013-10-29 22:41:47 -0700138 inst_to = getattr(self, 'install_path', '/Applications') + '/%s/Contents/Resources' % name
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -0700139 self.bld.install_as (inst_to + '/%s' % real_out.name, real_out)
140
141class xib(Task.Task):
142 color='PINK'
Alexander Afanasyev713e4922013-10-31 17:45:37 -0700143 run_str = '${IBTOOL} --errors --warnings --notices --output-format human-readable-text --compile ${TGT} ${SRC}'