summaryrefslogtreecommitdiffstats
path: root/waftools/detections/compiler_swift.py
diff options
context:
space:
mode:
Diffstat (limited to 'waftools/detections/compiler_swift.py')
-rw-r--r--waftools/detections/compiler_swift.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/waftools/detections/compiler_swift.py b/waftools/detections/compiler_swift.py
index 3dffcdedd2..4ff6d20119 100644
--- a/waftools/detections/compiler_swift.py
+++ b/waftools/detections/compiler_swift.py
@@ -30,12 +30,25 @@ def __add_swift_flags(ctx):
if ctx.is_optimization():
ctx.env.SWIFT_FLAGS.append("-O")
-def __add_swift_library_linking_flags(ctx, swift_library):
+def __add_static_swift_library_linking_flags(ctx, swift_library):
ctx.env.append_value('LINKFLAGS', [
'-L%s' % swift_library,
'-Xlinker', '-force_load_swift_libs', '-lc++',
])
+def __add_dynamic_swift_library_linking_flags(ctx, swift_library):
+ ctx.env.append_value('LINKFLAGS', [ '-L%s' % swift_library ])
+
+ #ABI compatibility
+ if StrictVersion(ctx.env.SWIFT_VERSION) >= StrictVersion("5.0"):
+ ctx.env.append_value('LINKFLAGS', [
+ '-Xlinker', '-rpath', '-Xlinker', '/usr/lib/swift',
+ ])
+
+ ctx.env.append_value('LINKFLAGS', [
+ '-Xlinker', '-rpath', '-Xlinker', swift_library,
+ ])
+
def __find_swift_library(ctx):
swift_libraries = {}
#look for set lib paths in passed environment variables
@@ -90,10 +103,16 @@ def __find_swift_library(ctx):
ctx.start_msg('Checking for static Swift Library')
if 'SWIFT_LIB_STATIC' in swift_libraries:
ctx.end_msg(swift_libraries['SWIFT_LIB_STATIC'])
- __add_swift_library_linking_flags(ctx, swift_libraries['SWIFT_LIB_STATIC'])
+ ctx.env['SWIFT_LIB_STATIC'] = swift_libraries['SWIFT_LIB_STATIC']
else:
ctx.end_msg(False)
+ enableStatic = getattr(ctx.options, 'enable_swift-static')
+ if (enableStatic or enableStatic == None) and 'SWIFT_LIB_STATIC' in swift_libraries:
+ __add_static_swift_library_linking_flags(ctx, swift_libraries['SWIFT_LIB_STATIC'])
+ else:
+ __add_dynamic_swift_library_linking_flags(ctx, swift_libraries['SWIFT_LIB_DYNAMIC'])
+
def __find_macos_sdk(ctx):
ctx.start_msg('Checking for macOS SDK')
sdk = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-path'])