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): |
Alexander Afanasyev | eb11157 | 2013-11-08 22:59:43 -0800 | [diff] [blame] | 8 | opt.load('compiler_c compiler_cxx qt4 gnu_dirs') |
Alexander Afanasyev | d1a75b8 | 2013-09-25 16:50:04 -0700 | [diff] [blame] | 9 | opt.load('sparkle xcode', tooldir='waf-tools') |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 10 | |
Alexander Afanasyev | 2beff7f | 2013-09-27 17:50:36 -0700 | [diff] [blame] | 11 | grp = opt.add_option_group ('NDNx Control Center options') |
Alexander Afanasyev | 506d0ab | 2013-10-29 19:18:10 -0700 | [diff] [blame] | 12 | 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 Afanasyev | 2beff7f | 2013-09-27 17:50:36 -0700 | [diff] [blame] | 14 | |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 15 | 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 Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 20 | def configure(conf): |
| 21 | conf.load('compiler_c compiler_cxx') |
| 22 | |
Alexander Afanasyev | 2beff7f | 2013-09-27 17:50:36 -0700 | [diff] [blame] | 23 | conf.start_msg('Checking for NDNx in %s' % conf.options.ndnx_root) |
| 24 | if not conf.find_file('ndnd ndndstatus ndndstart ndndstop', path_list='%s/bin' % conf.options.ndnx_root, mandatory=False): |
Alexander Afanasyev | 506d0ab | 2013-10-29 19:18:10 -0700 | [diff] [blame] | 25 | conf.fatal ('not found', 'RED') |
Alexander Afanasyev | 2beff7f | 2013-09-27 17:50:36 -0700 | [diff] [blame] | 26 | else: |
| 27 | conf.end_msg ('ok') |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 28 | |
Alexander Afanasyev | 2beff7f | 2013-09-27 17:50:36 -0700 | [diff] [blame] | 29 | conf.define('NDNX_ROOT', conf.options.ndnx_root) |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 30 | 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 Afanasyev | b9024d1 | 2013-10-14 18:10:18 +0300 | [diff] [blame] | 32 | conf.define('NDND_AUTOCONFIG_COMMAND', '%s/bin/ndnd-autoconfig' % conf.options.ndnx_root) |
Alexander Afanasyev | 2beff7f | 2013-09-27 17:50:36 -0700 | [diff] [blame] | 33 | |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 34 | if Utils.unversioned_sys_platform () == "darwin" and not conf.options.build_qt: |
Alexander Afanasyev | 86240d0 | 2013-11-08 23:32:53 -0800 | [diff] [blame] | 35 | conf.define('NDND_START_COMMAND', '%s/bin/ndndstart' % conf.options.ndnx_root) |
| 36 | conf.define('NDND_STOP_COMMAND', '%s/bin/ndndstop' % conf.options.ndnx_root) |
| 37 | |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 38 | conf.env.BUILD_OSX_NATIVE = 1 |
| 39 | |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 40 | conf.find_program('ibtool', var='IBTOOL', mandatory=False) |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 41 | |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 42 | 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 Afanasyev | 506d0ab | 2013-10-29 19:18:10 -0700 | [diff] [blame] | 47 | conf.env.CXXFLAGS_OSX += ['-fobjc-arc', '-mmacosx-version-min=10.7'] |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 48 | conf.env.LINKFLAGS_OSX += ['-mmacosx-version-min=10.7'] |
Alexander Afanasyev | 506d0ab | 2013-10-29 19:18:10 -0700 | [diff] [blame] | 49 | conf.env.MACOSX_DEPLOYMENT_TARGET = '10.7' |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 50 | |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 51 | conf.load('sparkle') |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 52 | else: |
| 53 | conf.load('qt4') |
Alexander Afanasyev | eb11157 | 2013-11-08 22:59:43 -0800 | [diff] [blame] | 54 | conf.load('gnu_dirs') |
Alexander Afanasyev | 669ea1a | 2013-11-08 22:25:23 -0800 | [diff] [blame] | 55 | conf.find_program('xsltproc', mandatory=True) |
| 56 | conf.define('XSLTPROC', conf.env['XSLTPROC']) |
Alexander Afanasyev | eb11157 | 2013-11-08 22:59:43 -0800 | [diff] [blame] | 57 | |
| 58 | conf.define('RESOURCES_DIR', Utils.subst_vars("${DATAROOTDIR}/ndnx-control-center", conf.env)) |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 59 | |
| 60 | if Utils.unversioned_sys_platform () == "darwin": |
| 61 | conf.define('OSX_BUILD', 1) |
| 62 | |
Alexander Afanasyev | 2beff7f | 2013-09-27 17:50:36 -0700 | [diff] [blame] | 63 | conf.write_config_header('config.h') |
| 64 | |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 65 | def build (bld): |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 66 | if bld.env.BUILD_OSX_NATIVE: |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 67 | bld ( |
| 68 | target = "NDNx Control Center", |
| 69 | features=['cxxprogram', 'cxx'], |
Alexander Afanasyev | 2beff7f | 2013-09-27 17:50:36 -0700 | [diff] [blame] | 70 | includes = ". osx", |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 71 | source = bld.path.ant_glob (['osx/**/*.mm', 'osx/MainMenu.xib']), |
| 72 | |
| 73 | mac_app = True, |
| 74 | use = "OSX COCOA FOUNDATION APPKIT SPARKLE", |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 75 | |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 76 | mac_plist = 'osx/Info.plist', |
Ilya Moiseenko | 350b9b5 | 2013-09-25 16:38:41 -0700 | [diff] [blame] | 77 | 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] | 78 | mac_frameworks = "osx/Frameworks/Sparkle.framework", |
| 79 | ) |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 80 | else: |
Alexander Afanasyev | eb11157 | 2013-11-08 22:59:43 -0800 | [diff] [blame] | 81 | bld (features = "subst", |
| 82 | source = bld.path.ant_glob(['linux/**/*.in']), |
| 83 | target = [node.change_ext('', '.in') for node in bld.path.ant_glob(['linux/**/*.in'])], |
Alexander Afanasyev | 4ab3f8a | 2013-11-09 20:08:28 -0800 | [diff] [blame] | 84 | BINARY = "NDNx\\ Control\\ Center", |
Alexander Afanasyev | eb11157 | 2013-11-08 22:59:43 -0800 | [diff] [blame] | 85 | install_path = "${DATAROOTDIR}/ndnx-control-center" |
| 86 | ) |
| 87 | bld.install_files("${DATAROOTDIR}/ndnx-control-center", |
| 88 | bld.path.ant_glob(['linux/Resources/*'])) |
| 89 | |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 90 | bld ( |
| 91 | target = "NDNx Control Center", |
| 92 | features=['qt4', 'cxxprogram', 'cxx'], |
| 93 | includes = ". linux", |
| 94 | |
| 95 | use = "QTCORE QTGUI QTXML QTXMLPATTERNS QTDBUS", |
| 96 | |
| 97 | defines = "WAF", |
| 98 | source = bld.path.ant_glob (['linux/**/*.cpp', 'linux/**/*.ui', 'linux/**/*.qrc']), |
| 99 | ) |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 100 | |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 101 | |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 102 | from waflib import TaskGen |
| 103 | @TaskGen.extension('.mm') |
| 104 | def m_hook(self, node): |
| 105 | """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing.""" |
| 106 | return self.create_compiled_task('cxx', node) |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 107 | |
| 108 | @TaskGen.extension('.m') |
| 109 | def m_hook(self, node): |
| 110 | """Alias .m files to be compiled the same as .c files, gcc/clang will do the right thing.""" |
| 111 | return self.create_compiled_task('c', node) |
| 112 | |
| 113 | |
| 114 | def bundle_name_for_output(name): |
| 115 | k = name.rfind('.') |
| 116 | if k >= 0: |
| 117 | name = name[:k] + '.app' |
| 118 | else: |
| 119 | name = name + '.app' |
| 120 | return name |
| 121 | |
| 122 | @TaskGen.extension('.xib') |
| 123 | def xib(self,node): |
| 124 | out = node.change_ext ('.nib') |
| 125 | |
| 126 | name = self.path.get_bld ().find_or_declare (bundle_name_for_output(self.target)) |
| 127 | resources = name.find_or_declare(['Contents', 'Resources']) |
| 128 | resources.mkdir() |
| 129 | real_out = resources.make_node (out.name) |
| 130 | |
| 131 | self.create_task('xib', node, real_out) |
Alexander Afanasyev | 5906b83 | 2013-10-29 22:41:47 -0700 | [diff] [blame] | 132 | inst_to = getattr(self, 'install_path', '/Applications') + '/%s/Contents/Resources' % name |
Alexander Afanasyev | 88f0b3a | 2013-09-24 23:52:08 -0700 | [diff] [blame] | 133 | self.bld.install_as (inst_to + '/%s' % real_out.name, real_out) |
| 134 | |
| 135 | class xib(Task.Task): |
| 136 | color='PINK' |
Alexander Afanasyev | 713e492 | 2013-10-31 17:45:37 -0700 | [diff] [blame] | 137 | run_str = '${IBTOOL} --errors --warnings --notices --output-format human-readable-text --compile ${TGT} ${SRC}' |