diff --git a/.envrc b/.envrc index d38ce97..04d94ef 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,2 @@ -use guix chicken chicken-test chicken-r7rs chicken-srfi-34 chicken-srfi-35 chicken-srfi-69 chicken-srfi-99 chicken-srfi-113 chicken-srfi-128 chicken-srfi-133 chicken-srfi-152 chicken-srfi-158 redis +export NIXPKGS_ALLOW_BROKEN=1 +use nix diff --git a/LICENSE b/LICENSE index 909b517..de5105f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2022 Daniel Ziltener +Copyright (C) 2022-2024 Daniel Ziltener All rights reserved. diff --git a/nix/chicken.nix b/nix/chicken.nix new file mode 100644 index 0000000..72f3daa --- /dev/null +++ b/nix/chicken.nix @@ -0,0 +1,126 @@ +{ + pkgs, + lib, + stdenv, + fetchgit, + fetchurl, + makeWrapper, + darwin, + tcc-mob, + version ? "git", + testers +}: +let + platform = with stdenv; + if isDarwin then "macosx" + else if isCygwin then "cygwin" + else if (isFreeBSD || isOpenBSD) then "bsd" + else if isSunOS then "solaris" + else "linux"; # Should be a sane default +in +stdenv.mkDerivation (finalAttrs: { + pname = "chicken"; + inherit version; + + binaryVersion = 12; + + srcs = [ + (fetchgit { + url = "git://code.call-cc.org/chicken-core"; + rev = "8b7b3124c47e018388f9f6b80bdb89813248ac76"; + sha256 = "sha256-BdZhxW6cgN5Lr1YFVZ+iejKMEvGYJ8sQlc+4DnO+Djw="; + }) + (fetchurl { + url = "https://code.call-cc.org/dev-snapshots/2024/07/01/chicken-6.0.0-bootstrap.tar.gz"; + sha256 = "sha256-qkcyWzsaN9+HbMBolmv7zeaPrtbaCTGa9HoF2g/3//o="; + }) + ]; + + unpackPhase = '' + cp -r `echo $srcs | awk '{print $1}'`/* . + cp -r `echo $srcs | awk '{print $1}'`/.* . + chmod -R 777 . + mkdir -p boot/snapshot + cd boot + tar xzf `echo $srcs | awk '{print $2}'` + cd .. + echo ${version} > buildid + + cd boot/chicken-6.0.0 + case "${platform}" in + bsd) + mkcmd=gmake;; + *) + mkcmd=make;; + esac + export CC="${tcc-mob}/bin/tcc" + $mkcmd C_COMPILER=$CC PREFIX="$(pwd)"/../snapshot + $mkcmd C_COMPILER=$CC PREFIX="$(pwd)"/../snapshot install + cd ../.. + ./configure --chicken "$(pwd)"/boot/snapshot/bin/chicken --c-compiler "${tcc-mob}/bin/tcc" + $mkcmd boot-chicken + ''; + + # Disable two broken tests: "static link" and "linking tests" + postPatch = '' + sed -i tests/runtests.sh -e "/static link/,+4 { s/^/# / }" + sed -i tests/runtests.sh -e "/linking tests/,+11 { s/^/# / }" + ''; + + # -fno-strict-overflow is not a supported argument in clang + hardeningDisable = lib.optionals stdenv.cc.isClang [ "strictoverflow" ]; + + makeFlags = [ + "PLATFORM=${platform}" + "PREFIX=$(out)" + "C_COMPILER=${tcc-mob}/bin/tcc" + "CXX_COMPILER=$(CXX)" + ] ++ (lib.optionals stdenv.isDarwin [ + "XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin" + "LINKER_OPTIONS=-headerpad_max_install_names" + "POSTINSTALL_PROGRAM=install_name_tool" + ]) ++ (lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "HOSTSYSTEM=${stdenv.hostPlatform.config}" + "TARGET_C_COMPILER=${tcc-mob}/bin/${stdenv.cc.targetPrefix}tcc" + "TARGET_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" + ]); + + nativeBuildInputs = [ + makeWrapper + pkgs.hostname + tcc-mob + ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ + darwin.autoSignDarwinBinariesHook + ]; + + configurePhase = '' + ./configure --chicken ./chicken-boot --prefix $PREFIX --platform=$PLATFORM --c-compiler "${tcc-mob}/bin/tcc" + ''; + + doCheck = !stdenv.isDarwin; + postCheck = '' + ./csi -R chicken.pathname -R chicken.platform \ + -p "(assert (equal? \"${toString finalAttrs.binaryVersion}\" (pathname-file (car (repository-path)))))" + ''; + + passthru.tests.version = testers.testVersion { + package = finalAttrs.finalPackage; + command = "csi -version"; + }; + + meta = { + homepage = "https://call-cc.org/"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ corngood nagy konst-aa ]; + platforms = lib.platforms.unix; + description = "Portable compiler for the Scheme programming language"; + longDescription = '' + CHICKEN is a compiler for the Scheme programming language. + CHICKEN produces portable and efficient C, supports almost all + of the R5RS Scheme language standard, and includes many + enhancements and extensions. CHICKEN runs on Linux, macOS, + Windows, and many Unix flavours. + ''; + }; + +}) diff --git a/nix/chicken.nix~ b/nix/chicken.nix~ new file mode 100644 index 0000000..c6af73c --- /dev/null +++ b/nix/chicken.nix~ @@ -0,0 +1,126 @@ +{ + pkgs, + lib, + stdenv, + fetchgit, + fetchurl, + makeWrapper, + darwin, + tcc-mob, + version ? "git", + testers +}: +let + platform = with stdenv; + if isDarwin then "macosx" + else if isCygwin then "cygwin" + else if (isFreeBSD || isOpenBSD) then "bsd" + else if isSunOS then "solaris" + else "linux"; # Should be a sane default +in +stdenv.mkDerivation (finalAttrs: { + pname = "chicken"; + inherit version; + + binaryVersion = 12; + + srcs = [ + (fetchgit { + url = "git://code.call-cc.org/chicken-core"; + rev = "dbffda19e57c3be092e5a9174f1829632f5fa5a7"; + sha256 = "sha256-zWjf9JS4H1buBlkmUhIv+odCQzXaOPtI7VfIaQUhe6Q="; + }) + (fetchurl { + url = "https://code.call-cc.org/dev-snapshots/2024/07/01/chicken-6.0.0-bootstrap.tar.gz"; + sha256 = "sha256-qkcyWzsaN9+HbMBolmv7zeaPrtbaCTGa9HoF2g/3//o="; + }) + ]; + + unpackPhase = '' + cp -r `echo $srcs | awk '{print $1}'`/* . + cp -r `echo $srcs | awk '{print $1}'`/.* . + chmod -R 777 . + mkdir -p boot/snapshot + cd boot + tar xzf `echo $srcs | awk '{print $2}'` + cd .. + echo ${version} > buildid + + cd boot/chicken-6.0.0 + case "${platform}" in + bsd) + mkcmd=gmake;; + *) + mkcmd=make;; + esac + export CC="${tcc-mob}/bin/tcc" + $mkcmd C_COMPILER=$CC PREFIX="$(pwd)"/../snapshot + $mkcmd C_COMPILER=$CC PREFIX="$(pwd)"/../snapshot install + cd ../.. + ./configure --chicken "$(pwd)"/boot/snapshot/bin/chicken --c-compiler "${tcc-mob}/bin/tcc" + $mkcmd boot-chicken + ''; + + # Disable two broken tests: "static link" and "linking tests" + postPatch = '' + sed -i tests/runtests.sh -e "/static link/,+4 { s/^/# / }" + sed -i tests/runtests.sh -e "/linking tests/,+11 { s/^/# / }" + ''; + + # -fno-strict-overflow is not a supported argument in clang + hardeningDisable = lib.optionals stdenv.cc.isClang [ "strictoverflow" ]; + + makeFlags = [ + "PLATFORM=${platform}" + "PREFIX=$(out)" + "C_COMPILER=${tcc-mob}/bin/tcc" + "CXX_COMPILER=$(CXX)" + ] ++ (lib.optionals stdenv.isDarwin [ + "XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin" + "LINKER_OPTIONS=-headerpad_max_install_names" + "POSTINSTALL_PROGRAM=install_name_tool" + ]) ++ (lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "HOSTSYSTEM=${stdenv.hostPlatform.config}" + "TARGET_C_COMPILER=${tcc-mob}/bin/${stdenv.cc.targetPrefix}tcc" + "TARGET_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" + ]); + + nativeBuildInputs = [ + makeWrapper + pkgs.hostname + tcc-mob + ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ + darwin.autoSignDarwinBinariesHook + ]; + + configurePhase = '' + ./configure --chicken ./chicken-boot --prefix $PREFIX --platform=$PLATFORM --c-compiler "${tcc-mob}/bin/tcc" + ''; + + doCheck = !stdenv.isDarwin; + postCheck = '' + ./csi -R chicken.pathname -R chicken.platform \ + -p "(assert (equal? \"${toString finalAttrs.binaryVersion}\" (pathname-file (car (repository-path)))))" + ''; + + passthru.tests.version = testers.testVersion { + package = finalAttrs.finalPackage; + command = "csi -version"; + }; + + meta = { + homepage = "https://call-cc.org/"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ corngood nagy konst-aa ]; + platforms = lib.platforms.unix; + description = "Portable compiler for the Scheme programming language"; + longDescription = '' + CHICKEN is a compiler for the Scheme programming language. + CHICKEN produces portable and efficient C, supports almost all + of the R5RS Scheme language standard, and includes many + enhancements and extensions. CHICKEN runs on Linux, macOS, + Windows, and many Unix flavours. + ''; + }; + +}) diff --git a/nix/tinycc.nix b/nix/tinycc.nix new file mode 100644 index 0000000..603f1a9 --- /dev/null +++ b/nix/tinycc.nix @@ -0,0 +1,129 @@ +{ lib +, copyPkgconfigItems +, fetchFromRepoOrCz +, makePkgconfigItem +, perl +, stdenv +, texinfo +, which +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "tcc-mob"; + version = "0.9.29-unstable-2024-09-16"; + + src = fetchFromRepoOrCz { + repo = "tinycc"; + rev = "b8b6a5fd7b4e8cab8e5a5d01064cf5bf2b5eed95"; + hash = "sha256-jY0P2GErmo//YBaz6u4/jj/voOE3C2JaIDRmo0orXN8="; + }; + + outputs = [ "out" "info" "man" ]; + + nativeBuildInputs = [ + copyPkgconfigItems + perl + texinfo + which + ]; + + strictDeps = true; + + pkgconfigItems = let + libtcc-pcitem = { + name = "libtcc"; + inherit (finalAttrs) version; + cflags = [ "-I${libtcc-pcitem.variables.includedir}" ]; + libs = [ + "-L${libtcc-pcitem.variables.libdir}" + "-Wl,--rpath ${libtcc-pcitem.variables.libdir}" + "-ltcc" + ]; + variables = { + prefix = "${placeholder "out"}"; + includedir = "${placeholder "dev"}/include"; + libdir = "${placeholder "lib"}/lib"; + }; + description = "Tiny C compiler backend"; + }; + in [ + (makePkgconfigItem libtcc-pcitem) + ]; + + postPatch = '' + patchShebangs texi2pod.pl + ''; + + configureFlags = [ + "--cc=$CC" + "--ar=$AR" + "--crtprefix=${lib.getLib stdenv.cc.libc}/lib" + "--sysincludepaths=${lib.getDev stdenv.cc.libc}/include:{B}/include" + "--libpaths=${lib.getLib stdenv.cc.libc}/lib" + # build cross compilers + "--enable-cross" + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ + "--config-musl" + ]; + + preConfigure = let + # To avoid "malformed 32-bit x.y.z" error on mac when using clang + versionIsClean = version: + builtins.match "^[0-9]\\.+[0-9]+\\.[0-9]+" version != null; + in '' + ${ + if stdenv.isDarwin && ! versionIsClean finalAttrs.version + then "echo 'not overwriting VERSION since it would upset ld'" + else "echo ${finalAttrs.version} > VERSION" + } + configureFlagsArray+=("--elfinterp=$(< $NIX_CC/nix-support/dynamic-linker)") + ''; + + env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [ + "-Wno-error=implicit-int" + "-Wno-error=int-conversion" + ]); + + # Test segfault for static build + doCheck = !stdenv.hostPlatform.isStatic; + + checkTarget = "test"; + # https://www.mail-archive.com/tinycc-devel@nongnu.org/msg10142.html + preCheck = lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) '' + rm tests/tests2/{108,114}* + ''; + + meta = { + homepage = "https://repo.or.cz/tinycc.git"; + description = "Small, fast, and embeddable C compiler and interpreter"; + longDescription = '' + TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C + compilers, it is meant to be self-sufficient: you do not need an external + assembler or linker because TCC does that for you. + + TCC compiles so fast that even for big projects Makefiles may not be + necessary. + + TCC not only supports ANSI C, but also most of the new ISO C99 standard + and many GNU C extensions. + + TCC can also be used to make C scripts, i.e. pieces of C source that you + run as a Perl or Python script. Compilation is so fast that your script + will be as fast as if it was an executable. + + TCC can also automatically generate memory and bound checks while allowing + all C pointers operations. TCC can do these checks even if non patched + libraries are used. + + With libtcc, you can use TCC as a backend for dynamic code generation. + ''; + license = with lib.licenses; [ lgpl21Only ]; + mainProgram = "tcc"; + maintainers = with lib.maintainers; [ joachifm AndersonTorres ]; + platforms = lib.platforms.unix; + # https://www.mail-archive.com/tinycc-devel@nongnu.org/msg10199.html + broken = stdenv.isDarwin && stdenv.isAarch64; + }; +}) +# TODO: more multiple outputs +# TODO: self-compilation diff --git a/nix/tinycc.nix~ b/nix/tinycc.nix~ new file mode 100644 index 0000000..a6d5667 --- /dev/null +++ b/nix/tinycc.nix~ @@ -0,0 +1,131 @@ +{ lib +, copyPkgconfigItems +, fetchFromRepoOrCz +, makePkgconfigItem +, perl +, stdenv +, texinfo +, which +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "tcc-mob"; + version = "0.9.29-unstable-2024-09-16"; + + src = fetchFromRepoOrCz { + repo = "tinycc"; + rev = "b8b6a5fd7b4e8cab8e5a5d01064cf5bf2b5eed95"; + hash = "sha256-jY0P2GErmo//YBaz6u4/jj/voOE3C2JaIDRmo0orXN8="; + }; + + outputs = [ "out" "info" "man" ]; + + nativeBuildInputs = [ + copyPkgconfigItems + perl + texinfo + which + ]; + + strictDeps = true; + + pkgconfigItems = let + libtcc-pcitem = { + name = "libtcc"; + inherit (finalAttrs) version; + cflags = [ "-I${libtcc-pcitem.variables.includedir}" ]; + libs = [ + "-L${libtcc-pcitem.variables.libdir}" + "-Wl,--rpath ${libtcc-pcitem.variables.libdir}" + "-ltcc" + ]; + variables = { + prefix = "${placeholder "out"}"; + includedir = "${placeholder "dev"}/include"; + libdir = "${placeholder "lib"}/lib"; + }; + description = "Tiny C compiler backend"; + }; + in [ + (makePkgconfigItem libtcc-pcitem) + ]; + + postPatch = '' + patchShebangs texi2pod.pl + ''; + + configureFlags = [ + "--cc=$CC" + "--ar=$AR" + "--crtprefix=${lib.getLib stdenv.cc.libc}/lib" + "--sysincludepaths=${lib.getDev stdenv.cc.libc}/include:{B}/include" + "--libpaths=${lib.getLib stdenv.cc.libc}/lib" + # build cross compilers + "--enable-cross" + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ + "--config-musl" + ]; + + preConfigure = let + # To avoid "malformed 32-bit x.y.z" error on mac when using clang + versionIsClean = version: + builtins.match "^[0-9]\\.+[0-9]+\\.[0-9]+" version != null; + in '' + ${ + if stdenv.isDarwin && ! versionIsClean finalAttrs.version + then "echo 'not overwriting VERSION since it would upset ld'" + else "echo ${finalAttrs.version} > VERSION" + } + configureFlagsArray+=("--elfinterp=$(< $NIX_CC/nix-support/dynamic-linker)") + ''; + + env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [ + "-Wno-error=implicit-int" + "-Wno-error=int-conversion" + ]); + + # Test segfault for static build + doCheck = !stdenv.hostPlatform.isStatic; + + checkTarget = "test"; + # https://www.mail-archive.com/tinycc-devel@nongnu.org/msg10142.html + preCheck = lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) '' + rm tests/tests2/{108,114}* + ''; + + meta = { + homepage = "https://repo.or.cz/tinycc.git"; + description = "Small, fast, and embeddable C compiler and interpreter"; + longDescription = '' + TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C + compilers, it is meant to be self-sufficient: you do not need an external + assembler or linker because TCC does that for you. + + TCC compiles so fast that even for big projects Makefiles may not be + necessary. + + TCC not only supports ANSI C, but also most of the new ISO C99 standard + and many GNU C extensions. + + TCC can also be used to make C scripts, i.e. pieces of C source that you + run as a Perl or Python script. Compilation is so fast that your script + will be as fast as if it was an executable. + + TCC can also automatically generate memory and bound checks while allowing + all C pointers operations. TCC can do these checks even if non patched + libraries are used. + + With libtcc, you can use TCC as a backend for dynamic code generation. + ''; + license = with lib.licenses; [ lgpl21Only ]; + mainProgram = "tcc"; + maintainers = with lib.maintainers; [ joachifm AndersonTorres ]; + platforms = lib.platforms.unix; + # https://www.mail-archive.com/tinycc-devel@nongnu.org/msg10199.html + broken = stdenv.isDarwin && stdenv.isAarch64; + }; +}) +# TODO: more multiple outputs +# TODO: self-compilation + + diff --git a/redis-impl.scm b/redis-impl.scm index 5271db7..7feeb9b 100644 --- a/redis-impl.scm +++ b/redis-impl.scm @@ -1,5 +1,5 @@ ;; [[file:redis.org::*API][API:2]] -(import r7rs +(import (scheme base) (chicken base) (chicken port) (chicken string) @@ -8,10 +8,8 @@ (srfi 34) ;; Exception Handling (srfi 35) ;; Exception Types (srfi 69) ;; Hash Tables - (srfi 99) ;; Extended Records (srfi 113) ;; Sets and Bags (srfi 128) ;; Comparators - (srfi 133) ;; Vectors (srfi 152) ;; Strings (srfi 158) ;; Generators and Accumulators ) @@ -32,7 +30,10 @@ ;; [[file:redis.org::*Connection Management][Connection Management:2]] -(define-record-type redis-connection #t #t input output) +(define-record-type redis-connection + (make-redis-connection input output) redis-connection? + (input redis-connection-input) + (output redis-connection-output)) (define (redis-connect host port #!optional (protocol-version 1)) (let-values (((i o) (tcp-connect host port))) (values (make-redis-connection i o) @@ -55,7 +56,7 @@ ;; Uses connection =rconn= to run =command= with =args=. The args will be appended to the command, space-separated. Returns the parsed reply. ;; [[file:redis.org::*Running Commands][Running Commands:2]] -(define (redis-run rconn command . args) +(define (redis-run rconn command #!rest args) (let ((in (redis-connection-input rconn)) (out (redis-connection-output rconn)) (comm (string-join (cons command args)))) @@ -68,7 +69,7 @@ ;; Calls =proc= with the output port of the =rconn= as current output port, optionally with =args=. Returns the parsed reply. ;; [[file:redis.org::*Running Commands][Running Commands:4]] -(define (redis-run-proc rconn proc . args) +(define (redis-run-proc rconn proc #!rest args) (let ((in (redis-connection-input rconn)) (out (redis-connection-output rconn))) (with-output-to-port out @@ -197,7 +198,7 @@ (define (read-redis-array #!optional port) (let* ((port (or port (current-input-port))) (elems (string->number (read-line port))) - (vec (make-vector elems '()))) + (vec (make-vector elems))) (generator-for-each (lambda (i) (vector-set! vec i (redis-read-reply port))) diff --git a/redis.egg b/redis.egg index 5b343c2..d321363 100644 --- a/redis.egg +++ b/redis.egg @@ -7,11 +7,11 @@ (synopsis "A Redis client library for Chicken Scheme") (category db) (license "BSD") - (version "0.6") - (dependencies r7rs srfi-34 srfi-35 srfi-69 srfi-99 srfi-113 srfi-128 srfi-133 srfi-152 srfi-158) + (version "0.7") + (dependencies srfi-34 srfi-35 srfi-69 srfi-113 srfi-128 srfi-152 srfi-158) (test-dependencies test) (components (extension redis - (csc-options "-X" "r7rs" "-R" "r7rs" "-sJ")))) + (csc-options "-sJ")))) ;; About this egg:1 ends here diff --git a/redis.org b/redis.org index 65f863f..9295e61 100644 --- a/redis.org +++ b/redis.org @@ -19,8 +19,7 @@ ** Prepare in-line testing #+name: prep-test #+begin_src scheme :noweb yes :tangle tests/run.scm :results silent -(import r7rs - test +(import test (chicken base) (chicken port) (chicken io) @@ -35,10 +34,8 @@ | 34 | Exception Handling | | 35 | Exception Types | | 69 | Hash Tables | -| 99 | Extended Records | | 113 | Sets and Bags | | 128 | Comparators | -| 133 | Vectors | | 152 | Strings | | 158 | Generators and Accumulators | @@ -79,7 +76,7 @@ #+end_src #+begin_src scheme :noweb yes :tangle redis-impl.scm :exports none - (import r7rs + (import (scheme base) (chicken base) (chicken port) (chicken string) @@ -88,10 +85,8 @@ (srfi 34) ;; Exception Handling (srfi 35) ;; Exception Types (srfi 69) ;; Hash Tables - (srfi 99) ;; Extended Records (srfi 113) ;; Sets and Bags (srfi 128) ;; Comparators - (srfi 133) ;; Vectors (srfi 152) ;; Strings (srfi 158) ;; Generators and Accumulators ) @@ -119,12 +114,15 @@ This egg currently uses a simple TCP connection without any "bells and whistles" Connects to a (hopefully) Redis server at =host:port=, using the given protocol version. Defaults, like Redis itself, to version 1. #+begin_src scheme :tangle redis-impl.scm :exports none - (define-record-type redis-connection #t #t input output) - (define (redis-connect host port #!optional (protocol-version 1)) - (let-values (((i o) (tcp-connect host port))) - (values (make-redis-connection i o) - (and (write-line (string-append "HELLO " (->string protocol-version)) o) - (redis-read-reply i))))) + (define-record-type redis-connection + (make-redis-connection input output) redis-connection? + (input redis-connection-input) + (output redis-connection-output)) + (define (redis-connect host port #!optional (protocol-version 1)) + (let-values (((i o) (tcp-connect host port))) + (values (make-redis-connection i o) + (and (write-line (string-append "HELLO " (->string protocol-version)) o) + (redis-read-reply i))))) #+end_src #+begin_src scheme @@ -146,7 +144,7 @@ Disconnects from =rconn= which must be a =redis-connection=. Uses connection =rconn= to run =command= with =args=. The args will be appended to the command, space-separated. Returns the parsed reply. #+begin_src scheme :tangle redis-impl.scm :exports none - (define (redis-run rconn command . args) + (define (redis-run rconn command #!rest args) (let ((in (redis-connection-input rconn)) (out (redis-connection-output rconn)) (comm (string-join (cons command args)))) @@ -160,7 +158,7 @@ Uses connection =rconn= to run =command= with =args=. The args will be appended Calls =proc= with the output port of the =rconn= as current output port, optionally with =args=. Returns the parsed reply. #+begin_src scheme :tangle redis-impl.scm :exports none - (define (redis-run-proc rconn proc . args) + (define (redis-run-proc rconn proc #!rest args) (let ((in (redis-connection-input rconn)) (out (redis-connection-output rconn))) (with-output-to-port out @@ -417,7 +415,7 @@ Arrays are marked with ~*~ followed by the number of entries, and get returned a (define (read-redis-array #!optional port) (let* ((port (or port (current-input-port))) (elems (string->number (read-line port))) - (vec (make-vector elems '()))) + (vec (make-vector elems))) (generator-for-each (lambda (i) (vector-set! vec i (redis-read-reply port))) @@ -559,12 +557,12 @@ This library returns two values in this case, the first value being the actual d (category db) (license "BSD") (version <>) - (dependencies r7rs <>) + (dependencies <>) (test-dependencies test) (components (extension redis - (csc-options "-X" "r7rs" "-R" "r7rs" "-sJ")))) + (csc-options "-sJ")))) #+end_src #+begin_src scheme :tangle tests/run.scm :exports none @@ -581,6 +579,9 @@ Daniel Ziltener ** Version History +#+name: version-history-6 +| 0.7 | Port to Chicken 6 | + #+name: version-history | 0.6 | Easier Protocol Version Setting | | 0.5 | Initial Release | @@ -592,10 +593,17 @@ Daniel Ziltener #+end_src #+name: latest-release -#+begin_src emacs-lisp :var vers=version-history :exports none :results code +#+begin_src emacs-lisp :var vers=version-history-6 :exports none :results code (number-to-string (caar vers)) #+end_src +#+begin_src scheme :noweb yes :tangle redis.release-info.6 :exports none +;; -*- Scheme -*- +(repo git "https://forgejo.lyrion.ch/Chicken/redis.git") +(uri targz "https://forgejo.lyrion.ch/Chicken/redis/archive/{egg-release}.tar.gz") +<> +#+end_src + #+begin_src scheme :noweb yes :tangle redis.release-info :exports none ;; -*- Scheme -*- (repo git "https://forgejo.lyrion.ch/Chicken/redis.git") @@ -606,7 +614,7 @@ Daniel Ziltener ** License #+begin_src fundamental :tangle LICENSE -Copyright (C) 2022 Daniel Ziltener +Copyright (C) 2022-2024 Daniel Ziltener All rights reserved. diff --git a/redis.release-info b/redis.release-info index 6912707..3a29d39 100644 --- a/redis.release-info +++ b/redis.release-info @@ -1,7 +1,7 @@ -;; [[file:redis.org::*Version History][Version History:3]] +;; [[file:redis.org::*Version History][Version History:4]] ;; -*- Scheme -*- (repo git "https://forgejo.lyrion.ch/Chicken/redis.git") (uri targz "https://forgejo.lyrion.ch/Chicken/redis/archive/{egg-release}.tar.gz") (release "0.6") ;; Easier Protocol Version Setting (release "0.5") ;; Initial Release -;; Version History:3 ends here +;; Version History:4 ends here diff --git a/redis.release-info.6 b/redis.release-info.6 new file mode 100644 index 0000000..cdb0bc4 --- /dev/null +++ b/redis.release-info.6 @@ -0,0 +1,6 @@ +;; [[file:redis.org::*Version History][Version History:3]] +;; -*- Scheme -*- +(repo git "https://forgejo.lyrion.ch/Chicken/redis.git") +(uri targz "https://forgejo.lyrion.ch/Chicken/redis/archive/{egg-release}.tar.gz") +(release "0.7") ;; Port to Chicken 6 +;; Version History:3 ends here diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..d7adeb6 --- /dev/null +++ b/shell.nix @@ -0,0 +1,34 @@ +with import { + overlays = [ + (final: prev: { + tcc-mob = final.callPackage ./nix/tinycc.nix { stdenv = final.gcc13Stdenv; }; + chicken = final.callPackage ./nix/chicken.nix { + stdenv = final.gcc13Stdenv; + version = "6.0.0-8b7b312"; + }; + }) + ]; +}; +mkShell { + packages = with pkgs; [ + tcc-mob + chicken + ] + # ++ (with pkgs.chickenPackages_5.chickenEggs; [ + # apropos + # chicken-doc + # srfi-1 + # srfi-18 + # lsp-server + # srfi-152 + # ]) + ; + shellHook = '' + export CC="${pkgs.tcc-mob}/bin/tcc" + export CHICKEN_INSTALL_PREFIX="$HOME/.chicken" + export CHICKEN_INSTALL_REPOSITORY="$HOME/.chicken/eggs" + export CHICKEN_REPOSITORY_PATH="${pkgs.chicken}/lib/chicken/12:$HOME/.chicken/eggs" + export PATH="$PATH:$CHICKEN_PREFIX" + export CHICKEN_INSTALL_PREFIX="${pkgs.chicken}" + ''; +} diff --git a/tests/run.scm b/tests/run.scm index 3261950..0c1f0c6 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -1,16 +1,13 @@ (import (chicken string)) -(import r7rs - test +(import test (chicken base) (chicken port) (chicken io) (srfi 34) ;; Exception Handling (srfi 35) ;; Exception Types (srfi 69) ;; Hash Tables - (srfi 99) ;; Extended Records (srfi 113) ;; Sets and Bags (srfi 128) ;; Comparators - (srfi 133) ;; Vectors (srfi 152) ;; Strings (srfi 158) ;; Generators and Accumulators )