Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | VERSION='1.0' |
| 3 | APPNAME='ndnx-control-center' |
| 4 | |
| 5 | from waflib import Logs, Utils, Task, TaskGen |
| 6 | |
| 7 | def options(opt): |
| 8 | opt.load('compiler_c compiler_cxx') |
| 9 | opt.load('sparkle', tooldir='waf-tools') |
| 10 | |
| 11 | def 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 Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 19 | conf.find_program('ibtool', var='IBTOOL', mandatory=False) |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 20 | |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 21 | 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 Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 31 | conf.load('sparkle') |
| 32 | |
| 33 | def 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 Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 43 | source = bld.path.ant_glob (['osx/**/*.mm', 'osx/MainMenu.xib']), |
| 44 | |
| 45 | mac_app = True, |
| 46 | use = "OSX COCOA FOUNDATION APPKIT SPARKLE", |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 47 | |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 48 | mac_plist = 'osx/Info.plist', |
Ilya Moiseenko | 350b9b5 | 2013-09-25 16:38:41 -0700 | [diff] [blame^] | 49 | mac_resources = [i.path_from(bld.path) for i in bld.path.ant_glob ('osx/Resources/**/*')], |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 50 | mac_frameworks = "osx/Frameworks/Sparkle.framework", |
| 51 | ) |
| 52 | |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 53 | |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 54 | from waflib import TaskGen |
| 55 | @TaskGen.extension('.mm') |
| 56 | def 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 Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 59 | |
| 60 | @TaskGen.extension('.m') |
| 61 | def 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 | |
| 66 | def 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') |
| 75 | def 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 | |
| 87 | class 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}' |