Subject: [PATCH 1/1] gnu: Add selene.

From: Fis Trivial <[email-masked]>
Date: Sat, 6 Jan 2018 18:04:28 +0000

* gnu/packages/lua.scm (selene): New public variable.
---
 gnu/packages/lua.scm | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index 3fd1c43d4..dba704ffe 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -28,8 +28,11 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix build utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system cmake)
   #:use-module (gnu packages)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages tls)
@@ -434,3 +437,62 @@ on numbers.")

 (define-public lua5.1-bitop
   (make-lua-bitop "lua5.1-bitop" lua-5.1))
+
+(define-public selene
+  (package
+    (name "selene")
+    (version "2017.08.25")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/jeremyong/Selene.git")
+                    ;; The release is quite old.
+                    (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
+              (file-name "Selene")
+              (sha256
+               (base32
+                "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:configure-flags
+       ;; lua pc file in CMakeLists.txt is lua5.3.pc
+       '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
+       #:test-target "all"
+       #:phases
+       ;; This is a header only library
+       (modify-phases %standard-phases
+         (delete 'build)
+         (replace 'install
+           (lambda _
+             (let* ((output     (assoc-ref %outputs "out"))
+                    (source     (assoc-ref %build-inputs "source"))
+                    (includedir (string-append output "/include")))
+               (copy-recursively
+                (string-append source "/include")
+                includedir))
+             #t))
+         ;; The path of test files are hard coded.
+         (replace 'check
+           (lambda _
+             (let* ((output (assoc-ref %output "out"))
+                    (source (assoc-ref %build-inputs "source"))
+                    (builddir   (getcwd))
+                    (testdir    (string-append builddir "/test")))
+               (and
+                (copy-recursively
+                 (string-append source "/test")
+                 testdir)
+                (system* "make")
+                ;; To overcome the hardcoded test path
+                (mkdir-p "runner")
+                (copy-file "./test_runner" "./runner/test_runner")
+                (chdir "./runner")
+                (system* "./test_runner"))))))))
+    (native-inputs
+     `(("lua" ,lua)
+       ("pkg-config" ,pkg-config)))
+    (home-page "https://github.com/jeremyong/Selene")
+    (synopsis "Lua C++11 bindings")
+    (description
+     "Selene is a simple C++11 friendly header-only binding to Lua.")
+    (license license:zlib)))
-- 
2.13.6