blob: 3f1d6a6d691e232bebd96f5376920f8b5afca38a [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):
8 opt.load('compiler_c compiler_cxx')
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')
12 grp.add_option ('--ndnx', help='''Root path to NDNx installation (default: /usr)''',
13 dest='ndnx_root', type=str, default='/usr')
14
Alexander Afanasyev749f0652013-09-22 13:03:21 -070015def configure(conf):
16 conf.load('compiler_c compiler_cxx')
17
18 if Utils.unversioned_sys_platform () != "darwin":
19 Logs.error ("Only OSX is supported so far")
20 return -1
21
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070022 conf.start_msg('Checking for NDNx in %s' % conf.options.ndnx_root)
23 if not conf.find_file('ndnd ndndstatus ndndstart ndndstop', path_list='%s/bin' % conf.options.ndnx_root, mandatory=False):
24 conf.end_msg ('not found, but will proceed anyways', 'YELLOW')
25 else:
26 conf.end_msg ('ok')
Alexander Afanasyev6cacb972013-10-03 23:39:06 -070027
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070028 conf.define('NDNX_ROOT', conf.options.ndnx_root)
Alexander Afanasyev6cacb972013-10-03 23:39:06 -070029 conf.define('NDND_START_COMMAND', '%s/bin/ndndstart' % conf.options.ndnx_root)
30 conf.define('NDND_STOP_COMMAND', '%s/bin/ndndstop' % conf.options.ndnx_root)
31 conf.define('NDND_STATUS_COMMAND', '%s/bin/ndndsmoketest' % conf.options.ndnx_root)
32 conf.define('NDND_FIB_COMMAND', '%s/bin/ndndc' % conf.options.ndnx_root)
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070033
Alexander Afanasyev749f0652013-09-22 13:03:21 -070034 if Utils.unversioned_sys_platform () == "darwin":
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070035 conf.find_program('ibtool', var='IBTOOL', mandatory=False)
Alexander Afanasyev749f0652013-09-22 13:03:21 -070036
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070037 conf.check_cxx(framework_name='Foundation', uselib_store='FOUNDATION', compile_filename='test.mm')
38 conf.check_cxx(framework_name='AppKit', uselib_store='APPKIT', compile_filename='test.mm')
39 conf.check_cxx(framework_name='Cocoa', uselib_store='COCOA', compile_filename='test.mm')
40
41 conf.env.ARCH_OSX = 'x86_64'
42 conf.env.CXXFLAGS_OSX += ['-fobjc-arc', '-mmacosx-version-min=10.8']
43 conf.env.LINKFLAGS_OSX += ['-mmacosx-version-min=10.8']
44
45 conf.env.MACOSX_DEPLOYMENT_TARGET = '10.8'
46
Alexander Afanasyev749f0652013-09-22 13:03:21 -070047 conf.load('sparkle')
48
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070049 conf.write_config_header('config.h')
50
Alexander Afanasyev749f0652013-09-22 13:03:21 -070051def build (bld):
52 if Utils.unversioned_sys_platform () != "darwin":
53 Logs.error ("Only OSX is supported so far")
54 return -1
55
56 if Utils.unversioned_sys_platform () == "darwin":
57 bld (
58 target = "NDNx Control Center",
59 features=['cxxprogram', 'cxx'],
Alexander Afanasyev2beff7f2013-09-27 17:50:36 -070060 includes = ". osx",
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070061 source = bld.path.ant_glob (['osx/**/*.mm', 'osx/MainMenu.xib']),
62
63 mac_app = True,
64 use = "OSX COCOA FOUNDATION APPKIT SPARKLE",
Alexander Afanasyev749f0652013-09-22 13:03:21 -070065
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070066 mac_plist = 'osx/Info.plist',
Ilya Moiseenko350b9b52013-09-25 16:38:41 -070067 mac_resources = [i.path_from(bld.path) for i in bld.path.ant_glob ('osx/Resources/**/*')],
Alexander Afanasyev749f0652013-09-22 13:03:21 -070068 mac_frameworks = "osx/Frameworks/Sparkle.framework",
69 )
70
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070071
Alexander Afanasyev749f0652013-09-22 13:03:21 -070072from waflib import TaskGen
73@TaskGen.extension('.mm')
74def m_hook(self, node):
75 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
76 return self.create_compiled_task('cxx', node)
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070077
78@TaskGen.extension('.m')
79def m_hook(self, node):
80 """Alias .m files to be compiled the same as .c files, gcc/clang will do the right thing."""
81 return self.create_compiled_task('c', node)
82
83
84def bundle_name_for_output(name):
85 k = name.rfind('.')
86 if k >= 0:
87 name = name[:k] + '.app'
88 else:
89 name = name + '.app'
90 return name
91
92@TaskGen.extension('.xib')
93def xib(self,node):
94 out = node.change_ext ('.nib')
95
96 name = self.path.get_bld ().find_or_declare (bundle_name_for_output(self.target))
97 resources = name.find_or_declare(['Contents', 'Resources'])
98 resources.mkdir()
99 real_out = resources.make_node (out.name)
100
101 self.create_task('xib', node, real_out)
102 inst_to = getattr(self, 'install_path', '/Applications') + '/%s/Resources' % name
103 self.bld.install_as (inst_to + '/%s' % real_out.name, real_out)
104
105class xib(Task.Task):
106 color='PINK'
107 run_str = '${IBTOOL} --errors --warnings --notices --minimum-deployment-target 10.8 --output-format human-readable-text --compile ${TGT} ${SRC}'