blob: f1c7198e0f3d5072c5087e7f6ffce3a95eae3745 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
{ lib
, stdenv
, swift
, wrapperParams ? swift._wrapperParams
, useSwiftDriver ? true, swift-driver
}:
stdenv.mkDerivation (wrapperParams // {
pname = "swift-wrapper";
inherit (swift) version meta;
outputs = [ "out" "man" ];
# 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 = ''
mkdir -p $out/bin $out/nix-support
# Symlink all Swift binaries first.
# NOTE: This specifically omits clang binaries. We want to hide these for
# private use by Swift only.
ln -s -t $out/bin/ $swift/bin/swift*
# Replace specific binaries with wrappers.
for executable in swift swiftc swift-frontend; do
export prog=$swift/bin/$executable
rm $out/bin/$executable
substituteAll '${./wrapper.sh}' $out/bin/$executable
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
# relative to the swift compiler. It's fine if this is for build-time
# stuff, but we should patch all cases were it would end up in an output.
ln -s ${swift.lib}/lib $out/lib
substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook
'';
passthru = {
inherit swift;
inherit (swift) swiftOs swiftArch swiftModuleSubdir swiftLibSubdir;
};
})
|