at master 1.7 kB view raw
1{ 2 lib, 3 stdenv, 4 callPackage, 5 cmake, 6 ninja, 7 swift, 8 Foundation, 9 DarwinTools, 10}: 11 12let 13 sources = callPackage ../sources.nix { }; 14in 15stdenv.mkDerivation { 16 pname = "swift-corelibs-xctest"; 17 18 inherit (sources) version; 19 src = sources.swift-corelibs-xctest; 20 21 outputs = [ "out" ]; 22 23 nativeBuildInputs = [ 24 cmake 25 ninja 26 swift 27 ] 28 ++ lib.optional stdenv.hostPlatform.isDarwin DarwinTools; # sw_vers 29 buildInputs = [ Foundation ]; 30 31 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' 32 # On Darwin only, Swift uses arm64 as cpu arch. 33 substituteInPlace cmake/modules/SwiftSupport.cmake \ 34 --replace '"aarch64" PARENT_SCOPE' '"arm64" PARENT_SCOPE' 35 ''; 36 37 preConfigure = '' 38 # On aarch64-darwin, our minimum target is 11.0, but we can target lower, 39 # and some dependants require a lower target. Harmless on non-Darwin. 40 export MACOSX_DEPLOYMENT_TARGET=10.12 41 ''; 42 43 cmakeFlags = lib.optional stdenv.hostPlatform.isDarwin "-DUSE_FOUNDATION_FRAMEWORK=ON"; 44 45 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' 46 # Darwin normally uses the Xcode version of XCTest. Installing 47 # swift-corelibs-xctest is probably not officially supported, but we have 48 # no alternative. Fix up the installation here. 49 mv $out/lib/swift/darwin/${swift.swiftArch}/* $out/lib/swift/darwin 50 rmdir $out/lib/swift/darwin/${swift.swiftArch} 51 mv $out/lib/swift/darwin $out/lib/swift/${swift.swiftOs} 52 ''; 53 54 meta = { 55 description = "Framework for writing unit tests in Swift"; 56 homepage = "https://github.com/apple/swift-corelibs-xctest"; 57 platforms = lib.platforms.all; 58 license = lib.licenses.asl20; 59 teams = [ lib.teams.swift ]; 60 }; 61}