From c20eff42cfbc5d0c83135dc35020467760c77739 Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Thu, 23 Nov 2023 22:54:48 +0100 Subject: [PATCH] bloaty: devendor git submodules Signed-off-by: Florian Brandes Co-authored-by: Sandro --- pkgs/development/tools/bloaty/default.nix | 43 +++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/pkgs/development/tools/bloaty/default.nix b/pkgs/development/tools/bloaty/default.nix index 738384e28a97..96a6d28e9787 100644 --- a/pkgs/development/tools/bloaty/default.nix +++ b/pkgs/development/tools/bloaty/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, cmake, zlib, fetchFromGitHub }: +{ lib, stdenv, cmake, zlib, fetchFromGitHub, re2, abseil-cpp, protobuf, capstone, gtest, pkg-config, lit, llvmPackages_16 }: stdenv.mkDerivation rec { pname = "bloaty"; @@ -7,18 +7,49 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "google"; repo = "bloaty"; - # no version since 1.1 in 2020 rev = "16f9fe54d9cd0e9abe1d25fc1a9b44c214cfaa9f"; - hash = "sha256-w855aSLzzvuUWjAU9zOKuZTNGLZiEKMJYjVGejH48xQ="; - fetchSubmodules = true; + hash = "sha256-mIVlNMKtJMfH2QdYZ6+oV7619oYzvKkq3fHY6uofqlM="; }; - nativeBuildInputs = [ cmake ]; + # Old vendored package which has no other use than here, so not packaged in nixpkgs. + demumble = fetchFromGitHub { + owner = "nico"; + repo = "demumble"; + rev = "01098eab821b33bd31b9778aea38565cd796aa85"; + hash = "sha256-605SsXd7TSdm3BH854ChHIZbOXcHI/n8RN+pFMz4Ex4="; + }; - buildInputs = [ zlib ]; + cmakeFlags = [ + "-DLIT_EXECUTABLE=${lit}/bin/lit" + "-DFILECHECK_EXECUTABLE=${llvmPackages_16.libllvm}/bin/FileCheck" + "-DYAML2OBJ_EXECUTABLE=${llvmPackages_16.libllvm}/bin/yaml2obj" + ]; + + postPatch = '' + # Build system relies on some of those source files + rm -rf third_party/googletest third_party/abseil-cpp third_party/demumble + ln -s ${gtest.src} third_party/googletest + ln -s ${abseil-cpp.src} third_party/abseil-cpp + ln -s ${demumble} third_party/demumble + substituteInPlace CMakeLists.txt \ + --replace "find_package(Python COMPONENTS Interpreter)" "" \ + --replace "if(Python_FOUND AND LIT_EXECUTABLE" "if(LIT_EXECUTABLE" \ + --replace "COMMAND \''\${Python_EXECUTABLE} \''\${LIT_EXECUTABLE}" "COMMAND \''\${LIT_EXECUTABLE}" + # wasm test fail. Possibly due to LLVM version < 17. See https://github.com/google/bloaty/pull/354 + rm -rf tests/wasm + ''; + + nativeBuildInputs = [ cmake pkg-config ]; + + buildInputs = [ zlib re2 abseil-cpp protobuf capstone gtest lit llvmPackages_16.libllvm ]; doCheck = true; + postCheck = '' + # These lit tests need to be build seperatly. + # See https://github.com/google/bloaty/blob/main/tests/README.md + cmake --build . --target check-bloaty + ''; installPhase = '' install -Dm755 {.,$out/bin}/bloaty '';