diff options
Diffstat (limited to 'pkgs/development/compilers/swift/wrapper')
-rw-r--r-- | pkgs/development/compilers/swift/wrapper/default.nix | 13 | ||||
-rw-r--r-- | pkgs/development/compilers/swift/wrapper/wrapper.sh | 25 |
2 files changed, 36 insertions, 2 deletions
diff --git a/pkgs/development/compilers/swift/wrapper/default.nix b/pkgs/development/compilers/swift/wrapper/default.nix index f244af13fcba2..f1c7198e0f3d5 100644 --- a/pkgs/development/compilers/swift/wrapper/default.nix +++ b/pkgs/development/compilers/swift/wrapper/default.nix @@ -1,6 +1,8 @@ -{ stdenv +{ lib +, stdenv , swift , wrapperParams ? swift._wrapperParams +, useSwiftDriver ? true, swift-driver }: stdenv.mkDerivation (wrapperParams // { @@ -9,12 +11,14 @@ stdenv.mkDerivation (wrapperParams // { outputs = [ "out" "man" ]; - # Setup hook variables. + # Wrapper and setup hook variables. inherit swift; inherit (swift) swiftOs swiftArch swiftModuleSubdir swiftLibSubdir swiftStaticModuleSubdir swiftStaticLibSubdir; + swiftDriver = if useSwiftDriver + then "${swift-driver}/bin/swift-driver" else ""; passAsFile = [ "buildCommand" ]; buildCommand = '' @@ -33,6 +37,11 @@ stdenv.mkDerivation (wrapperParams // { chmod a+x $out/bin/$executable done + ${lib.optionalString useSwiftDriver '' + # Symlink swift-driver executables. + ln -s -t $out/bin/ ${swift-driver}/bin/* + ''} + ln -s ${swift.man} $man # This link is here because various tools (swiftpm) check for stdlib 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 |