1{ lib, stdenv, buildPythonApplication, pkgsBuildTarget, python, minijail }:
2
3let
4 targetClang = pkgsBuildTarget.targetPackages.clangStdenv.cc;
5in
6
7buildPythonApplication {
8 pname = "minijail-tools";
9 inherit (minijail) version src;
10
11 postPatch = ''
12 substituteInPlace Makefile --replace /bin/echo echo
13 '';
14
15 postConfigure = ''
16 substituteInPlace tools/compile_seccomp_policy.py \
17 --replace "'constants.json'" "'$out/share/constants.json'"
18 '';
19
20 preBuild = ''
21 make libconstants.gen.c libsyscalls.gen.c
22 ${targetClang}/bin/${targetClang.targetPrefix}cc -S -emit-llvm \
23 libconstants.gen.c libsyscalls.gen.c
24 ${python.pythonForBuild.interpreter} tools/generate_constants_json.py \
25 --output constants.json \
26 libconstants.gen.ll libsyscalls.gen.ll
27 '';
28
29 postInstall = ''
30 mkdir -p $out/share
31 cp -v constants.json $out/share/constants.json
32 '';
33
34 meta = with lib; {
35 homepage = "https://android.googlesource.com/platform/external/minijail/+/refs/heads/master/tools/";
36 description = "A set of tools for minijail";
37 license = licenses.asl20;
38 inherit (minijail.meta) maintainers platforms;
39 };
40}