2018-06-24 12:59:48 +00:00
|
|
|
{ stdenv, fetchFromGitHub, fetchurl, fetchpatch
|
|
|
|
, ocaml, findlib, ocamlbuild, ocaml_oasis,
|
2018-07-21 00:44:44 +00:00
|
|
|
bitstring, camlzip, cmdliner, core_kernel, ezjsonm, faillib, fileutils, ocaml_lwt, ocamlgraph, ocurl, re, uri, zarith, piqi, piqi-ocaml, uuidm, llvm_38, frontc, ounit, ppx_jane, parsexp,
|
2018-03-01 17:10:41 +00:00
|
|
|
utop,
|
2018-06-24 12:59:48 +00:00
|
|
|
which, makeWrapper, writeText
|
|
|
|
}:
|
2017-01-25 07:08:03 +00:00
|
|
|
|
2018-06-24 12:59:48 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "ocaml${ocaml.version}-bap-${version}";
|
2018-03-01 17:10:41 +00:00
|
|
|
version = "1.4.0";
|
2017-01-25 07:08:03 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "BinaryAnalysisPlatform";
|
|
|
|
repo = "bap";
|
|
|
|
rev = "v${version}";
|
2018-03-01 17:10:41 +00:00
|
|
|
sha256 = "0329m65x8q5q8vgvsqgyz2vz7q6qkh2rh11j7x29hckk3fzxsf8g";
|
2017-01-25 07:08:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sigs = fetchurl {
|
|
|
|
url = "https://github.com/BinaryAnalysisPlatform/bap/releases/download/v${version}/sigs.zip";
|
2018-03-01 17:10:41 +00:00
|
|
|
sha256 = "0k761w82zkmi5dwsfqq61dbjnb8mmmpb2xwp7vp85xs14g5fjz19";
|
2017-01-25 07:08:03 +00:00
|
|
|
};
|
|
|
|
|
2018-06-24 12:59:48 +00:00
|
|
|
patches = [(fetchpatch {
|
|
|
|
url = "https://github.com/BinaryAnalysisPlatform/bap/commit/e4ee3a1e5b427e8d8991e7462b06123178c0a046.patch";
|
|
|
|
sha256 = "1yq33zd2sdacclr20g05c1q050m7x7vfbl66qdgansh23dr4fnxk";
|
|
|
|
})];
|
|
|
|
|
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/"
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [ which makeWrapper ];
|
|
|
|
|
2018-06-24 12:59:48 +00:00
|
|
|
buildInputs = [ ocaml findlib ocamlbuild ocaml_oasis
|
2017-01-25 07:08:03 +00:00
|
|
|
llvm_38
|
|
|
|
utop ];
|
|
|
|
|
2018-03-01 17:10:41 +00:00
|
|
|
propagatedBuildInputs = [ bitstring camlzip cmdliner ppx_jane core_kernel ezjsonm faillib 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:$OCAMLFIND_DESTDIR/bap-plugin-llvm/:$OCAMLFIND_DESTDIR/bap/
|
|
|
|
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 --disable-fsi-benchmark";
|
|
|
|
|
2018-07-25 21:44:21 +00:00
|
|
|
configureFlags = [ "--enable-everything ${disableIda}" "--with-llvm-config=${llvm_38}/bin/llvm-config" ];
|
2017-01-25 07:08:03 +00:00
|
|
|
|
|
|
|
BAPBUILDFLAGS = "-j $(NIX_BUILD_CORES)";
|
|
|
|
|
|
|
|
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/;
|
|
|
|
maintainers = [ maintainers.maurer ];
|
|
|
|
license = licenses.mit;
|
2018-03-01 17:10:41 +00:00
|
|
|
broken = versionOlder ocaml.version "4.03";
|
2017-01-25 07:08:03 +00:00
|
|
|
};
|
|
|
|
}
|