diff mbox

[v6,1/2] gnu: Add arduino-libraries.

Message ID 20160830190155.11668-2-dannym@scratchpost.org
State New
Headers show

Commit Message

Danny Milosavljevic Aug. 30, 2016, 7:01 p.m. UTC
* gnu/packages/arduino.scm (arduino-installer, arduino-libraries): New variables.
* gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch: New file.
* gnu/local.mk (dist_patch_DATA, GNU_SYSTEM_MODULES): Add them.
---
 gnu/local.mk                                       |  2 +
 gnu/packages/arduino.scm                           | 91 ++++++++++++++++++++++
 ...aries-hardware-remove-__cxa_guard_acquire.patch | 13 ++++
 3 files changed, 106 insertions(+)
 create mode 100644 gnu/packages/arduino.scm
 create mode 100644 gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch

Comments

Ricardo Wurmus Aug. 31, 2016, 8:08 p.m. UTC | #1
Danny Milosavljevic <dannym@scratchpost.org> writes:

> * gnu/packages/arduino.scm (arduino-installer, arduino-libraries): New variables.

I think we’d just write “New file.” without mentioning the new variables.

> * gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch: New file.
> * gnu/local.mk (dist_patch_DATA, GNU_SYSTEM_MODULES): Add them.
> ---

[…]

> +(define-module (gnu packages arduino)
> +  #:use-module ((guix licenses) #:prefix license:)
> +  #:use-module (guix utils)
> +  #:use-module (guix download)
> +  #:use-module (guix packages)
> +  #:use-module (guix build-system gnu)
> +  #:use-module (guix build-system python)
> +  #:use-module (guix build-system ant)
> +  #:use-module (gnu packages)
> +  #:use-module (gnu packages avr)
> +  #:use-module (gnu packages flashing-tools)
> +  #:use-module (gnu packages java)
> +  #:use-module (gnu packages python))
> +
> +(define (arduino-installer filenames)
> +  `(lambda* (#:key outputs #:allow-other-keys)
> +    (let* ((out (assoc-ref outputs "out"))
> +           (out-share (string-append out "/share/arduino")))
> +      (mkdir-p out-share)
> +      (for-each
> +        (lambda (filename)
> +          (let* ((out-share-part (string-append out-share "/" filename)))
> +            (copy-recursively filename out-share-part)))
> +        (list ,@filenames)))))

As this is only used by “arduino-libraries” and probably no other
package I’d move this into the definition of “arduino-libraries”.

> +(define-public arduino-libraries
> +  (package
> +    (name "arduino-libraries")
> +    (version "1.6.10")
> +    (source (origin
> +              (method url-fetch)
> +              (uri (string-append "https://github.com/arduino/Arduino/"
> +                                  "archive/" version ".tar.gz"))
> +              (sha256
> +               (base32
> +                "15gbg64i2ac6d0mlnbla567sn26494cvqwf5q53xzf4b5v2rb0jc"))
> +              (file-name (string-append name "-" version ".tar.gz"))
> +              (modules '((guix build utils)))
> +              (snippet
> +                 '(begin
> +                    ;; Delete bundled jar archives.
> +                    (for-each delete-file (find-files "." "\\.jar$"))
> +                    ;; Delete non-Free Software
> +                    (delete-file-recursively "libraries/WiFi/extras/wifiHD")
> +                    (delete-file-recursively "libraries/WiFi/extras/wifi_dnld")
> +                    #t))
> +              (patches (search-patches
> +                        "arduino-libraries-hardware-remove-__cxa_guard_acquire.patch"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:tests? #f ; no tests exist
> +       #:phases
> +        (modify-phases %standard-phases
> +          (delete 'configure)
> +          (delete 'build)
> +          (replace 'install ,(arduino-installer '("libraries" "hardware"))))))
> +    (home-page "https://www.arduino.cc/")
> +    (synopsis "Arduino Libraries and Hardware Spec Files")

Please use lower case.

> +    (description "arduino-libraries contains libraries and Arduino
> +hardware spec files (boards.txt).")

s/arduino-libraries/This package/

Could you expand the description a little?  Maybe one more sentence.

> +    ;; gpl covers the main body ("app", "core").
> +    ;; lgpl2.1+ covers the remainder mostly.
> +    ;; Exceptions are:
> +    ;;   libraries/Ethernet/src/Dns*: asl2.0
> +    ;;   libraries/Ethernet/src/EthernetUdp*: expat
> +    ;;   libraries/Ethernet/src/utility/w5100*: lgpl2.1

Only 2.1?  Or is a later version okay?

> +    ;;   libraries/SD: gpl3+
> +    ;;   libraries/TFT: bsd-3
> +    ;;   libraries/WiFi: bsd-3

Nitpick: the license names should be capitalised.

> +    (license (list license:lgpl2.1+
> +                   license:asl2.0
> +                   license:expat
> +                   license:bsd-3))))

The list should also include “gpl3+”.

> diff --git a/gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch b/gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch

Please add a comment at the very top of this patch to explain what its
purpose is.

Thanks!

~~ Ricardo
Danny Milosavljevic Aug. 31, 2016, 8:40 p.m. UTC | #2
> As this is only used by “arduino-libraries” and probably no other
> package I’d move this into the definition of “arduino-libraries”.

I suppressed arduino-core in this patch series. It will be used by others.

> Could you expand the description a little?  Maybe one more sentence.

What should I write?

Would "There are libraries for Ethernet, GSM, LCD, SD drives, servos, stepper motors, TFT displays and WiFi. " be OK?

> > +    ;;   libraries/Ethernet/src/utility/w5100*: lgpl2.1  
> 
> Only 2.1?  Or is a later version okay?

Only 2.1.

> > diff --git a/gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch b/gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch  
> 
> Please add a comment at the very top of this patch to explain what its
> purpose is.

"Removes function-static variable. Our avr-gcc chokes on it otherwise." ?
diff mbox

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d75ab54..66ef07b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -40,6 +40,7 @@  GNU_SYSTEM_MODULES =				\
   %D%/packages/anthy.scm			\
   %D%/packages/apl.scm				\
   %D%/packages/apr.scm				\
+  %D%/packages/arduino.scm			\
   %D%/packages/aspell.scm			\
   %D%/packages/assembly.scm			\
   %D%/packages/attr.scm				\
@@ -439,6 +440,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/antiword-CVE-2014-8123.patch			\
   %D%/packages/patches/apr-skip-getservbyname-test.patch	\
   %D%/packages/patches/arb-ldconfig.patch			\
+  %D%/packages/patches/arduino-hardware-patch-out-__cxa_guard_acquire.patch \
   %D%/packages/patches/ath9k-htc-firmware-binutils.patch	\
   %D%/packages/patches/ath9k-htc-firmware-gcc.patch		\
   %D%/packages/patches/ath9k-htc-firmware-objcopy.patch		\
diff --git a/gnu/packages/arduino.scm b/gnu/packages/arduino.scm
new file mode 100644
index 0000000..5309587
--- /dev/null
+++ b/gnu/packages/arduino.scm
@@ -0,0 +1,91 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org>
+;;;
+;;; 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 arduino)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix utils)
+  #:use-module (guix download)
+  #:use-module (guix packages)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system python)
+  #:use-module (guix build-system ant)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages avr)
+  #:use-module (gnu packages flashing-tools)
+  #:use-module (gnu packages java)
+  #:use-module (gnu packages python))
+
+(define (arduino-installer filenames)
+  `(lambda* (#:key outputs #:allow-other-keys)
+    (let* ((out (assoc-ref outputs "out"))
+           (out-share (string-append out "/share/arduino")))
+      (mkdir-p out-share)
+      (for-each
+        (lambda (filename)
+          (let* ((out-share-part (string-append out-share "/" filename)))
+            (copy-recursively filename out-share-part)))
+        (list ,@filenames)))))
+
+(define-public arduino-libraries
+  (package
+    (name "arduino-libraries")
+    (version "1.6.10")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/arduino/Arduino/"
+                                  "archive/" version ".tar.gz"))
+              (sha256
+               (base32
+                "15gbg64i2ac6d0mlnbla567sn26494cvqwf5q53xzf4b5v2rb0jc"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (modules '((guix build utils)))
+              (snippet
+                 '(begin
+                    ;; Delete bundled jar archives.
+                    (for-each delete-file (find-files "." "\\.jar$"))
+                    ;; Delete non-Free Software
+                    (delete-file-recursively "libraries/WiFi/extras/wifiHD")
+                    (delete-file-recursively "libraries/WiFi/extras/wifi_dnld")
+                    #t))
+              (patches (search-patches
+                        "arduino-libraries-hardware-remove-__cxa_guard_acquire.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ; no tests exist
+       #:phases
+        (modify-phases %standard-phases
+          (delete 'configure)
+          (delete 'build)
+          (replace 'install ,(arduino-installer '("libraries" "hardware"))))))
+    (home-page "https://www.arduino.cc/")
+    (synopsis "Arduino Libraries and Hardware Spec Files")
+    (description "arduino-libraries contains libraries and Arduino
+hardware spec files (boards.txt).")
+    ;; gpl covers the main body ("app", "core").
+    ;; lgpl2.1+ covers the remainder mostly.
+    ;; Exceptions are:
+    ;;   libraries/Ethernet/src/Dns*: asl2.0
+    ;;   libraries/Ethernet/src/EthernetUdp*: expat
+    ;;   libraries/Ethernet/src/utility/w5100*: lgpl2.1
+    ;;   libraries/SD: gpl3+
+    ;;   libraries/TFT: bsd-3
+    ;;   libraries/WiFi: bsd-3
+    (license (list license:lgpl2.1+
+                   license:asl2.0
+                   license:expat
+                   license:bsd-3))))
diff --git a/gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch b/gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch
new file mode 100644
index 0000000..75d12cf
--- /dev/null
+++ b/gnu/packages/patches/arduino-libraries-hardware-remove-__cxa_guard_acquire.patch
@@ -0,0 +1,13 @@ 
+--- ./hardware/arduino/avr/cores/arduino/PluggableUSB.cpp.orig	2016-08-16 04:40:10.449580005 +0200
++++ ./hardware/arduino/avr/cores/arduino/PluggableUSB.cpp	2016-08-16 04:40:17.661634498 +0200
+@@ -97,9 +97,9 @@
+ 	// restart USB layer???
+ }
+ 
++static PluggableUSB_ obj;
+ PluggableUSB_& PluggableUSB()
+ {
+-	static PluggableUSB_ obj;
+ 	return obj;
+ }
+