From 770fc5221528e18c17e7b3664ad300a96cdace3a Mon Sep 17 00:00:00 2001 From: der richter Date: Sun, 14 Apr 2019 11:39:12 +0200 Subject: build: make Swift lib and compiler paths configurable via env vars --- waftools/detections/compiler_swift.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/waftools/detections/compiler_swift.py b/waftools/detections/compiler_swift.py index bdac0baf83..3dffcdedd2 100644 --- a/waftools/detections/compiler_swift.py +++ b/waftools/detections/compiler_swift.py @@ -38,17 +38,24 @@ def __add_swift_library_linking_flags(ctx, swift_library): def __find_swift_library(ctx): swift_libraries = {} - #first search for swift libs relative to the swift compiler executable + #look for set lib paths in passed environment variables + if 'SWIFT_LIB_DYNAMIC' in ctx.environ: + swift_libraries['SWIFT_LIB_DYNAMIC'] = ctx.environ['SWIFT_LIB_DYNAMIC'] + if 'SWIFT_LIB_STATIC' in ctx.environ: + swift_libraries['SWIFT_LIB_STATIC'] = ctx.environ['SWIFT_LIB_STATIC'] + + #search for swift libs relative to the swift compiler executable swift_library_relative_paths = { 'SWIFT_LIB_DYNAMIC': '../../lib/swift/macosx', 'SWIFT_LIB_STATIC': '../../lib/swift_static/macosx' } for lib_type, path in swift_library_relative_paths.items(): - lib_path = os.path.join(ctx.env.SWIFT, path) - swift_library = ctx.root.find_dir(lib_path) - if swift_library is not None: - swift_libraries[lib_type] = swift_library.abspath() + if lib_type not in swift_libraries: + lib_path = os.path.join(ctx.env.SWIFT, path) + swift_library = ctx.root.find_dir(lib_path) + if swift_library is not None: + swift_libraries[lib_type] = swift_library.abspath() #fall back to xcode-select path swift_library_paths = { @@ -98,7 +105,16 @@ def __find_macos_sdk(ctx): def __find_swift_compiler(ctx): ctx.start_msg('Checking for swift (Swift compiler)') - swift = __run(['xcrun', '-find', 'swift']) + swift = '' + + #look for set swift paths in passed environment variables + if 'SWIFT' in ctx.environ: + swift = ctx.environ['SWIFT'] + + #find swift executable + if not swift: + swift = __run(['xcrun', '-find', 'swift']) + if swift: ctx.end_msg(swift) ctx.env.SWIFT = swift -- cgit v1.2.3