From 0cf2c3b798071048d70c39d9f6697e8137e24251 Mon Sep 17 00:00:00 2001 From: Simon South Date: Fri, 15 May 2020 18:18:51 -0400 Subject: [PATCH 2/3] gnu: Add lua-cqueues. * gnu/packages/lua.scm (make-lua-cqueues): New function. (luajit-cqueues): New variable. --- gnu/packages/lua.scm | 106 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm index ab86e24bb9..dd14f7dd43 100644 --- a/gnu/packages/lua.scm +++ b/gnu/packages/lua.scm @@ -422,6 +422,112 @@ secure session between the peers.") (define-public lua5.2-sec (make-lua-sec "lua5.2-sec" lua-5.2)) +(define (make-lua-cqueues name lua lua-ossl) + (package + (name name) + (version "20190813") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/wahern/cqueues.git") + (commit (string-append "rel-" version)))) + (sha256 + (base32 + "0yin39cldhc1l6rr33nj2z8la6rvv0c70g47rkvjb7s0wy760ggz")))) + (build-system gnu-build-system) + (arguments + `(#:modules ((guix build gnu-build-system) + (guix build utils) + (ice-9 string-fun)) + #:make-flags + (let ((lua-api-version ,(if (eq? lua luajit) + "5.1" + (version-major+minor (package-version lua))))) + (list "CC=gcc" + (string-append "LUA_APIS=" lua-api-version))) + #:phases + (modify-phases %standard-phases + (delete 'configure) + (delete 'check) + (replace 'install + (lambda* (#:key make-flags outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (apply invoke "make" "install" + (append make-flags + (list (string-append "DESTDIR=" out) + "prefix=")))))) + (add-after 'install 'check + (lambda* (#:key inputs make-flags outputs #:allow-other-keys) + (let* ((lua-api-version ,(if (eq? lua luajit) + "5.1" + (version-major+minor + (package-version lua)))) + (lua-cpath (lambda (p) + (string-append p "/lib/lua/" lua-api-version + "/?.so"))) + (lua-path (lambda (p) + (string-append p "/share/lua/" lua-api-version + "/?.lua"))) + (env-suffix (if (equal? lua-api-version "5.1") + "" + (string-append + "_" + (string-replace-substring lua-api-version + "." "_")))) + (lua-ossl (assoc-ref inputs "lua-ossl")) + (out (assoc-ref outputs "out"))) + ;; The test suite sets Lua-version-specific search-path variables + ;; when available so we must do the same, as these take + ;; precedence over the generic "LUA_CPATH" and "LUA_PATH" + (setenv (string-append "LUA_CPATH" env-suffix) + (string-append + (string-join (map lua-cpath (list out lua-ossl)) ";") + ";;")) + (setenv (string-append "LUA_PATH" env-suffix) + (string-append + (string-join (map lua-path (list out lua-ossl)) ";") + ";;")) + + ;; Skip regression tests we expect to fail + (with-directory-excursion "regress" + (for-each (lambda (f) + (rename-file f (string-append f ".skip"))) + (append + ;; Tests that require network connectivity + '("22-client-dtls.lua" + "30-starttls-completion.lua" + "62-noname.lua" + "153-dns-resolvers.lua") + + ;; Tests that require LuaJIT + (if ,(not (eq? lua luajit)) + '("44-resolvers-gc.lua" + "51-join-defunct-thread.lua") + '()) + + ;; Tests that require Lua 5.3 + (if (not (equal? lua-api-version "5.3")) + '("152-thread-integer-passing.lua") + '())))) + + (apply invoke "make" "check" make-flags))))))) + (native-inputs + `(("m4" ,m4))) + (inputs + `(("lua" ,lua) + ("openssl" ,openssl))) + (propagated-inputs + `(("lua-ossl" ,lua-ossl))) + (home-page "https://25thandclement.com/~william/projects/cqueues.html") + (synopsis "Event loop for Lua using continuation queues") + (description "The cqueues extension module for Lua implements an event loop +that operates through the yielding and resumption of coroutines. It is designed +to be non-intrusive, composable, and embeddable within existing applications.") + (license license:expat))) + +(define-public luajit-cqueues + (make-lua-cqueues "luajit-cqueues" luajit luajit-ossl)) + (define-public lua-penlight (package (name "lua-penlight") -- 2.26.2