diff mbox series

[bug#41294] gnu: Add libfreenect.

Message ID QLWnu8KtNBTHA51a59dkF3pxVUigT96IOwcqgtejj0Bmi5AmUuSOMIm3BCHfrR4YUIBN7dNK0bLnv9l5qnyy6iTCIvga0qTmmfLO_2ZmDaE=@elenq.tech
State Accepted
Headers show
Series [bug#41294] gnu: Add libfreenect. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job

Commit Message

Ekaitz Zarraga May 20, 2020, 4:37 p.m. UTC
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, May 20, 2020 3:33 PM, <iyzsong@member.fsf.org> wrote:
>
> Um, I mean something like this:
>
> (define libfreenect-derived-phases
> '(modify-phases %standard-phases
> (lambda* (#:key outputs #:allow-other-keys)
> ...)))
>
> ...
> (arguments
> `(#:phases ,libfreenect-derived-phases))
> ...
>
> Here 'libfreenect-derived-phases' is a list of symbols, the arguments
> field we want is a list of symbols too.

Hi,

That makes way more sense than what I was trying to do.
I applied that and separated libfreenect to a different module. Patch below.

Thank you very much for your support.

PS: I'm still wondering what kind of weird magic is involved in the example I shown.


From efcf2b3fcb4b422939550e614d20abafaaed3d7f Mon Sep 17 00:00:00 2001
From: Ekaitz Zarraga <ekaitz@elenq.tech>
Date: Wed, 20 May 2020 18:18:23 +0200
Subject: [PATCH] gnu: openkinect: New module

    * gnu/packages/openkinect.scm: New file.
    * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk                |   1 +
 gnu/packages/openkinect.scm | 140 ++++++++++++++++++++++++++++++++++++
 2 files changed, 141 insertions(+)
 create mode 100644 gnu/packages/openkinect.scm

--
2.26.2

Comments

宋文武 May 21, 2020, 11:38 a.m. UTC | #1
Ekaitz Zarraga <ekaitz@elenq.tech> writes:

> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Wednesday, May 20, 2020 3:33 PM, <iyzsong@member.fsf.org> wrote:
>>
>> Um, I mean something like this:
>>
>> (define libfreenect-derived-phases
>> '(modify-phases %standard-phases
>> (lambda* (#:key outputs #:allow-other-keys)
>> ...)))
>>
>> ...
>> (arguments
>> `(#:phases ,libfreenect-derived-phases))
>> ...
>>
>> Here 'libfreenect-derived-phases' is a list of symbols, the arguments
>> field we want is a list of symbols too.
>
> Hi,
>
> That makes way more sense than what I was trying to do.
> I applied that and separated libfreenect to a different module. Patch below.

Pushed, with:
- Change libfreenect-python to 'python-libfreenect'.
- Change libfreenect-cv to 'libfreenect-opencv'.
- Change some comments..

Thank you!

>
> Thank you very much for your support.
>
> PS: I'm still wondering what kind of weird magic is involved in the example I shown.
>

Basically we can't use procedure (defined outside of the builder
environment) values in the package's arguments field, it have to be self
contained, as the package builder is a guile script file serialized from
the package object (procedures serilazied into #<procedure ...>, and
can't be loaded again), and will be executed in an isolated environment.
Ekaitz Zarraga May 21, 2020, 11:40 a.m. UTC | #2
Hi,

> > PS: I'm still wondering what kind of weird magic is involved in the example I shown.
>
> Basically we can't use procedure (defined outside of the builder
> environment) values in the package's arguments field, it have to be self
> contained, as the package builder is a guile script file serialized from
> the package object (procedures serilazied into #<procedure ...>, and
> can't be loaded again), and will be executed in an isolated environment.

Great. Understood.
Thank you very much.
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index ab2bac9bc5..b9c09cc5e3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -394,6 +394,7 @@  GNU_SYSTEM_MODULES =				\
   %D%/packages/nvi.scm				\
   %D%/packages/ocaml.scm			\
   %D%/packages/ocr.scm				\
+  %D%/packages/openkinect.scm			\
   %D%/packages/onc-rpc.scm			\
   %D%/packages/opencl.scm			\
   %D%/packages/openbox.scm			\
diff --git a/gnu/packages/openkinect.scm b/gnu/packages/openkinect.scm
new file mode 100644
index 0000000000..96150801e6
--- /dev/null
+++ b/gnu/packages/openkinect.scm
@@ -0,0 +1,140 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2020 Ekaitz Zarraga <ekaitz@elenq.tech>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages openkinect)
+  #:use-module (guix packages)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cmake)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages libusb)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages image-processing))
+
+(define-public libfreenect
+  (let ((version "0.6.1"))
+    (package
+      (name "libfreenect")
+      (version version)
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/OpenKinect/libfreenect")
+                      (commit (string-append "v" version))))
+                (sha256
+                 (base32 "0was1va167rqshmpn382h36yyprpfi9cwillb6ylppmnfdrfrhrr"))))
+      (build-system cmake-build-system)
+      (arguments
+       '(#:tests? #f ; Project has not tests
+         #:configure-flags
+         '("-DBUILD_FAKENECT=ON"
+           "-DBUILD_CPP=ON"
+           "-DBUILD_EXAMPLES=OFF" ; Available in libfreenect-examples
+           "-DBUILD_CV=OFF"       ; Available in libfreenect-cv
+           "-DBUILD_PYTHON=OFF"   ; Available in libfreenect-python
+           "-DBUILD_C_SYNC=ON")
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'install 'install-udev-rules
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (rules-out (string-append out "/lib/udev/rules.d")))
+                 (install-file "../source/platform/linux/udev/51-kinect.rules"
+                               (string-append rules-out "51-kinect.rules"))
+                 #t))))))
+      (native-inputs
+       `(("pkg-config" ,pkg-config)))
+      (inputs
+       `(("libusb" ,libusb)))
+      (synopsis "Drivers and libraries for the Xbox Kinect device")
+      (description "libfreenect is a userspace driver for the Microsoft Kinect.
+It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.")
+      (home-page "https://openkinect.org/")
+      (license license:gpl2+))))
+
+;; Sources are already compiled in libfreenect input: remove them from the
+;; compilation
+(define libfreenect-derived-phases
+  '(modify-phases %standard-phases
+     (add-after 'unpack 'disable-sources
+       (lambda* (#:key outputs #:allow-other-keys)
+         (substitute* "CMakeLists.txt"
+           ((".*libusb.*") "")
+           (("add_subdirectory \\(src\\)") "")
+           ((".*libfreenectConfig.cmake.*") ""))))))
+
+(define-public libfreenect-examples
+  (package
+    (inherit libfreenect)
+    (name "libfreenect-examples")
+    (inputs
+     `(("libfreenect" ,libfreenect)
+       ("glut" ,freeglut)))
+    (arguments
+     `(#:tests? #f ; Project has not tests
+       #:configure-flags '("-DBUILD_EXAMPLES=ON"
+                           "-DBUILD_FAKENECT=OFF"
+                           "-DBUILD_CPP=OFF"
+                           "-DBUILD_C_SYNC=OFF"
+                           "-DBUILD_CV=OFF")
+       #:phases ,libfreenect-derived-phases))
+    (synopsis "Examples for libfreenect, the Xbox Kinect device library")))
+
+(define-public libfreenect-cv
+  (package
+    (inherit libfreenect)
+    (name "libfreenect-cv")
+    (inputs
+     `(("libfreenect" ,libfreenect)
+       ("opencv" ,opencv)))
+    (arguments
+     `(#:tests? #f ; Project has not tests
+       #:configure-flags '("-DBUILD_EXAMPLES=OFF"
+                           "-DBUILD_FAKENECT=OFF"
+                           "-DBUILD_CPP=OFF"
+                           "-DBUILD_C_SYNC=OFF"
+                           "-DBUILD_CV=ON")
+       #:phases ,libfreenect-derived-phases))
+    (synopsis "OpenCV wrapper for libfreenect, the Xbox Kinect device
+library")))
+
+(define-public libfreenect-python
+  (package
+    (inherit libfreenect)
+    (name "libfreenect-python")
+    (native-inputs
+     `(("python-cython" ,python-cython)))
+    (inputs
+     `(("libfreenect" ,libfreenect)))
+    (propagated-inputs
+     `(("python" ,python)
+       ("python-numpy" ,python-numpy)))
+    (arguments
+     `(#:tests? #f ; Project has not tests
+       #:configure-flags '("-DBUILD_EXAMPLES=OFF"
+                           "-DBUILD_FAKENECT=OFF"
+                           "-DBUILD_CPP=OFF"
+                           "-DBUILD_C_SYNC=OFF"
+                           "-DBUILD_CV=OFF"
+                           "-DBUILD_PYTHON3=ON")
+       #:phases ,libfreenect-derived-phases))
+    (synopsis "Python wrapper for libfreenect, the Xbox Kinect device
+library")))