pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / by-name / bl / bloaty / package.nix
blobfab4550cbdb00ef3735541e6ebc838bce1c57040
2   lib,
3   stdenv,
4   cmake,
5   zlib,
6   fetchFromGitHub,
7   re2,
8   abseil-cpp,
9   protobuf,
10   capstone,
11   gtest,
12   pkg-config,
13   lit,
14   llvmPackages_16,
16 let
17   # Old vendored package which has no other use than here, so not packaged in nixpkgs.
18   demumble = fetchFromGitHub {
19     owner = "nico";
20     repo = "demumble";
21     rev = "01098eab821b33bd31b9778aea38565cd796aa85";
22     hash = "sha256-605SsXd7TSdm3BH854ChHIZbOXcHI/n8RN+pFMz4Ex4=";
23   };
25 stdenv.mkDerivation {
26   pname = "bloaty";
27   version = "1.1-unstable-2024-09-23";
29   src = fetchFromGitHub {
30     owner = "google";
31     repo = "bloaty";
32     rev = "0c89acd7e8b9d91fd1e9c8c129be627b4e47f1ea";
33     hash = "sha256-txZDPytWnkjkiVkPL2SWLwCPEtVvqoI/MVRvbJ2kBGw=";
34   };
36   cmakeFlags = [
37     "-DLIT_EXECUTABLE=${lit}/bin/lit"
38     "-DFILECHECK_EXECUTABLE=${llvmPackages_16.libllvm}/bin/FileCheck"
39     "-DYAML2OBJ_EXECUTABLE=${llvmPackages_16.libllvm}/bin/yaml2obj"
40   ];
42   postPatch = ''
43     # Build system relies on some of those source files
44     rm -rf third_party/googletest third_party/abseil-cpp third_party/demumble
45     ln -s ${gtest.src} third_party/googletest
46     ln -s ${abseil-cpp.src} third_party/abseil-cpp
47     ln -s ${demumble} third_party/demumble
48     substituteInPlace CMakeLists.txt \
49       --replace "find_package(Python COMPONENTS Interpreter)" "" \
50       --replace "if(Python_FOUND AND LIT_EXECUTABLE" "if(LIT_EXECUTABLE" \
51       --replace "COMMAND \''\${Python_EXECUTABLE} \''\${LIT_EXECUTABLE}" "COMMAND \''\${LIT_EXECUTABLE}"
52     # wasm test fail. Possibly due to LLVM version < 17. See https://github.com/google/bloaty/pull/354
53     rm -rf tests/wasm
54   '';
56   nativeBuildInputs = [
57     cmake
58     pkg-config
59   ];
61   buildInputs = [
62     zlib
63     re2
64     abseil-cpp
65     protobuf
66     capstone
67     gtest
68     lit
69     llvmPackages_16.libllvm
70   ];
72   doCheck = true;
74   postCheck = ''
75     # These lit tests need to be build seperatly.
76     # See https://github.com/google/bloaty/blob/main/tests/README.md
77     cmake --build . --target check-bloaty
78   '';
79   installPhase = ''
80     install -Dm755 {.,$out/bin}/bloaty
81   '';
83   meta = {
84     description = "Size profiler for binaries";
85     mainProgram = "bloaty";
86     homepage = "https://github.com/google/bloaty";
87     license = lib.licenses.asl20;
88     platforms = lib.platforms.unix;
89     maintainers = with lib.maintainers; [ momeemt ];
90   };