summary refs log tree commit diff
path: root/gnu/packages/cpp.scm
diff options
context:
space:
mode:
authornixo <nicolo@nixo.xyz>2021-01-27 23:44:04 +0100
committerLudovic Courtès <ludo@gnu.org>2021-09-03 22:08:51 +0200
commited4dd53b1ee1dca1740b72ddc798a27cc4a012e6 (patch)
treeb15f0e45021aca79602111d1be33e7a9a277000d /gnu/packages/cpp.scm
parent49bb544b77c7dcd7d2a1bade00fb0844a2e8f7ee (diff)
downloadguix-ed4dd53b1ee1dca1740b72ddc798a27cc4a012e6.tar.gz
gnu: Add cpp-httplib.
* gnu/packages/cpp.scm (cpp-httplib): New variable.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/packages/cpp.scm')
-rw-r--r--gnu/packages/cpp.scm63
1 files changed, 62 insertions, 1 deletions
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index ba921fac11..f4708eda91 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -18,7 +18,7 @@
 ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
 ;;; Copyright © 2020 Milkey Mouse <milkeymouse@meme.institute>
 ;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
-
+;;; Copyright © 2021 Nicolò Balzarotti <nicolo@nixo.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -66,6 +66,7 @@
   #:use-module (gnu packages maths)
   #:use-module (gnu packages onc-rpc)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages python)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages popt)
   #:use-module (gnu packages pretty-print)
@@ -556,6 +557,66 @@ tools:
 @end itemize\n")
     (license license:bsd-3)))
 
+(define-public cpp-httplib
+  ;; this package is not graftable, as everything is implemented in a single
+  ;; header
+  (package
+    (name "cpp-httplib")
+    (version "0.8.8")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/yhirose/cpp-httplib")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "0c0gyfbvm34bgrqy9fhfxw1f8nb9zhf063j7xq91k892flb7qm1c"))
+       (file-name (git-file-name name version))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:configure-flags
+       '("-DBUILD_SHARED_LIBS=ON"
+         "-DHTTPLIB_COMPILE=ON"
+         "-DHTTPLIB_REQUIRE_BROTLI=ON"
+         "-DHTTPLIB_REQUIRE_OPENSSL=ON"
+         "-DHTTPLIB_REQUIRE_ZLIB=ON")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'disable-network-tests
+           (lambda _
+             (for-each
+              (lambda (test)
+                (substitute* "test/test.cc"
+                  (((string-append "\\(" test))
+                   (string-append "(DISABLED_" test))))
+              ;; There are tests requiring network access, disable them
+              '("AbsoluteRedirectTest" "BaseAuthTest" "CancelTest"
+                "ChunkedEncodingTest" "ChunkedEncodingTest"
+                "DecodeWithChunkedEncoding" "DefaultHeadersTest"
+                "DigestAuthTest" "HttpsToHttpRedirectTest"
+                "RangeTest" "RedirectTest" "RelativeRedirectTest"
+                "SSLClientTest" "SendAPI" "TooManyRedirectTest" "UrlWithSpace"
+                "YahooRedirectTest" "YahooRedirectTest"))))
+         (replace 'check
+           (lambda* (#:key source tests? #:allow-other-keys)
+             ;; openssl genrsa wants to write a file in the git checkout
+             (when tests?
+               (with-directory-excursion "../source/test"
+                 (invoke "make"))))))))
+    (native-inputs
+     ;; required to build shared lib
+     `(("python" ,python)))
+    (inputs
+     `(("brotli" ,brotli)
+       ("openssl" ,openssl)
+       ("zlib" ,zlib)))
+    (home-page "https://github.com/yhirose/cpp-httplib")
+    (synopsis "C++ HTTP/HTTPS server and client library")
+    (description "cpp-httplib is a C++11 single-file cross platform blocking
+HTTP/HTTPS library, easy to setup.  It can also be used as a single-header
+library.")
+    (license license:expat)))
+
 (define-public cpplint
   (package
     (name "cpplint")