about summary refs log tree commit diff
path: root/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix
blob: 252040dd3ec01802b7fda8932af7e1e04f8e0221 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# SwiftPM dependencies are normally not installed using CMake, and only provide
# CMake modules to link them together in a build tree. We have separate
# derivations, so need a real install step. Here we provide our own minimal
# CMake modules to install along with the build products.
{ lib, stdenv, swift }:
let

  inherit (stdenv.hostPlatform) extensions;

  # This file exports shell snippets for use in postInstall.
  mkInstallScript = module: template: ''
    mkdir -p $out/lib/cmake/${module}
    (
      export staticLibExt="${extensions.staticLibrary}"
      export sharedLibExt="${extensions.sharedLibrary}"
      export swiftOs="${swift.swiftOs}"
      substituteAll \
        ${builtins.toFile "${module}Config.cmake" template} \
        $out/lib/cmake/${module}/${module}Config.cmake
    )
  '';

in lib.mapAttrs mkInstallScript {
  SwiftSystem = ''
    add_library(SwiftSystem::SystemPackage STATIC IMPORTED)
    set_property(TARGET SwiftSystem::SystemPackage PROPERTY IMPORTED_LOCATION "@out@/lib/swift_static/@swiftOs@/libSystemPackage@staticLibExt@")
  '';

  SwiftCollections = ''
    add_library(SwiftCollections::Collections STATIC IMPORTED)
    set_property(TARGET SwiftCollections::Collections PROPERTY IMPORTED_LOCATION "@out@/lib/swift_static/@swiftOs@/libCollections@staticLibExt@")

    add_library(SwiftCollections::DequeModule STATIC IMPORTED)
    set_property(TARGET SwiftCollections::DequeModule PROPERTY IMPORTED_LOCATION "@out@/lib/swift_static/@swiftOs@/libDequeModule@staticLibExt@")

    add_library(SwiftCollections::OrderedCollections STATIC IMPORTED)
    set_property(TARGET SwiftCollections::OrderedCollections PROPERTY IMPORTED_LOCATION "@out@/lib/swift_static/@swiftOs@/libOrderedCollections@staticLibExt@")
  '';

  TSC = ''
    add_library(TSCLibc SHARED IMPORTED)
    set_property(TARGET TSCLibc PROPERTY IMPORTED_LOCATION "@out@/lib/libTSCLibc@sharedLibExt@")

    add_library(TSCBasic SHARED IMPORTED)
    set_property(TARGET TSCBasic PROPERTY IMPORTED_LOCATION "@out@/lib/libTSCBasic@sharedLibExt@")

    add_library(TSCUtility SHARED IMPORTED)
    set_property(TARGET TSCUtility PROPERTY IMPORTED_LOCATION "@out@/lib/libTSCUtility@sharedLibExt@")
  '';

  ArgumentParser = ''
    add_library(ArgumentParser SHARED IMPORTED)
    set_property(TARGET ArgumentParser PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libArgumentParser@sharedLibExt@")

    add_library(ArgumentParserToolInfo SHARED IMPORTED)
    set_property(TARGET ArgumentParserToolInfo PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libArgumentParserToolInfo@sharedLibExt@")
  '';

  Yams = ''
    add_library(Yams SHARED IMPORTED)
    set_property(TARGET Yams PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libYams@sharedLibExt@")
  '';

  LLBuild = ''
    add_library(libllbuild SHARED IMPORTED)
    set_property(TARGET libllbuild PROPERTY IMPORTED_LOCATION "@out@/lib/libllbuild@sharedLibExt@")

    add_library(llbuildSwift SHARED IMPORTED)
    set_property(TARGET llbuildSwift PROPERTY IMPORTED_LOCATION "@out@/lib/swift/pm/llbuild/libllbuildSwift@sharedLibExt@")
  '';

  SwiftDriver = ''
    add_library(SwiftDriver SHARED IMPORTED)
    set_property(TARGET SwiftDriver PROPERTY IMPORTED_LOCATION "@out@/lib/libSwiftDriver@sharedLibExt@")

    add_library(SwiftDriverExecution SHARED IMPORTED)
    set_property(TARGET SwiftDriverExecution PROPERTY IMPORTED_LOCATION "@out@/lib/libSwiftDriverExecution@sharedLibExt@")

    add_library(SwiftOptions SHARED IMPORTED)
    set_property(TARGET SwiftOptions PROPERTY IMPORTED_LOCATION "@out@/lib/libSwiftOptions@sharedLibExt@")
  '';

  SwiftCrypto = ''
    add_library(Crypto SHARED IMPORTED)
    set_property(TARGET Crypto PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libCrypto@sharedLibExt@")
  '';
}