blob: 76cd3df77b4628f664c3f313e670b3a9f6206d96 [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
Davide Pesavento4b8eab72018-09-01 20:10:36 -04007@conf
8def check_osx_framework_cxx(conf, fw_name, **kw):
9 conf.check_cxx(framework_name=fw_name,
10 uselib_store='OSX_' + fw_name.upper(),
11 fragment='#include <{0}/{0}.h>\nint main() {{}}'.format(fw_name),
12 **kw)
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070013
Davide Pesavento4b8eab72018-09-01 20:10:36 -040014@conf
15def check_osx_framework_mm(conf, fw_name, **kw):
16 conf.check_cxx(framework_name=fw_name,
17 uselib_store='OSX_' + fw_name.upper(),
18 fragment='#import <{0}/{0}.h>\nint main() {{}}'.format(fw_name),
19 compile_filename='test.mm',
20 **kw)
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050021
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070022@conf
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -050023def check_osx_frameworks(conf, *k, **kw):
Davide Pesavento4b8eab72018-09-01 20:10:36 -040024 if Utils.unversioned_sys_platform() == 'darwin':
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070025 try:
Davide Pesavento4b8eab72018-09-01 20:10:36 -040026 conf.check_osx_framework_cxx('CoreFoundation', mandatory=True)
27 conf.check_osx_framework_cxx('Security', use='OSX_COREFOUNDATION', mandatory=True)
28 conf.check_osx_framework_cxx('SystemConfiguration', use='OSX_COREFOUNDATION', mandatory=True)
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070029
Davide Pesavento4b8eab72018-09-01 20:10:36 -040030 conf.check_osx_framework_mm('Foundation', mandatory=True)
31 conf.check_osx_framework_mm('CoreWLAN', use='OSX_FOUNDATION', mandatory=True)
Alexander Afanasyev5bcee102017-03-27 22:28:29 -050032
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -050033 conf.define('HAVE_OSX_FRAMEWORKS', 1)
34 conf.env['HAVE_OSX_FRAMEWORKS'] = True
Alexander Afanasyev1160baa2014-04-10 18:50:29 -070035 except:
Davide Pesavento4b8eab72018-09-01 20:10:36 -040036 Logs.warn('Building on macOS, but one or more required frameworks are not functional.')
37 Logs.warn('Note that the frameworks are known to work only with the Apple clang compiler.')
Alexander Afanasyev7cd43ab2017-03-27 21:33:10 -050038
39@TaskGen.extension('.mm')
40def m_hook(self, node):
Davide Pesavento4b8eab72018-09-01 20:10:36 -040041 '''Alias .mm files to be compiled the same as .cpp files, clang will do the right thing.'''
Alexander Afanasyev7cd43ab2017-03-27 21:33:10 -050042 return self.create_compiled_task('cxx', node)