Subject: [PATCH 1/2] gnu: Add hueplusplus.

From: John Kehayias <[email-masked]>
Date: Sun, 02 Jan 2022 17:15:15 +0000

Empty Message

From ea9b2e7650f0cae46912d23e598b6bcfd148a2bf Mon Sep 17 00:00:00 2001
From: John Kehayias <[email-masked]>
Date: Sun, 2 Jan 2022 11:38:03 -0500
Subject: [PATCH 1/2] gnu: Add hueplusplus.

* gnu/packages/hardware.scm (hueplusplus): New variable.
* gnu/packages/patches/hueplusplus-mbedtls.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/hardware.scm                     | 39 ++++++++++++++++++-
 .../patches/hueplusplus-mbedtls.patch         | 20 ++++++++++
 3 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/hueplusplus-mbedtls.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 852f9f3246..b427edb4a4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1260,6 +1260,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/helm-fix-gcc-9-build.patch		\
   %D%/packages/patches/http-parser-CVE-2020-8287.patch		\
   %D%/packages/patches/hubbub-sort-entities.patch		\
+  %D%/packages/patches/hueplusplus-mbedtls.patch		\
   %D%/packages/patches/hurd-cross.patch				\
   %D%/packages/patches/hurd-xattr.patch				\
   %D%/packages/patches/hydra-disable-darcs-test.patch		\
diff --git a/gnu/packages/hardware.scm b/gnu/packages/hardware.scm
index 28647477fe..227a359adb 100644
--- a/gnu/packages/hardware.scm
+++ b/gnu/packages/hardware.scm
@@ -8,7 +8,7 @@
 ;;; Copyright © 2021 Petr Hodina <[email-masked]>
 ;;; Copyright © 2021 Raghav Gururajan <[email-masked]>
 ;;; Copyright © 2021 Vinicius Monego <[email-masked]>
-;;; Copyright © 2021 John Kehayias <[email-masked]>
+;;; Copyright © 2021, 2022 John Kehayias <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -341,6 +341,43 @@ (define-public headsetcontrol
 battery state, controlling LEDs, and setting the inactive time.")
     (license license:gpl3+)))
 
+(define-public hueplusplus
+  (package
+    (name "hueplusplus")
+    (version "1.1.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/enwi/hueplusplus")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1jy8m2a0h0kf0aw8jbniz069q9j7cx67b1zlv2vz1ymq921qk0pm"))
+       (patches
+        (search-patches "hueplusplus-mbedtls.patch"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:tests? #f)) ;; Tests require Google's gtest and gmock
+    (inputs
+     (list mbedtls-apache))
+    (synopsis "Simple C++ library to control Philips Hue lights")
+    (description "Hueplusplus is a simple and easy to use library for Philips Hue Lights.
+Features:
+
+@itemize
+@item find bridges with SSDP or set an ip manually
+@item all common light functions (brightness, color, temperature)
+@item extended @code{alert()} functions, which alert in a specific
+color (good for notifications)
+@item supports sensors, rules, groups, scenes and schedules
+@item streaming with entertainment mode
+@item documented with doxygen
+@item tested with google test, google mock and gcov/lcov
+@end itemize")
+    (home-page "https://github.com/enwi/hueplusplus")
+    (license license:lgpl3)))
+
 (define-public i7z
   (let ((revision "0")
         (commit "1a41ff13db747e962456ddbb5ccb2b7fc43ca0cb"))
diff --git a/gnu/packages/patches/hueplusplus-mbedtls.patch b/gnu/packages/patches/hueplusplus-mbedtls.patch
new file mode 100644
index 0000000000..894590af8d
--- /dev/null
+++ b/gnu/packages/patches/hueplusplus-mbedtls.patch
@@ -0,0 +1,20 @@
+Remove references to bundled mbedtls library to use the one from inputs.
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 1e27d21..f0eb1a5 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -85,13 +85,6 @@ endif()
+ 
+ set(USE_STATIC_MBEDTLS_LIBRARY ON)
+ set(USE_SHARED_MBEDTLS_LIBRARY OFF)
+-add_subdirectory("lib/mbedtls" EXCLUDE_FROM_ALL)
+-
+-# Compile the mbedtls library as a static with position independent code,
+-# because we need it for both a shared and static library
+-set_property(TARGET mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
+-set_property(TARGET mbedcrypto PROPERTY POSITION_INDEPENDENT_CODE ON)
+-set_property(TARGET mbedx509 PROPERTY POSITION_INDEPENDENT_CODE ON)
+ 
+ add_subdirectory(src)
+ 
-- 
2.34.0