scs: Fix darwin build

Additionally we make the unit-test deterministic by specifying a seed
instead of using something random.
This commit is contained in:
Josef Kemetmüller 2018-09-12 00:17:44 +02:00
parent 8955ec6c73
commit d726c0ff1d

View File

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, blas, liblapack, gfortran }: { stdenv, fetchFromGitHub, blas, liblapack, gfortran, fixDarwinDylibNames }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "scs-${version}"; name = "scs-${version}";
@ -11,24 +11,30 @@ stdenv.mkDerivation rec {
sha256 = "17lbcmcsniqlyzgbzmjipfd0rrk25a8hzh7l5wl2wp1iwsd8c3a9"; sha256 = "17lbcmcsniqlyzgbzmjipfd0rrk25a8hzh7l5wl2wp1iwsd8c3a9";
}; };
buildInputs = [ blas liblapack gfortran.cc.lib ];
# Actually link and add libgfortran to the rpath # Actually link and add libgfortran to the rpath
patchPhase = '' postPatch = ''
sed -i 's/#-lgfortran/-lgfortran/' scs.mk substituteInPlace scs.mk \
--replace "#-lgfortran" "-lgfortran" \
--replace "gcc" "cc"
''; '';
nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
buildInputs = [ blas liblapack gfortran.cc.lib ];
doCheck = true; doCheck = true;
# Test demo requires passing any int as $1; 42 chosen arbitrarily # Test demo requires passing data and seed; numbers chosen arbitrarily.
checkPhase = '' postCheck = ''
./out/demo_socp_indirect 42 ./out/demo_socp_indirect 42 0.42 0.42 42
''; '';
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/lib mkdir -p $out/lib
cp -r include $out/ cp -r include $out/
cp out/*.a out/*.so $out/lib/ cp out/*.a out/*.so out/*.dylib $out/lib/
runHook postInstall
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {