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