Merge pull request #309718 from Sigmanificient/cdecl-adopt

cdecl: adopt, migrate to by-name, reformat, modernize, update source, 2.5 -> 2.5-unstable-2024-05-07, add check phase
This commit is contained in:
Weijia Wang 2024-05-09 20:20:01 +02:00 committed by GitHub
commit 2f67b8ef60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 92 additions and 28 deletions

View file

@ -0,0 +1,82 @@
{
lib,
stdenv,
fetchFromGitHub,
bison,
flex,
readline,
ncurses,
}:
stdenv.mkDerivation {
pname = "cdecl";
version = "2.5-unstable-2024-05-07";
src = fetchFromGitHub {
owner = "ridiculousfish";
repo = "cdecl-blocks";
rev = "1e6e1596771183d9bb90bcf152d6bc2055219a7e";
hash = "sha256-5XuiYkFe+QvVBRIXRieKoE0zbISMvU1iLgEfkw6GnlE=";
};
patches = [
./cdecl-2.5-lex.patch
# when `USE_READLINE` is enabled, this option will not be present
./test_remove_interactive_line.patch
];
prePatch = ''
substituteInPlace cdecl.c \
--replace 'getline' 'cdecl_getline'
'';
strictDeps = true;
nativeBuildInputs = [
bison
flex
];
buildInputs = [
readline
ncurses
];
env = {
NIX_CFLAGS_COMPILE = toString (
[
"-DBSD"
"-DUSE_READLINE"
]
++ lib.optionals stdenv.cc.isClang [
"-Wno-error=int-conversion"
"-Wno-error=incompatible-function-pointer-types"
]
);
NIX_LDFLAGS = "-lreadline";
};
makeFlags = [
"CC=${stdenv.cc.targetPrefix}cc"
"PREFIX=${placeholder "out"}"
"BINDIR=${placeholder "out"}/bin"
"MANDIR=${placeholder "out"}/man1"
"CATDIR=${placeholder "out"}/cat1"
];
doCheck = true;
checkTarget = "test";
preInstall = ''
mkdir -p $out/bin;
'';
meta = {
description = "Translator English -- C/C++ declarations";
homepage = "https://cdecl.org";
license = lib.licenses.publicDomain;
maintainers = with lib.maintainers; [ sigmanificient ];
platforms = lib.platforms.unix;
mainProgram = "cdecl";
};
}

View file

@ -0,0 +1,10 @@
--- a/test_expected_output.txt 2024-05-07 05:47:13.184419240 +0200
+++ b/test_expected_output.txt 2024-05-07 05:48:38.980122345 +0200
@@ -26,7 +26,6 @@
options
create (-c), nocreate
prompt, noprompt (-q)
- interactive (-i), nointeractive
ritchie (-r), preansi (-p), ansi (-a) or cplusplus (-+)
Current set values are:

View file

@ -1,26 +0,0 @@
{lib, stdenv, fetchurl, bison, flex, readline, ncurses, gnused}:
stdenv.mkDerivation rec {
pname = "cdecl";
version = "2.5";
src = fetchurl {
url = "https://www.cdecl.org/files/${pname}-blocks-${version}.tar.gz";
sha256 = "1b7k0ra30hh8mg8fqv0f0yzkaac6lfg6n376drgbpxg4wwml1rly";
};
patches = [ ./cdecl-2.5-lex.patch ];
preBuild = ''
${gnused}/bin/sed 's/getline/cdecl_getline/g' -i cdecl.c;
makeFlagsArray=(CFLAGS="-DBSD -DUSE_READLINE -std=gnu89" LIBS=-lreadline);
makeFlags="$makeFlags PREFIX=$out BINDIR=$out/bin MANDIR=$out/man1 CATDIR=$out/cat1 CC=$CC";
mkdir -p $out/bin;
'';
buildInputs = [bison flex readline ncurses];
meta = {
description = "Translator English -- C/C++ declarations";
license = lib.licenses.publicDomain;
maintainers = with lib.maintainers; [ ];
platforms = lib.platforms.unix;
};
}

View file

@ -6608,8 +6608,6 @@ with pkgs;
ccze = callPackage ../tools/misc/ccze { };
cdecl = callPackage ../development/tools/cdecl { };
cdi2iso = callPackage ../tools/cd-dvd/cdi2iso { };
cdist = python3Packages.callPackage ../tools/admin/cdist { };