about summary refs log tree commit diff
path: root/pkgs/development/compilers/swift/xctest/default.nix
blob: c8003d8486f102c741ca415a74d981dc432169e2 (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
{ lib
, stdenv
, callPackage
, cmake
, ninja
, swift
, Foundation
, DarwinTools
}:

let
  sources = callPackage ../sources.nix { };
in stdenv.mkDerivation {
  pname = "swift-corelibs-xctest";

  inherit (sources) version;
  src = sources.swift-corelibs-xctest;

  outputs = [ "out" ];

  nativeBuildInputs = [ cmake ninja swift ]
    ++ lib.optional stdenv.isDarwin DarwinTools; # sw_vers
  buildInputs = [ Foundation ];

  postPatch = lib.optionalString stdenv.isDarwin ''
    # On Darwin only, Swift uses arm64 as cpu arch.
    substituteInPlace cmake/modules/SwiftSupport.cmake \
      --replace '"aarch64" PARENT_SCOPE' '"arm64" PARENT_SCOPE'
  '';

  preConfigure = ''
    # On aarch64-darwin, our minimum target is 11.0, but we can target lower,
    # and some dependants require a lower target. Harmless on non-Darwin.
    export MACOSX_DEPLOYMENT_TARGET=10.12
  '';

  cmakeFlags = lib.optional stdenv.isDarwin "-DUSE_FOUNDATION_FRAMEWORK=ON";

  postInstall = lib.optionalString stdenv.isDarwin ''
    # Darwin normally uses the Xcode version of XCTest. Installing
    # swift-corelibs-xctest is probably not officially supported, but we have
    # no alternative. Fix up the installation here.
    mv $out/lib/swift/darwin/${swift.swiftArch}/* $out/lib/swift/darwin
    rmdir $out/lib/swift/darwin/${swift.swiftArch}
    mv $out/lib/swift/darwin $out/lib/swift/${swift.swiftOs}
  '';

  meta = {
    description = "Framework for writing unit tests in Swift";
    homepage = "https://github.com/apple/swift-corelibs-xctest";
    platforms = lib.platforms.all;
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ dtzWill trepetti dduan trundle stephank ];
  };
}