blob: 6bbd913d186756558d1f615da595b8858a3bed9d [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
11def configure(conf):
12 conf.load('compiler_c compiler_cxx')
13
14 if Utils.unversioned_sys_platform () != "darwin":
15 Logs.error ("Only OSX is supported so far")
16 return -1
17
18 if Utils.unversioned_sys_platform () == "darwin":
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070019 conf.find_program('ibtool', var='IBTOOL', mandatory=False)
Alexander Afanasyev749f0652013-09-22 13:03:21 -070020
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070021 conf.check_cxx(framework_name='Foundation', uselib_store='FOUNDATION', compile_filename='test.mm')
22 conf.check_cxx(framework_name='AppKit', uselib_store='APPKIT', compile_filename='test.mm')
23 conf.check_cxx(framework_name='Cocoa', uselib_store='COCOA', compile_filename='test.mm')
24
25 conf.env.ARCH_OSX = 'x86_64'
26 conf.env.CXXFLAGS_OSX += ['-fobjc-arc', '-mmacosx-version-min=10.8']
27 conf.env.LINKFLAGS_OSX += ['-mmacosx-version-min=10.8']
28
29 conf.env.MACOSX_DEPLOYMENT_TARGET = '10.8'
30
Alexander Afanasyev749f0652013-09-22 13:03:21 -070031 conf.load('sparkle')
32
33def build (bld):
34 if Utils.unversioned_sys_platform () != "darwin":
35 Logs.error ("Only OSX is supported so far")
36 return -1
37
38 if Utils.unversioned_sys_platform () == "darwin":
39 bld (
40 target = "NDNx Control Center",
41 features=['cxxprogram', 'cxx'],
42 includes = "osx",
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070043 source = bld.path.ant_glob (['osx/**/*.mm', 'osx/MainMenu.xib']),
44
45 mac_app = True,
46 use = "OSX COCOA FOUNDATION APPKIT SPARKLE",
Alexander Afanasyev749f0652013-09-22 13:03:21 -070047
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070048 mac_plist = 'osx/Info.plist',
Ilya Moiseenko350b9b52013-09-25 16:38:41 -070049 mac_resources = [i.path_from(bld.path) for i in bld.path.ant_glob ('osx/Resources/**/*')],
Alexander Afanasyev749f0652013-09-22 13:03:21 -070050 mac_frameworks = "osx/Frameworks/Sparkle.framework",
51 )
52
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070053
Alexander Afanasyev749f0652013-09-22 13:03:21 -070054from waflib import TaskGen
55@TaskGen.extension('.mm')
56def m_hook(self, node):
57 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
58 return self.create_compiled_task('cxx', node)
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070059
60@TaskGen.extension('.m')
61def m_hook(self, node):
62 """Alias .m files to be compiled the same as .c files, gcc/clang will do the right thing."""
63 return self.create_compiled_task('c', node)
64
65
66def bundle_name_for_output(name):
67 k = name.rfind('.')
68 if k >= 0:
69 name = name[:k] + '.app'
70 else:
71 name = name + '.app'
72 return name
73
74@TaskGen.extension('.xib')
75def xib(self,node):
76 out = node.change_ext ('.nib')
77
78 name = self.path.get_bld ().find_or_declare (bundle_name_for_output(self.target))
79 resources = name.find_or_declare(['Contents', 'Resources'])
80 resources.mkdir()
81 real_out = resources.make_node (out.name)
82
83 self.create_task('xib', node, real_out)
84 inst_to = getattr(self, 'install_path', '/Applications') + '/%s/Resources' % name
85 self.bld.install_as (inst_to + '/%s' % real_out.name, real_out)
86
87class xib(Task.Task):
88 color='PINK'
89 run_str = '${IBTOOL} --errors --warnings --notices --minimum-deployment-target 10.8 --output-format human-readable-text --compile ${TGT} ${SRC}'