blob: 5366b72232e3149c0c8935f36ced9ee3838f7879 [file] [log] [blame]
Alexander Afanasyev1160baa2014-04-10 18:50:29 -07001#! /usr/bin/env python
2# encoding: utf-8
3
Alexander Afanasyev7cd43ab2017-03-27 21:33:10 -05004from waflib import Logs, Utils, TaskGen
Alexander Afanasyev1160baa2014-04-10 18:50:29 -07005from waflib.Configure import conf
6
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -05007OSX_SECURITY_CODE = '''
Alexander Afanasyev1160baa2014-04-10 18:50:29 -07008#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 Pesavento7c02b472015-10-28 20:50:17 +010013int main() {}
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070014'''
15
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050016OSX_SYSTEMCONFIGURATION_CODE = '''
17#include <CoreFoundation/CoreFoundation.h>
18#include <SystemConfiguration/SystemConfiguration.h>
19int main() {}
20'''
21
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070022@conf
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -050023def check_osx_frameworks(conf, *k, **kw):
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070024 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 Afanasyev0cf887d2017-03-26 16:58:59 -050031 use='OSX_COREFOUNDATION', fragment=OSX_SECURITY_CODE,
32 mandatory=True)
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050033 conf.check_cxx(framework_name='SystemConfiguration', uselib_store='OSX_SYSTEMCONFIGURATION',
34 use='OSX_COREFOUNDATION', fragment=OSX_SYSTEMCONFIGURATION_CODE,
35 mandatory=True)
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070036
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -050037 conf.define('HAVE_OSX_FRAMEWORKS', 1)
38 conf.env['HAVE_OSX_FRAMEWORKS'] = True
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070039 except:
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050040 Logs.warn("Compiling on OSX, but CoreFoundation, CoreServices, Security, or SystemConfiguration " +
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -050041 "framework is not functional.")
42 Logs.warn("The frameworks are known to work only with the Apple clang compiler")
Alexander Afanasyev7cd43ab2017-03-27 21:33:10 -050043
44@TaskGen.extension('.mm')
45def 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)