3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/ocaml-modules/bap/default.nix

80 lines
3 KiB
Nix
Raw Normal View History

{ stdenv, fetchFromGitHub, fetchurl
, ocaml, findlib, ocamlbuild, ocaml_oasis
, bitstring, camlzip, cmdliner, core_kernel, ezjsonm, fileutils, ocaml_lwt, ocamlgraph, ocurl, re, uri, zarith, piqi, piqi-ocaml, uuidm, llvm, frontc, ounit, ppx_jane, parsexp
, utop, libxml2, ncurses
, ppx_bitstring
, ppx_tools_versioned
, which, makeWrapper, writeText
2020-10-02 06:44:56 +01:00
, z3
}:
2017-01-25 07:08:03 +00:00
2020-10-02 06:44:56 +01:00
if !stdenv.lib.versionAtLeast ocaml.version "4.07"
then throw "BAP is not available for OCaml ${ocaml.version}"
else
if stdenv.lib.versionAtLeast core_kernel.version "0.13"
then throw "BAP needs core_kernel-0.12 (hence OCaml 4.07)"
else
stdenv.mkDerivation rec {
name = "ocaml${ocaml.version}-bap-${version}";
2020-10-02 06:44:56 +01:00
version = "2.1.0";
2017-01-25 07:08:03 +00:00
src = fetchFromGitHub {
owner = "BinaryAnalysisPlatform";
repo = "bap";
rev = "v${version}";
2020-10-02 06:44:56 +01:00
sha256 = "10fkr6p798ad18j4h9bvp9dg4pmjdpv3hmj7k389i0vhqniwi5xq";
2017-01-25 07:08:03 +00:00
};
sigs = fetchurl {
url = "https://github.com/BinaryAnalysisPlatform/bap/releases/download/v${version}/sigs.zip";
sha256 = "0d69jd28z4g64mglq94kj5imhmk5f6sgcsh9q2nij3b0arpcliwk";
2017-01-25 07:08:03 +00:00
};
createFindlibDestdir = true;
setupHook = writeText "setupHook.sh" ''
export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/${name}/"
export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/${name}-llvm-plugins/"
2017-01-25 07:08:03 +00:00
'';
nativeBuildInputs = [ which makeWrapper ];
buildInputs = [ ocaml findlib ocamlbuild ocaml_oasis
llvm ppx_bitstring ppx_tools_versioned
2020-10-02 06:44:56 +01:00
z3
utop libxml2 ncurses ];
2017-01-25 07:08:03 +00:00
propagatedBuildInputs = [ bitstring camlzip cmdliner ppx_jane core_kernel ezjsonm fileutils ocaml_lwt ocamlgraph ocurl re uri zarith piqi parsexp
2017-01-25 07:08:03 +00:00
piqi-ocaml uuidm frontc ounit ];
installPhase = ''
export OCAMLPATH=$OCAMLPATH:$OCAMLFIND_DESTDIR;
export PATH=$PATH:$out/bin
export CAML_LD_LIBRARY_PATH=''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}$OCAMLFIND_DESTDIR/bap-plugin-llvm/:$OCAMLFIND_DESTDIR/bap/
2017-01-25 07:08:03 +00:00
mkdir -p $out/lib/bap
make install
rm $out/bin/baptop
makeWrapper ${utop}/bin/utop $out/bin/baptop --prefix OCAMLPATH : $OCAMLPATH --prefix PATH : $PATH --add-flags "-ppx ppx-bap -short-paths -require \"bap.top\""
wrapProgram $out/bin/bapbuild --prefix OCAMLPATH : $OCAMLPATH --prefix PATH : $PATH
ln -s $sigs $out/share/bap/sigs.zip
'';
disableIda = "--disable-ida";
patches = [ ./curses_is_ncurses.patch ];
2017-01-25 07:08:03 +00:00
preConfigure = ''
substituteInPlace oasis/elf --replace bitstring.ppx ppx_bitstring
'';
2019-09-03 20:26:27 +01:00
configureFlags = [ "--enable-everything ${disableIda}" "--with-llvm-config=${llvm}/bin/llvm-config" ];
2017-01-25 07:08:03 +00:00
meta = with stdenv.lib; {
description = "Platform for binary analysis. It is written in OCaml, but can be used from other languages.";
homepage = "https://github.com/BinaryAnalysisPlatform/bap/";
2017-01-25 07:08:03 +00:00
maintainers = [ maintainers.maurer ];
license = licenses.mit;
};
}