about summary refs log tree commit diff
path: root/pkgs/by-name/cd
diff options
context:
space:
mode:
authorSigmanificient <edhyjox@gmail.com>2024-05-07 05:29:57 +0200
committerWeijia Wang <9713184+wegank@users.noreply.github.com>2024-05-09 18:00:44 +0200
commit11c2265d7e238ba6bad0e3e56f3b42e258b1aed7 (patch)
tree0ef68437fe29cc0019039376bfe68b8e280f7b08 /pkgs/by-name/cd
parentde8d1617da6352748416b5b6317a552ebaad3310 (diff)
cdecl: 2.5 -> 2.5-unstable-2024-05-07, add check, refactor
Jumping almost 8 years ahead, to the repo latest commit

cdecl: add check phase

cdecl: further refactoring
Diffstat (limited to 'pkgs/by-name/cd')
-rw-r--r--pkgs/by-name/cd/cdecl/package.nix48
-rw-r--r--pkgs/by-name/cd/cdecl/test_remove_interactive_line.patch10
2 files changed, 46 insertions, 12 deletions
diff --git a/pkgs/by-name/cd/cdecl/package.nix b/pkgs/by-name/cd/cdecl/package.nix
index 16412a52a3708..016a15e9bea06 100644
--- a/pkgs/by-name/cd/cdecl/package.nix
+++ b/pkgs/by-name/cd/cdecl/package.nix
@@ -10,38 +10,62 @@
 
 stdenv.mkDerivation {
   pname = "cdecl";
-  version = "2.5";
+  version = "2.5-unstable-2024-05-07";
 
   src = fetchFromGitHub {
     owner = "ridiculousfish";
     repo = "cdecl-blocks";
-    # github repo has no tag, but the 2.5 version match this commit
-    rev = "cb130ea7e61df5b6fa1e84f996e3f04e21a0181c";
-    hash = "sha256-lErAxTpPIT49QdOpdjM9e3Qyaajzc+iwv27B3XUFUuE=";
+    rev = "1e6e1596771183d9bb90bcf152d6bc2055219a7e";
+    hash = "sha256-5XuiYkFe+QvVBRIXRieKoE0zbISMvU1iLgEfkw6GnlE=";
   };
 
-  buildInputs = [
+  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
   ];
 
-  NIX_CFLAGS_COMPILE = "-DBSD -DUSE_READLINE -std=gnu89";
-  NIX_LDFLAGS = "-lreadline";
+  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}/bin/cc" # otherwise fails on x86_64-darwin
+    "CC=${stdenv.cc.targetPrefix}cc"
     "PREFIX=${placeholder "out"}"
     "BINDIR=${placeholder "out"}/bin"
     "MANDIR=${placeholder "out"}/man1"
     "CATDIR=${placeholder "out"}/cat1"
   ];
 
-  patches = [ ./cdecl-2.5-lex.patch ];
-  prePatch = ''
-    substituteInPlace cdecl.c --replace 'getline' 'cdecl_getline'
-  '';
+  doCheck = true;
+  checkTarget = "test";
 
   preInstall = ''
     mkdir -p $out/bin;
diff --git a/pkgs/by-name/cd/cdecl/test_remove_interactive_line.patch b/pkgs/by-name/cd/cdecl/test_remove_interactive_line.patch
new file mode 100644
index 0000000000000..5a769f2dfec9d
--- /dev/null
+++ b/pkgs/by-name/cd/cdecl/test_remove_interactive_line.patch
@@ -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: