;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Ethan R. Jones <ethanrjones97@gmail.com>
;;;
;;; 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 cpp)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)  
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages python)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages icu4c)
  #:use-module (gnu packages bash))

(define-public libzen
  (package
    (name "libzen")
    (version "0.4.35")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://mediaarea.net/download/source/"
                                  name "/" version "/"
                                  name "_" version ".tar.bz2"))
              (sha256
               (base32
                "12a1icgcffgv503ii2k1453kxg5hfly09mf4zjcc80aq8a6rf8by"))))
    (native-inputs
     `(("autoconf" ,autoconf)
       ("automake" ,automake)
       ("libtool" ,libtool)))
    (build-system gnu-build-system)
    (arguments
     '(#:phases
       ;; build scripts not in root of archive
       (modify-phases %standard-phases
         (add-after 'unpack 'pre-configure
           (lambda _
             (chdir "Project/GNU/Library")))
         (add-after 'pre-configure 'autogen
           (lambda _
             (zero? (system* "sh" "autogen.sh")))))))
    (home-page "https://github.com/MediaArea/ZenLib")
    (synopsis "C++ utility library")
    (description "ZenLib is a C++ utility library.  It includes classes for handling
strings, configuration, bit streams, threading, translation, and cross-platform
operating system functions.")
    (license license:zlib)))

(define-public dbus-test-runner
  (package
    (name "dbus-test-runner")
    (version "12.10.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://launchpad.net/"
                   name "/12.10/" version "/+download/"
                   name "-" version ".tar.gz"))
              (sha256
               (base32
                "0psjmdgyg3f7mirr9snb3x5xyhmgpwmr17rq54b8zy58915amwki"))))
    (inputs
     `(("glib" ,glib)
       ("glib" ,dbus-glib)))
    (native-inputs
     `(("glib" ,intltool)
       ("pkg-config" ,pkg-config)))
    (build-system gnu-build-system)
    (arguments
     ;; FIXME tests fail (reproducible on ubuntu)
     '(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         ;; Need to remove -Werror from compile makefile
         (add-after 'unpack 'patch-werror-compile
           (lambda _ (substitute* "src/Makefile.in"
                       (("-Wall -Werror -Wextra") ""))
                   #t))
         ;; Need to remove -Werror from test/check makefile
         (add-after 'patch-werror-compile 'patch-werror-check
           (lambda _ (substitute* "tests/Makefile.in"
                       (("-Wall -Werror") "")
                       (("-Wall -Werror") "")
                       (("-Wall -Werror") "")
                       (("-Wall -Werror") ""))
                   #t)))))
     (home-page "https://launchpad.net/dbus-test-runner")
     (synopsis "DBus session tester")
     (description "A small little utility to run a couple of executables
under a new DBus session for testing.")
     (license license:gpl3)))

(define-public dee
  (package
    (name "dee")
    (version "1.2.7")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://launchpad.net/dee/1.0/"
                                  version "/+download/" name "-" version ".tar.gz"))
              (sha256
               (base32
                "12mzffk0lyd566y46x57jlvb9af152b4dqpasr40zal4wrn37w0v"))))
    (inputs
     `(("glib" ,dbus)
       ("glib" ,glib)
       ("glib" ,gobject-introspection)
       ("icu4c" ,icu4c)
       ("cpp" ,dbus-test-runner)))
    (native-inputs
     `(("python" ,python-2)
       ("pkg-config" ,pkg-config)))
    (arguments
     ;; FIXME add gtester??
     `(#:tests? #f))
    (build-system gnu-build-system)
    (home-page "https://launchpad.net/dee")
    (synopsis "DBus MVC Library")
    (description "Libdee is a library that uses DBus to provide
objects allowing you to create Model-View-Controller type programs across DBus.
It also consists of utility objects which extend DBus allowing for peer-to-peer
discoverability of known objects without needing a central registrar.")
    (license license:lgpl3)))


;; FIXME two origins??
(define-public breakpad
  (package
    (name "breakpad")
    (version "2018-02-02") ; Google does not tag releases
    (source (origin
              (method git-fetch) ; Google does not release tarballs
              (uri (git-reference
                    (url "https://chromium.googlesource.com/breakpad/breakpad")
                    (commit "6bb6c9b26afd9844b9e35fcaa39fb24893e7abb5")))
              (sha256
               (base32
                "162pgqbh4ddhnb8mvn2c3icc4sfmxbipj4r6r23g422q883v53il"))))
            ;; (origin
            ;;   (method git-fetch) ; Set of headers needed for Linux
            ;;   (uri (git-reference
            ;;         (url "https://chromium.googlesource.com/linux-syscall-support")
            ;;         (commit "a89bf7903f3169e6bc7b8efc10a73a7571de21cf")))
            ;;   (sha256
            ;;    (base32
            ;;     "162pgqbh4ddhnb8mvn2c3icc4sfmxbipj4r6r23g422q883v53il"))))
    (build-system gnu-build-system)
    (home-page "https://chromium.googlesource.com/breakpad/breakpad/")
    (synopsis "Crash-reporting system")
    (description "A set of client and server components which implement
a crash-reporting system.")
    (license license:bsd-3)))
