blob: 477a7f75c4a37203b72cf63d04b39c1ba07e9948 [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 Afanasyev5bcee102017-03-27 22:28:29 -050037 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 Afanasyev0cf887d2017-03-26 16:58:59 -050042 conf.define('HAVE_OSX_FRAMEWORKS', 1)
43 conf.env['HAVE_OSX_FRAMEWORKS'] = True
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070044 except:
Alexander Afanasyev5bcee102017-03-27 22:28:29 -050045 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 Afanasyev7cd43ab2017-03-27 21:33:10 -050047
48@TaskGen.extension('.mm')
49def 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)