2021-02-13 14:23:35 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, python
|
|
|
|
, fixDarwinDylibNames
|
2020-08-20 17:08:02 +00:00
|
|
|
, javaBindings ? false
|
2020-10-07 09:15:18 +00:00
|
|
|
, ocamlBindings ? false
|
2020-08-20 17:08:02 +00:00
|
|
|
, pythonBindings ? true
|
|
|
|
, jdk ? null
|
2021-02-13 14:23:35 +00:00
|
|
|
, ocaml ? null
|
|
|
|
, findlib ? null
|
|
|
|
, zarith ? null
|
2022-01-03 16:56:52 +00:00
|
|
|
, writeScript
|
2020-08-20 17:08:02 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert javaBindings -> jdk != null;
|
2020-10-07 09:15:18 +00:00
|
|
|
assert ocamlBindings -> ocaml != null && findlib != null && zarith != null;
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
let common = { version, sha256, patches ? [ ], tag ? "z3" }:
|
2022-04-15 01:41:22 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "z3";
|
|
|
|
inherit version sha256 patches;
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Z3Prover";
|
|
|
|
repo = pname;
|
2023-03-04 12:14:45 +00:00
|
|
|
rev = "${tag}-${version}";
|
2022-04-15 01:41:22 +00:00
|
|
|
sha256 = sha256;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ python ]
|
|
|
|
++ optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames
|
2022-04-15 01:41:22 +00:00
|
|
|
++ optional javaBindings jdk
|
2023-02-09 11:40:11 +00:00
|
|
|
++ optionals ocamlBindings [ ocaml findlib ]
|
2022-04-15 01:41:22 +00:00
|
|
|
;
|
2023-02-09 11:40:11 +00:00
|
|
|
propagatedBuildInputs = [ python.pkgs.setuptools ]
|
|
|
|
++ optionals ocamlBindings [ zarith ];
|
2022-04-15 01:41:22 +00:00
|
|
|
enableParallelBuilding = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
postPatch = optionalString ocamlBindings ''
|
|
|
|
export OCAMLFIND_DESTDIR=$ocaml/lib/ocaml/${ocaml.version}/site-lib
|
|
|
|
mkdir -p $OCAMLFIND_DESTDIR/stublibs
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
configurePhase = concatStringsSep " "
|
|
|
|
(
|
2023-03-04 12:14:45 +00:00
|
|
|
[ "${python.pythonForBuild.interpreter} scripts/mk_make.py --prefix=$out" ]
|
2022-04-15 01:41:22 +00:00
|
|
|
++ optional javaBindings "--java"
|
|
|
|
++ optional ocamlBindings "--ml"
|
|
|
|
++ optional pythonBindings "--python --pypkgdir=$out/${python.sitePackages}"
|
|
|
|
) + "\n" + "cd build";
|
2022-01-03 16:56:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
make test
|
|
|
|
./test-z3 -a
|
|
|
|
'';
|
2022-01-03 16:56:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $dev $lib
|
|
|
|
mv $out/lib $lib/lib
|
|
|
|
mv $out/include $dev/include
|
|
|
|
'' + optionalString pythonBindings ''
|
|
|
|
mkdir -p $python/lib
|
|
|
|
mv $lib/lib/python* $python/lib/
|
|
|
|
ln -sf $lib/lib/libz3${stdenv.hostPlatform.extensions.sharedLibrary} $python/${python.sitePackages}/z3/lib/libz3${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
'' + optionalString javaBindings ''
|
|
|
|
mkdir -p $java/share/java
|
|
|
|
mv com.microsoft.z3.jar $java/share/java
|
|
|
|
moveToOutput "lib/libz3java.${stdenv.hostPlatform.extensions.sharedLibrary}" "$java"
|
2022-01-03 16:56:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
outputs = [ "out" "lib" "dev" "python" ]
|
|
|
|
++ optional javaBindings "java"
|
|
|
|
++ optional ocamlBindings "ocaml";
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A high-performance theorem prover and SMT solver";
|
|
|
|
homepage = "https://github.com/Z3Prover/z3";
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice ttuegel ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2022-09-09 14:08:57 +00:00
|
|
|
z3_4_11 = common {
|
|
|
|
version = "4.11.0";
|
|
|
|
sha256 = "sha256-ItmtZHDhCeLAVtN7K80dqyAh20o7TM4xk2sTb9QgHvk=";
|
|
|
|
};
|
2022-04-15 01:41:22 +00:00
|
|
|
z3_4_8 = common {
|
|
|
|
version = "4.8.15";
|
|
|
|
sha256 = "0xkwqz0y5d1lfb6kfqy8wn8n2dqalzf4c8ghmjsajc1bpdl70yc5";
|
|
|
|
};
|
2023-03-04 12:14:45 +00:00
|
|
|
z3_4_8_5 = common {
|
|
|
|
tag = "Z3";
|
|
|
|
version = "4.8.5";
|
|
|
|
sha256 = "sha256-ytG5O9HczbIVJAiIGZfUXC/MuYH7d7yLApaeTRlKXoc=";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|