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 | |
Alexander Afanasyev | 0cf887d | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 7 | OSX_SECURITY_CODE = ''' |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 8 | #include <CoreFoundation/CoreFoundation.h> |
| 9 | #include <Security/Security.h> |
| 10 | #include <Security/SecRandom.h> |
| 11 | #include <CoreServices/CoreServices.h> |
| 12 | #include <Security/SecDigestTransform.h> |
Davide Pesavento | 7c02b47 | 2015-10-28 20:50:17 +0100 | [diff] [blame] | 13 | int main() {} |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 14 | ''' |
| 15 | |
Alexander Afanasyev | 3b3355c | 2017-03-26 11:57:13 -0500 | [diff] [blame] | 16 | OSX_SYSTEMCONFIGURATION_CODE = ''' |
| 17 | #include <CoreFoundation/CoreFoundation.h> |
| 18 | #include <SystemConfiguration/SystemConfiguration.h> |
| 19 | int main() {} |
| 20 | ''' |
| 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): |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 24 | if Utils.unversioned_sys_platform() == "darwin": |
| 25 | try: |
| 26 | conf.check_cxx(framework_name='CoreFoundation', uselib_store='OSX_COREFOUNDATION', |
| 27 | mandatory=True) |
| 28 | conf.check_cxx(framework_name='CoreServices', uselib_store='OSX_CORESERVICES', |
| 29 | mandatory=True) |
| 30 | conf.check_cxx(framework_name='Security', uselib_store='OSX_SECURITY', |
Alexander Afanasyev | 0cf887d | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 31 | use='OSX_COREFOUNDATION', fragment=OSX_SECURITY_CODE, |
| 32 | mandatory=True) |
Alexander Afanasyev | 3b3355c | 2017-03-26 11:57:13 -0500 | [diff] [blame] | 33 | conf.check_cxx(framework_name='SystemConfiguration', uselib_store='OSX_SYSTEMCONFIGURATION', |
| 34 | use='OSX_COREFOUNDATION', fragment=OSX_SYSTEMCONFIGURATION_CODE, |
| 35 | mandatory=True) |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 36 | |
Alexander Afanasyev | 5bcee10 | 2017-03-27 22:28:29 -0500 | [diff] [blame] | 37 | conf.check_cxx(framework_name='Foundation', uselib_store='OSX_FOUNDATION', |
| 38 | mandatory=True, compile_filename='test.mm') |
| 39 | conf.check_cxx(framework_name='CoreWLAN', uselib_store='OSX_COREWLAN', |
| 40 | use="OSX_FOUNDATION", mandatory=True, compile_filename='test.mm') |
| 41 | |
Alexander Afanasyev | 0cf887d | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 42 | conf.define('HAVE_OSX_FRAMEWORKS', 1) |
| 43 | conf.env['HAVE_OSX_FRAMEWORKS'] = True |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 44 | except: |
Alexander Afanasyev | 5bcee10 | 2017-03-27 22:28:29 -0500 | [diff] [blame] | 45 | Logs.warn("Compiling on macOS, but required framework(s) is(are) not functional.") |
| 46 | 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] | 47 | |
| 48 | @TaskGen.extension('.mm') |
| 49 | def m_hook(self, node): |
| 50 | """Alias .mm files to be compiled the same as .cpp files, gcc/clang will do the right thing.""" |
| 51 | return self.create_compiled_task('cxx', node) |