Skip to content

Commit

Permalink
scs: Fix darwin build
Browse files Browse the repository at this point in the history
Additionally we make the unit-test deterministic by specifying a seed
instead of using something random.

(cherry picked from commit d726c0f)
  • Loading branch information
knedlsepp authored and LnL7 committed Sep 12, 2018
1 parent 088e1bd commit 84361ab
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions pkgs/development/libraries/science/math/scs/default.nix
@@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, blas, liblapack, gfortran }:
{ stdenv, fetchFromGitHub, blas, liblapack, gfortran, fixDarwinDylibNames }:

stdenv.mkDerivation rec {
name = "scs-${version}";
Expand All @@ -11,24 +11,30 @@ stdenv.mkDerivation rec {
sha256 = "17lbcmcsniqlyzgbzmjipfd0rrk25a8hzh7l5wl2wp1iwsd8c3a9";
};

buildInputs = [ blas liblapack gfortran.cc.lib ];

# Actually link and add libgfortran to the rpath
patchPhase = ''
sed -i 's/#-lgfortran/-lgfortran/' scs.mk
postPatch = ''
substituteInPlace scs.mk \
--replace "#-lgfortran" "-lgfortran" \
--replace "gcc" "cc"
'';

nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;

buildInputs = [ blas liblapack gfortran.cc.lib ];

doCheck = true;

# Test demo requires passing any int as $1; 42 chosen arbitrarily
checkPhase = ''
./out/demo_socp_indirect 42
# Test demo requires passing data and seed; numbers chosen arbitrarily.
postCheck = ''
./out/demo_socp_indirect 42 0.42 0.42 42
'';

installPhase = ''
runHook preInstall
mkdir -p $out/lib
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; {
Expand Down

0 comments on commit 84361ab

Please sign in to comment.