diff options
Diffstat (limited to 'waftools/detections')
-rw-r--r-- | waftools/detections/compiler_swift.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/waftools/detections/compiler_swift.py b/waftools/detections/compiler_swift.py index 9b0e06ed8a..d4ba162667 100644 --- a/waftools/detections/compiler_swift.py +++ b/waftools/detections/compiler_swift.py @@ -1,3 +1,4 @@ +import re from waflib import Utils def __run(cmd): @@ -8,18 +9,22 @@ def __run(cmd): return "" 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_FLAGS = [ + "-frontend", "-c", "-sdk", ctx.env.MACOS_SDK, + "-enable-objc-interop", "-emit-objc-header", "-parse-as-library", + "-target", "x86_64-apple-macosx10.10" + ] + + ver = re.compile("(?i)version\s?([\d.]+)") + ctx.env.SWIFT_VERSION = ver.search(__run([ctx.env.SWIFT, '-version'])).group(1) + 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: - ctx.env.SWIFT_FLAGS += ' -swift-version 3' + ctx.env.SWIFT_FLAGS.extend([ "-swift-version", "3" ]) if ctx.is_optimization(): - ctx.env.SWIFT_FLAGS += ' -O' + ctx.env.SWIFT_FLAGS.append("-O") def __add_swift_library_linking_flags(ctx, swift_library): ctx.env.append_value('LINKFLAGS', [ |