diff mbox series

[bug#66263,09/23] gnu: Add make-cross-gcc-toolchain.

Message ID 20230929091627.7820-9-jean@foundationdevices.com
State New
Headers show
Series guix: Add avr as a platform. | expand

Commit Message

Jean-Pierre De Jesus DIAZ Sept. 29, 2023, 9:16 a.m. UTC
* gnu/packages/cross-toolchain.scm (make-cross-gcc-toolchain): New
  procedure.
---
 gnu/local.mk                     |  1 +
 gnu/packages/cross-toolchain.scm | 58 ++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 gnu/packages/cross-toolchain.scm

Comments

Efraim Flashner Oct. 4, 2023, 2:07 p.m. UTC | #1
On Fri, Sep 29, 2023 at 11:16:13AM +0200, Jean-Pierre De Jesus DIAZ wrote:
> * gnu/packages/cross-toolchain.scm (make-cross-gcc-toolchain): New
>   procedure.
> ---
>  gnu/local.mk                     |  1 +
>  gnu/packages/cross-toolchain.scm | 58 ++++++++++++++++++++++++++++++++
>  2 files changed, 59 insertions(+)
>  create mode 100644 gnu/packages/cross-toolchain.scm
> 
> diff --git a/gnu/local.mk b/gnu/local.mk
> index bfa816d717..bdd3af5080 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -197,6 +197,7 @@ GNU_SYSTEM_MODULES =				\
>    %D%/packages/crates-graphics.scm		\
>    %D%/packages/crates-gtk.scm			\
>    %D%/packages/cross-base.scm			\
> +  %D%/packages/cross-toolchain.scm			\
>    %D%/packages/crypto.scm			\
>    %D%/packages/cryptsetup.scm			\
>    %D%/packages/cups.scm				\
> diff --git a/gnu/packages/cross-toolchain.scm b/gnu/packages/cross-toolchain.scm
> new file mode 100644
> index 0000000000..0062d043a0
> --- /dev/null
> +++ b/gnu/packages/cross-toolchain.scm
> @@ -0,0 +1,58 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.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 cross-toolchain)
> +  #:use-module (gnu packages avr)
> +  #:use-module (gnu packages cross-base)
> +  #:use-module (guix build-system trivial)
> +  #:use-module (guix packages)
> +  #:use-module (srfi srfi-1)
> +  #:export (make-cross-gcc-toolchain))
> +
> +(define* (make-cross-gcc-toolchain target
> +                                   #:key
> +                                   (libc (cross-libc target))
> +                                   (xgcc (cross-gcc target #:libc libc))
> +                                   (xbinutils (cross-binutils target)))
> +  (package
> +    (name (string-append (package-name xgcc) "-toolchain"))
> +    (version (package-version xgcc))
> +    (source #f)
> +    (build-system trivial-build-system)
> +    (arguments
> +     '(#:modules ((guix build union))
> +       #:builder (begin
> +         (use-modules (ice-9 match)
> +                      (guix build union))
> +
> +         (match %build-inputs
> +           (((names . directory) ...)
> +            (union-build (assoc-ref %outputs "out") directory))))))
> +    (inputs (list xgcc xbinutils libc))
> +    (native-search-paths (package-native-search-paths xgcc))
> +    (search-paths (package-search-paths xgcc))
> +    (properties (alist-delete 'hidden? (package-properties xgcc)))
> +    (license (package-license xgcc))

Trivial thing but the break in the synopsis really bothers me. I'd put
the string-append starting on the next line

> +    (synopsis (string-append "Complete GCC tool chain for C/C++ development ("
> +                             target ")"))
> +    (description
> +      "This package provides a complete GCC cross tool chain for C/C++
> +development to be installed in user profiles.  This includes GCC, as well as
> +libc (headers and binaries), and Binutils.  GCC is the GNU Compiler
> +Collection.")
> +    (home-page "https://gcc.gnu.org/")))
> -- 
> 2.34.1
> 
> 
>
Maxim Cournoyer Oct. 5, 2023, 4:34 a.m. UTC | #2
Hi,

Jean-Pierre De Jesus DIAZ <jean@foundationdevices.com> writes:

> * gnu/packages/cross-toolchain.scm (make-cross-gcc-toolchain): New
>   procedure.

You forgot to mention the registration of the new module in the local.mk
file.

[...]

> +++ b/gnu/packages/cross-toolchain.scm
> @@ -0,0 +1,58 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.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 cross-toolchain)
> +  #:use-module (gnu packages avr)
> +  #:use-module (gnu packages cross-base)
> +  #:use-module (guix build-system trivial)
> +  #:use-module (guix packages)
> +  #:use-module (srfi srfi-1)
> +  #:export (make-cross-gcc-toolchain))


I'm a bit confused; why do we need this new module; couldn't it live in
(gnu packages cross-base)?  Also, there are extraneous imports: (gnu packages
avr) is not needed for one.  With a recent Guile you can check for such
imports with

--8<---------------cut here---------------start------------->8---
guild compile -W3 your-file.scm
--8<---------------cut here---------------end--------------->8---

> +(define* (make-cross-gcc-toolchain target
> +                                   #:key
> +                                   (libc (cross-libc target))
> +                                   (xgcc (cross-gcc target #:libc libc))
> +                                   (xbinutils (cross-binutils target)))

Please add a doc string, and memoize packages returning procedures like
this one.

> +  (package
> +    (name (string-append (package-name xgcc) "-toolchain"))
> +    (version (package-version xgcc))
> +    (source #f)
> +    (build-system trivial-build-system)
> +    (arguments
> +     '(#:modules ((guix build union))
> +       #:builder (begin
> +         (use-modules (ice-9 match)
> +                      (guix build union))

This will work as long as all the file names are ASCII only, as there's
no locale support in the trivial-build-system.  I guess this is not a
problem here, but just mentioning it, as it bit me in the past.
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index bfa816d717..bdd3af5080 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -197,6 +197,7 @@  GNU_SYSTEM_MODULES =				\
   %D%/packages/crates-graphics.scm		\
   %D%/packages/crates-gtk.scm			\
   %D%/packages/cross-base.scm			\
+  %D%/packages/cross-toolchain.scm			\
   %D%/packages/crypto.scm			\
   %D%/packages/cryptsetup.scm			\
   %D%/packages/cups.scm				\
diff --git a/gnu/packages/cross-toolchain.scm b/gnu/packages/cross-toolchain.scm
new file mode 100644
index 0000000000..0062d043a0
--- /dev/null
+++ b/gnu/packages/cross-toolchain.scm
@@ -0,0 +1,58 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.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 cross-toolchain)
+  #:use-module (gnu packages avr)
+  #:use-module (gnu packages cross-base)
+  #:use-module (guix build-system trivial)
+  #:use-module (guix packages)
+  #:use-module (srfi srfi-1)
+  #:export (make-cross-gcc-toolchain))
+
+(define* (make-cross-gcc-toolchain target
+                                   #:key
+                                   (libc (cross-libc target))
+                                   (xgcc (cross-gcc target #:libc libc))
+                                   (xbinutils (cross-binutils target)))
+  (package
+    (name (string-append (package-name xgcc) "-toolchain"))
+    (version (package-version xgcc))
+    (source #f)
+    (build-system trivial-build-system)
+    (arguments
+     '(#:modules ((guix build union))
+       #:builder (begin
+         (use-modules (ice-9 match)
+                      (guix build union))
+
+         (match %build-inputs
+           (((names . directory) ...)
+            (union-build (assoc-ref %outputs "out") directory))))))
+    (inputs (list xgcc xbinutils libc))
+    (native-search-paths (package-native-search-paths xgcc))
+    (search-paths (package-search-paths xgcc))
+    (properties (alist-delete 'hidden? (package-properties xgcc)))
+    (license (package-license xgcc))
+    (synopsis (string-append "Complete GCC tool chain for C/C++ development ("
+                             target ")"))
+    (description
+      "This package provides a complete GCC cross tool chain for C/C++
+development to be installed in user profiles.  This includes GCC, as well as
+libc (headers and binaries), and Binutils.  GCC is the GNU Compiler
+Collection.")
+    (home-page "https://gcc.gnu.org/")))