Skip to content

Commit

Permalink
cpptrace: init at 0.6.2 (NixOS#316008)
Browse files Browse the repository at this point in the history
  • Loading branch information
FliegendeWurst authored Dec 23, 2024
2 parents b9c3779 + 79f4ac2 commit 403eb36
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkgs/by-name/cp/cpptrace/findpackage-integration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
stdenv,
lib,
cmake,
cpptrace,
src,
checkOutput,
}:

stdenv.mkDerivation (finalAttrs: {
name = "cpptrace-findpackage-integration-test";

inherit src;

nativeBuildInputs = [ cmake ];
buildInputs = [ cpptrace ];

installPhase = ''
runHook preInstall
mkdir -p $out/bin
install main $out/bin
runHook postInstall
'';

doInstallCheck = true;

installCheckPhase = lib.strings.concatLines (
[ "$out/bin/main" ]
# Check that the backtrace contains the path to the executable.
++ lib.optionals (checkOutput) [

Check failure on line 30 in pkgs/by-name/cp/cpptrace/findpackage-integration.nix

View workflow job for this annotation

GitHub Actions / exp-nixf-tidy-check

parse-redundant-paren

redundant parentheses
''
if [[ !(`$out/bin/main 2>&1` =~ "${finalAttrs.name}") ]]; then
echo "ERROR: $out/bin/main does not output '${finalAttrs.name}'"
exit 1
fi
''
]
);
})
61 changes: 61 additions & 0 deletions pkgs/by-name/cp/cpptrace/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
pkg-config,
libdwarf,
gtest,
callPackage,
zstd,
static ? stdenv.hostPlatform.isStatic,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "cpptrace";
version = "0.6.2";

src = fetchFromGitHub {
owner = "jeremy-rifkin";
repo = "cpptrace";
rev = "v${finalAttrs.version}";
hash = "sha256-zjPxPtq+OQ104sJoeBD3jpMV9gV57FSHEJS4W6SF8GM=";
};

nativeBuildInputs = [
cmake
pkg-config
];

buildInputs = [ libdwarf ];
propagatedBuildInputs = [ zstd ];

cmakeFlags = [
(lib.cmakeBool "CPPTRACE_USE_EXTERNAL_LIBDWARF" true)
(lib.cmakeBool "CPPTRACE_FIND_LIBDWARF_WITH_PKGCONFIG" true)
(lib.cmakeBool "BUILD_SHARED_LIBS" (!static))
(lib.cmakeBool "BUILD_TESTING" finalAttrs.finalPackage.doCheck)
(lib.cmakeBool "CPPTRACE_USE_EXTERNAL_GTEST" true)
];

checkInputs = [ gtest ];

# Unit tests are flaky and hard to get right.
doCheck = false;

passthru.tests = {
findpackage-integration = callPackage ./findpackage-integration.nix {
src = "${finalAttrs.src}/test/findpackage-integration";
checkOutput = finalAttrs.finalPackage.doCheck;
};
};

meta = {
changelog = "https://github.com/jeremy-rifkin/cpptrace/releases/tag/v${finalAttrs.version}";
description = "Simple, portable, and self-contained stacktrace library for C++11 and newer";
homepage = "https://github.com/jeremy-rifkin/cpptrace";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ xokdvium ];
platforms = lib.platforms.all;
};
})

0 comments on commit 403eb36

Please sign in to comment.