about summary refs log tree commit diff
path: root/pkgs/development/compilers/swift/wrapper/wrapper.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/swift/wrapper/wrapper.sh')
-rw-r--r--pkgs/development/compilers/swift/wrapper/wrapper.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkgs/development/compilers/swift/wrapper/wrapper.sh b/pkgs/development/compilers/swift/wrapper/wrapper.sh
index dd08355903963..0c56e63b6f29e 100644
--- a/pkgs/development/compilers/swift/wrapper/wrapper.sh
+++ b/pkgs/development/compilers/swift/wrapper/wrapper.sh
@@ -63,6 +63,31 @@ case "$firstArg" in
         ;;
 esac
 
+# For many tasks, Swift reinvokes swift-driver, the new driver implementation
+# written in Swift. It needs some help finding the executable, though, and
+# reimplementing the logic here is little effort. These checks follow
+# `shouldDisallowNewDriver`.
+if [[
+    $isFrontend = 0 &&
+    -n "@swiftDriver@" &&
+    -z "${SWIFT_USE_OLD_DRIVER:-}" &&
+    ( "$progName" == "swift" || "$progName" == "swiftc" )
+]]; then
+    prog=@swiftDriver@
+    # Driver mode must be the very first argument.
+    extraBefore+=( "--driver-mode=$progName" )
+    if [[ $isRepl = 1 ]]; then
+        extraBefore+=( "-repl" )
+    fi
+
+    # Ensure swift-driver invokes the unwrapped frontend (instead of finding
+    # the wrapped one via PATH), because we don't have to wrap a second time.
+    export SWIFT_DRIVER_SWIFT_FRONTEND_EXEC="@swift@/bin/swift-frontend"
+
+    # Ensure swift-driver can find the LLDB with Swift support for the REPL.
+    export SWIFT_DRIVER_LLDB_EXEC="@swift@/bin/lldb"
+fi
+
 path_backup="$PATH"
 
 # That @-vars are substituted separately from bash evaluation makes