nixpkgs/pkgs/development/tools/packcc/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
1.8 KiB
Nix
Raw Normal View History

2024-07-13 22:14:25 +02:00
{
bats,
fetchFromGitHub,
lib,
packcc,
python3,
stdenv,
testers,
uncrustify,
2022-09-11 12:36:56 +02:00
}:
stdenv.mkDerivation rec {
pname = "packcc";
2024-07-13 22:14:25 +02:00
version = "2.0.2";
2022-09-11 12:36:56 +02:00
src = fetchFromGitHub {
owner = "arithy";
repo = "packcc";
rev = "v${version}";
2024-07-13 22:14:25 +02:00
hash = "sha256-k1C/thvr/5fYrgu/j8YN3kwXp4k26sC9AhYhYAKQuX0=";
2022-09-11 12:36:56 +02:00
};
2024-07-13 22:14:25 +02:00
postPatch = ''
patchShebangs tests
'';
2022-09-11 12:36:56 +02:00
dontConfigure = true;
preBuild = ''
2024-07-13 22:14:25 +02:00
cd build/${
if stdenv.cc.isGNU then
"gcc"
else if stdenv.cc.isClang then
"clang"
else
throw "Unsupported C compiler"
}
2022-09-11 12:36:56 +02:00
'';
doCheck = true;
2024-07-13 22:14:25 +02:00
nativeCheckInputs = [
bats
uncrustify
python3
];
2022-09-11 12:36:56 +02:00
2024-07-13 22:14:25 +02:00
preCheck =
''
# Style tests will always fail because upstream uses an older version of
# uncrustify.
rm -rf ../../tests/style.d
''
+ lib.optionalString stdenv.cc.isClang ''
export NIX_CFLAGS_COMPILE+=' -Wno-error=strict-prototypes -Wno-error=int-conversion'
'';
2022-09-11 12:36:56 +02:00
installPhase = ''
runHook preInstall
install -Dm755 release/bin/packcc $out/bin/packcc
runHook postInstall
'';
2024-07-13 22:14:25 +02:00
passthru.tests.version = testers.testVersion { package = packcc; };
2022-09-11 12:36:56 +02:00
meta = with lib; {
description = "Parser generator for C";
longDescription = ''
PackCC is a parser generator for C. Its main features are as follows:
- Generates your parser in C from a grammar described in a PEG,
- Gives your parser great efficiency by packrat parsing,
- Supports direct and indirect left-recursive grammar rules.
'';
homepage = "https://github.com/arithy/packcc";
changelog = "https://github.com/arithy/packcc/releases/tag/${src.rev}";
license = licenses.mit;
maintainers = with maintainers; [ azahi ];
platforms = platforms.unix;
2024-07-13 22:14:25 +02:00
mainProgram = "packcc";
2022-09-11 12:36:56 +02:00
};
}