|
| 1 | +{ stdenv, fetchzip, boost, cmake, ncurses, python2 |
| 2 | +, z3Support ? true, z3 ? null, cvc4Support ? true, cvc4 ? null |
| 3 | +, cln ? null, gmp ? null |
| 4 | +}: |
| 5 | + |
| 6 | +assert z3Support -> z3 != null && stdenv.lib.versionAtLeast z3.version "4.6.0"; |
| 7 | +assert cvc4Support -> cvc4 != null && cln != null && gmp != null; |
| 8 | + |
| 9 | +let |
| 10 | + jsoncppURL = https://github.com/open-source-parsers/jsoncpp/archive/1.8.4.tar.gz; |
| 11 | + jsoncpp = fetchzip { |
| 12 | + url = jsoncppURL; |
| 13 | + sha256 = "1z0gj7a6jypkijmpknis04qybs1hkd04d1arr3gy89lnxmp6qzlm"; |
| 14 | + }; |
| 15 | + buildSharedLibs = stdenv.hostPlatform.isLinux; |
| 16 | +in |
| 17 | +stdenv.mkDerivation rec { |
| 18 | + |
| 19 | + pname = "solc"; |
| 20 | + version = "0.5.11"; |
| 21 | + |
| 22 | + # upstream suggests avoid using archive generated by github |
| 23 | + src = fetchzip { |
| 24 | + url = "https://github.com/ethereum/solidity/releases/download/v${version}/solidity_${version}.tar.gz"; |
| 25 | + sha256 = "0679s5pqbfy7fgpb4f3ppgj8iafxb64g046v8vhp29mf3dsdcnyl"; |
| 26 | + }; |
| 27 | + |
| 28 | + patches = stdenv.lib.optionals buildSharedLibs [ ./patches/shared-libs-install.patch ]; |
| 29 | + |
| 30 | + postPatch = '' |
| 31 | + substituteInPlace cmake/jsoncpp.cmake \ |
| 32 | + --replace "${jsoncppURL}" ${jsoncpp} |
| 33 | + ''; |
| 34 | + |
| 35 | + cmakeFlags = [ |
| 36 | + "-DBoost_USE_STATIC_LIBS=OFF" |
| 37 | + ] ++ stdenv.lib.optionals buildSharedLibs [ |
| 38 | + "-DBUILD_SHARED_LIBS=ON" |
| 39 | + ] ++ stdenv.lib.optionals (!z3Support) [ |
| 40 | + "-DUSE_Z3=OFF" |
| 41 | + ] ++ stdenv.lib.optionals (!cvc4Support) [ |
| 42 | + "-DUSE_CVC4=OFF" |
| 43 | + ]; |
| 44 | + |
| 45 | + nativeBuildInputs = [ cmake ]; |
| 46 | + buildInputs = [ boost ] |
| 47 | + ++ stdenv.lib.optionals z3Support [ z3 ] |
| 48 | + ++ stdenv.lib.optionals cvc4Support [ cvc4 cln gmp ]; |
| 49 | + checkInputs = [ ncurses python2 ]; |
| 50 | + |
| 51 | + # Test fails on darwin for unclear reason |
| 52 | + doCheck = stdenv.hostPlatform.isLinux; |
| 53 | + |
| 54 | + checkPhase = '' |
| 55 | + while IFS= read -r -d ''' dir |
| 56 | + do |
| 57 | + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$dir |
| 58 | + export LD_LIBRARY_PATH |
| 59 | + done < <(find . -type d -print0) |
| 60 | +
|
| 61 | + pushd .. |
| 62 | + # IPC tests need aleth avaliable, so we disable it |
| 63 | + sed -i "s/IPC_ENABLED=true/IPC_ENABLED=false\nIPC_FLAGS=\"--no-ipc\"/" ./scripts/tests.sh |
| 64 | + for i in ./scripts/*.sh; do |
| 65 | + patchShebangs "$i" |
| 66 | + done |
| 67 | + for i in ./scripts/*.py; do |
| 68 | + patchShebangs "$i" |
| 69 | + done |
| 70 | + for i in ./test/*.sh; do |
| 71 | + patchShebangs "$i" |
| 72 | + done |
| 73 | + TERM=xterm ./scripts/tests.sh |
| 74 | + popd |
| 75 | + ''; |
| 76 | + |
| 77 | + outputs = [ "out" "dev" ]; |
| 78 | + |
| 79 | + meta = with stdenv.lib; { |
| 80 | + description = "Compiler for Ethereum smart contract language Solidity"; |
| 81 | + homepage = https://github.com/ethereum/solidity; |
| 82 | + license = licenses.gpl3; |
| 83 | + platforms = with platforms; linux ++ darwin; |
| 84 | + maintainers = with maintainers; [ dbrock akru lionello sifmelcara ]; |
| 85 | + inherit version; |
| 86 | + }; |
| 87 | +} |
0 commit comments