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 | 0cf887d | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 37 | conf.define('HAVE_OSX_FRAMEWORKS', 1) |
| 38 | conf.env['HAVE_OSX_FRAMEWORKS'] = True |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 39 | except: |
Alexander Afanasyev | 3b3355c | 2017-03-26 11:57:13 -0500 | [diff] [blame] | 40 | Logs.warn("Compiling on OSX, but CoreFoundation, CoreServices, Security, or SystemConfiguration " + |
Alexander Afanasyev | 0cf887d | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 41 | "framework is not functional.") |
| 42 | Logs.warn("The frameworks are known to work only with the Apple clang compiler") |
Alexander Afanasyev | 7cd43ab | 2017-03-27 21:33:10 -0500 | [diff] [blame^] | 43 | |
| 44 | @TaskGen.extension('.mm') |
| 45 | def m_hook(self, node): |
| 46 | """Alias .mm files to be compiled the same as .cpp files, gcc/clang will do the right thing.""" |
| 47 | return self.create_compiled_task('cxx', node) |