build: check for Swift version and disable dependencies if needed

(cherry picked from commit 50787acb27)
This commit is contained in:
Akemi 2018-07-08 16:49:33 +02:00 committed by Jan Ekström
parent 46969b449a
commit 89e52a228c
3 changed files with 11 additions and 4 deletions

View File

@ -4,7 +4,7 @@ from waflib import Utils
import os
__all__ = ["check_pthreads", "check_iconv", "check_lua",
"check_cocoa", "check_wl_protocols"]
"check_cocoa", "check_wl_protocols", "check_swift"]
pthreads_program = load_fragment('pthreads.c')
@ -111,3 +111,10 @@ def check_cocoa(ctx, dependency_identifier):
])
return res
def check_swift(ctx, dependency_identifier):
if ctx.env.SWIFT_VERSION:
major = int(ctx.env.SWIFT_VERSION.split('.')[0])
if major >= 3:
return True
return False

View File

@ -11,8 +11,8 @@ def __add_swift_flags(ctx):
ctx.env.SWIFT_FLAGS = ('-frontend -c -sdk %s -enable-objc-interop'
' -emit-objc-header -parse-as-library'
' -target x86_64-apple-macosx10.10') % (ctx.env.MACOS_SDK)
swift_version = __run([ctx.env.SWIFT, '-version']).split(' ')[3].split('.')[:2]
major, minor = [int(n) for n in swift_version]
ctx.env.SWIFT_VERSION = __run([ctx.env.SWIFT, '-version']).split(' ')[3]
major, minor = [int(n) for n in ctx.env.SWIFT_VERSION.split('.')[:2]]
# the -swift-version parameter is only supported on swift 3.1 and newer
if major >= 3 and minor >= 1 or major >= 4:

View File

@ -913,7 +913,7 @@ standalone_features = [
'name': '--macos-cocoa-cb',
'desc': 'macOS opengl-cb backend',
'deps': 'cocoa',
'func': check_true
'func': check_swift
}
]