2022-07-25 19:45:15 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2022-11-15 12:05:58 +00:00
|
|
|
, callPackage
|
2022-07-25 19:45:15 +00:00
|
|
|
, cmake
|
|
|
|
, ninja
|
|
|
|
, swift
|
|
|
|
, Foundation
|
|
|
|
, DarwinTools
|
|
|
|
}:
|
|
|
|
|
2022-11-15 12:05:58 +00:00
|
|
|
let
|
|
|
|
sources = callPackage ../sources.nix { };
|
|
|
|
in stdenv.mkDerivation {
|
2022-07-25 19:45:15 +00:00
|
|
|
pname = "swift-corelibs-xctest";
|
|
|
|
|
2022-11-15 12:05:58 +00:00
|
|
|
inherit (sources) version;
|
|
|
|
src = sources.swift-corelibs-xctest;
|
2022-07-25 19:45:15 +00:00
|
|
|
|
|
|
|
outputs = [ "out" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ninja swift ]
|
2024-09-24 15:50:49 +00:00
|
|
|
++ lib.optional stdenv.hostPlatform.isDarwin DarwinTools; # sw_vers
|
2022-07-25 19:45:15 +00:00
|
|
|
buildInputs = [ Foundation ];
|
|
|
|
|
2024-09-24 15:50:49 +00:00
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
2022-07-25 19:45:15 +00:00
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
2024-09-24 15:50:49 +00:00
|
|
|
cmakeFlags = lib.optional stdenv.hostPlatform.isDarwin "-DUSE_FOUNDATION_FRAMEWORK=ON";
|
2022-07-25 19:45:15 +00:00
|
|
|
|
2024-09-24 15:50:49 +00:00
|
|
|
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
2022-07-25 19:45:15 +00:00
|
|
|
# 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;
|
2024-07-17 16:13:06 +00:00
|
|
|
maintainers = lib.teams.swift.members;
|
2022-07-25 19:45:15 +00:00
|
|
|
};
|
|
|
|
}
|