blob: a657f70f4460b3ffd270b42489d46c10c5234db3 [file] [log] [blame]
Alexander Afanasyev7cd43ab2017-03-27 21:33:10 -05001from waflib import Logs, Utils, TaskGen
Alexander Afanasyev1160baa2014-04-10 18:50:29 -07002from waflib.Configure import conf
3
Davide Pesavento4b8eab72018-09-01 20:10:36 -04004@conf
5def check_osx_framework_cxx(conf, fw_name, **kw):
6 conf.check_cxx(framework_name=fw_name,
7 uselib_store='OSX_' + fw_name.upper(),
8 fragment='#include <{0}/{0}.h>\nint main() {{}}'.format(fw_name),
9 **kw)
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070010
Davide Pesavento4b8eab72018-09-01 20:10:36 -040011@conf
12def check_osx_framework_mm(conf, fw_name, **kw):
13 conf.check_cxx(framework_name=fw_name,
14 uselib_store='OSX_' + fw_name.upper(),
15 fragment='#import <{0}/{0}.h>\nint main() {{}}'.format(fw_name),
16 compile_filename='test.mm',
17 **kw)
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050018
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070019@conf
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -050020def check_osx_frameworks(conf, *k, **kw):
Davide Pesavento4b8eab72018-09-01 20:10:36 -040021 if Utils.unversioned_sys_platform() == 'darwin':
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070022 try:
Davide Pesavento4b8eab72018-09-01 20:10:36 -040023 conf.check_osx_framework_cxx('CoreFoundation', mandatory=True)
24 conf.check_osx_framework_cxx('Security', use='OSX_COREFOUNDATION', mandatory=True)
25 conf.check_osx_framework_cxx('SystemConfiguration', use='OSX_COREFOUNDATION', mandatory=True)
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070026
Davide Pesavento4b8eab72018-09-01 20:10:36 -040027 conf.check_osx_framework_mm('Foundation', mandatory=True)
28 conf.check_osx_framework_mm('CoreWLAN', use='OSX_FOUNDATION', mandatory=True)
Alexander Afanasyev5bcee102017-03-27 22:28:29 -050029
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -050030 conf.define('HAVE_OSX_FRAMEWORKS', 1)
31 conf.env['HAVE_OSX_FRAMEWORKS'] = True
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070032 except:
Davide Pesavento4b8eab72018-09-01 20:10:36 -040033 Logs.warn('Building on macOS, but one or more required frameworks are not functional.')
34 Logs.warn('Note that the frameworks are known to work only with the Apple clang compiler.')
Alexander Afanasyev7cd43ab2017-03-27 21:33:10 -050035
36@TaskGen.extension('.mm')
37def m_hook(self, node):
Davide Pesavento4b8eab72018-09-01 20:10:36 -040038 '''Alias .mm files to be compiled the same as .cpp files, clang will do the right thing.'''
Alexander Afanasyev7cd43ab2017-03-27 21:33:10 -050039 return self.create_compiled_task('cxx', node)