Alexander Afanasyev | 7cd43ab | 2017-03-27 21:33:10 -0500 | [diff] [blame] | 1 | from waflib import Logs, Utils, TaskGen |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 2 | from waflib.Configure import conf |
| 3 | |
Davide Pesavento | 4b8eab7 | 2018-09-01 20:10:36 -0400 | [diff] [blame] | 4 | @conf |
| 5 | def check_osx_framework_cxx(conf, fw_name, **kw): |
| 6 | conf.check_cxx(framework_name=fw_name, |
| 7 | uselib_store='OSX_' + fw_name.upper(), |
| 8 | fragment='#include <{0}/{0}.h>\nint main() {{}}'.format(fw_name), |
| 9 | **kw) |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 10 | |
Davide Pesavento | 4b8eab7 | 2018-09-01 20:10:36 -0400 | [diff] [blame] | 11 | @conf |
| 12 | def check_osx_framework_mm(conf, fw_name, **kw): |
| 13 | conf.check_cxx(framework_name=fw_name, |
| 14 | uselib_store='OSX_' + fw_name.upper(), |
| 15 | fragment='#import <{0}/{0}.h>\nint main() {{}}'.format(fw_name), |
| 16 | compile_filename='test.mm', |
| 17 | **kw) |
Alexander Afanasyev | 3b3355c | 2017-03-26 11:57:13 -0500 | [diff] [blame] | 18 | |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 19 | @conf |
Alexander Afanasyev | 0cf887d | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 20 | def check_osx_frameworks(conf, *k, **kw): |
Davide Pesavento | 4b8eab7 | 2018-09-01 20:10:36 -0400 | [diff] [blame] | 21 | if Utils.unversioned_sys_platform() == 'darwin': |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 22 | try: |
Davide Pesavento | 4b8eab7 | 2018-09-01 20:10:36 -0400 | [diff] [blame] | 23 | conf.check_osx_framework_cxx('CoreFoundation', mandatory=True) |
| 24 | conf.check_osx_framework_cxx('Security', use='OSX_COREFOUNDATION', mandatory=True) |
| 25 | conf.check_osx_framework_cxx('SystemConfiguration', use='OSX_COREFOUNDATION', mandatory=True) |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 26 | |
Davide Pesavento | 4b8eab7 | 2018-09-01 20:10:36 -0400 | [diff] [blame] | 27 | conf.check_osx_framework_mm('Foundation', mandatory=True) |
| 28 | conf.check_osx_framework_mm('CoreWLAN', use='OSX_FOUNDATION', mandatory=True) |
Alexander Afanasyev | 5bcee10 | 2017-03-27 22:28:29 -0500 | [diff] [blame] | 29 | |
Alexander Afanasyev | 0cf887d | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 30 | conf.define('HAVE_OSX_FRAMEWORKS', 1) |
| 31 | conf.env['HAVE_OSX_FRAMEWORKS'] = True |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 32 | except: |
Davide Pesavento | 4b8eab7 | 2018-09-01 20:10:36 -0400 | [diff] [blame] | 33 | Logs.warn('Building on macOS, but one or more required frameworks are not functional.') |
| 34 | Logs.warn('Note that the frameworks are known to work only with the Apple clang compiler.') |
Alexander Afanasyev | 7cd43ab | 2017-03-27 21:33:10 -0500 | [diff] [blame] | 35 | |
| 36 | @TaskGen.extension('.mm') |
| 37 | def m_hook(self, node): |
Davide Pesavento | 4b8eab7 | 2018-09-01 20:10:36 -0400 | [diff] [blame] | 38 | '''Alias .mm files to be compiled the same as .cpp files, clang will do the right thing.''' |
Alexander Afanasyev | 7cd43ab | 2017-03-27 21:33:10 -0500 | [diff] [blame] | 39 | return self.create_compiled_task('cxx', node) |