diff options
Diffstat (limited to 'guix/build-system')
-rw-r--r-- | guix/build-system/chicken.scm | 10 | ||||
-rw-r--r-- | guix/build-system/dune.scm | 18 | ||||
-rw-r--r-- | guix/build-system/glib-or-gtk.scm | 144 | ||||
-rw-r--r-- | guix/build-system/go.scm | 161 | ||||
-rw-r--r-- | guix/build-system/linux-module.scm | 2 | ||||
-rw-r--r-- | guix/build-system/meson.scm | 9 | ||||
-rw-r--r-- | guix/build-system/minetest.scm | 99 | ||||
-rw-r--r-- | guix/build-system/minify.scm | 4 |
8 files changed, 408 insertions, 39 deletions
diff --git a/guix/build-system/chicken.scm b/guix/build-system/chicken.scm index c6978266fc..07666d1321 100644 --- a/guix/build-system/chicken.scm +++ b/guix/build-system/chicken.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 raingloom <raingloom@riseup.net> ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; ;;; This file is part of GNU Guix. ;;; @@ -29,7 +30,14 @@ #:use-module (ice-9 match) #:export (%chicken-build-system-modules chicken-build - chicken-build-system)) + chicken-build-system + egg-uri)) + +(define* (egg-uri name version #:optional (extension ".tar.gz")) + "Return a URI string for the CHICKEN egg corresponding to NAME and VERSION. +EXTENSION is the file name extension, such as '.tar.gz'." + (string-append "https://code.call-cc.org/egg-tarballs/5/" + name "/" name "-" version extension)) (define %chicken-build-system-modules ;; Build-side modules imported and used by default. diff --git a/guix/build-system/dune.scm b/guix/build-system/dune.scm index 8c33e096f5..12100fd8e8 100644 --- a/guix/build-system/dune.scm +++ b/guix/build-system/dune.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2016, 2017, 2018 Julien Lepiller <julien@lepiller.eu> ;;; Copyright © 2017 Ben Woodcroft <donttrustben@gmail.com> ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2021 pukkamustard <pukkamustard@posteo.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -60,6 +61,17 @@ #:allow-other-keys #:rest arguments) "Return a bag for NAME." + + ;; Flags that put dune into reproducible build mode. + (define dune-release-flags + (if (version>=? (package-version dune) "2.5.0") + ;; For dune >= 2.5.0 this is just --release. + ''("--release") + ;; --release does not exist before 2.5.0. Replace with flags compatible + ;; with our old ocaml4.07-dune (1.11.3) + ''("--root" "." "--ignore-promoted-rules" "--no-config" + "--profile" "release"))) + (define private-keywords '(#:target #:dune #:findlib #:ocaml #:inputs #:native-inputs)) @@ -79,7 +91,9 @@ (build-inputs `(("dune" ,dune) ,@(bag-build-inputs base))) (build dune-build) - (arguments (strip-keyword-arguments private-keywords arguments)))))) + (arguments (append + `(#:dune-release-flags ,dune-release-flags) + (strip-keyword-arguments private-keywords arguments))))))) (define* (dune-build name inputs #:key @@ -90,6 +104,7 @@ (out-of-source? #t) (jbuild? #f) (package #f) + (dune-release-flags ''()) (tests? #t) (test-flags ''()) (test-target "test") @@ -129,6 +144,7 @@ provides a 'setup.ml' file as its build system." #:out-of-source? #$out-of-source? #:jbuild? #$jbuild? #:package #$package + #:dune-release-flags #$dune-release-flags #:tests? #$tests? #:test-target #$test-target #:install-target #$install-target diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm index 2df49a2495..ec491ff0bd 100644 --- a/guix/build-system/glib-or-gtk.scm +++ b/guix/build-system/glib-or-gtk.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2013, 2014, 2015, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com> ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch> +;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ #:use-module (ice-9 match) #:export (%glib-or-gtk-build-system-modules glib-or-gtk-build + glib-or-gtk-cross-build glib-or-gtk-build-system)) ;; Commentary: @@ -82,30 +84,42 @@ #:key source inputs native-inputs outputs system target (glib (default-glib)) (implicit-inputs? #t) + (implicit-cross-inputs? #t) (strip-binaries? #t) #:allow-other-keys #:rest arguments) "Return a bag for NAME." (define private-keywords - '(#:target #:glib #:inputs #:native-inputs - #:outputs #:implicit-inputs?)) + `(#:glib #:inputs #:native-inputs + #:outputs #:implicit-inputs? #:implicit-cross-inputs? + ,@(if target '() '(#:target)))) - (and (not target) ;XXX: no cross-compilation - (bag - (name name) - (system system) - (host-inputs (if source - `(("source" ,source)) - '())) - (build-inputs `(,@native-inputs - ,@inputs - ("glib:bin" ,glib "bin") ; to compile schemas - ,@(if implicit-inputs? - (standard-packages) - '()))) - (outputs outputs) - (build glib-or-gtk-build) - (arguments (strip-keyword-arguments private-keywords arguments))))) + (bag + (name name) + (system system) (target target) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@(if target + inputs + '()))) + (build-inputs `(,@native-inputs + ,@(if target '() inputs) + ("glib:bin" ,glib "bin") ; to compile schemas + ;; Keep standard inputs of gnu-build-system. + ,@(if (and target implicit-cross-inputs?) + (standard-cross-packages target 'host) + '()) + ,@(if implicit-inputs? + (standard-packages) + '()))) + ;; Keep standard inputs of 'gnu-build-system'. + (target-inputs (if (and target implicit-cross-inputs?) + (standard-cross-packages target 'target) + '())) + (outputs outputs) + (build (if target glib-or-gtk-cross-build glib-or-gtk-build)) + (arguments (strip-keyword-arguments private-keywords arguments)))) (define* (glib-or-gtk-build name inputs #:key guile source @@ -176,6 +190,100 @@ #:disallowed-references disallowed-references #:guile-for-build guile))) +(define* (glib-or-gtk-cross-build name + #:key + target + build-inputs target-inputs host-inputs + guile source + (outputs '("out")) + (search-paths '()) + (native-search-paths '()) + (configure-flags ''()) + ;; Disable icon theme cache generation. + (make-flags ''("gtk_update_icon_cache=true")) + (out-of-source? #f) + (tests? #f) + (test-target "check") + (parallel-build? #t) + (parallel-tests? #t) + (validate-runpath? #t) + (make-dynamic-linker-cache? #f) + (patch-shebangs? #t) + (strip-binaries? #t) + (strip-flags ''("--strip-debug")) + (strip-directories ''("lib" "lib64" "libexec" + "bin" "sbin")) + (phases '(@ (guix build glib-or-gtk-build-system) + %standard-phases)) + (glib-or-gtk-wrap-excluded-outputs ''()) + (system (%current-system)) + (build (nix-system->gnu-triplet system)) + (imported-modules %glib-or-gtk-build-system-modules) + (modules %default-modules) + allowed-references + disallowed-references) + "Cross-build SOURCE with INPUTS. See GNU-BUILD for more details." + (define builder + #~(begin + (use-modules #$@(sexp->gexp modules)) + + (define %build-host-inputs + #+(input-tuples->gexp build-inputs)) + + (define %build-target-inputs + (append #$(input-tuples->gexp host-inputs) + #+(input-tuples->gexp target-inputs))) + + (define %build-inputs + (append %build-host-inputs %build-target-inputs)) + + (define %outputs + #$(outputs->gexp outputs)) + + (glib-or-gtk-build #:source #+source + #:system #$system + #:build #$build + #:target #$target + #:outputs %outputs + #:inputs %build-target-inputs + #:native-inputs %build-host-inputs + #:search-paths '#$(sexp->gexp + (map search-path-specification->sexp + search-paths)) + #:native-search-paths '#$(sexp->gexp + (map search-path-specification->sexp + native-search-paths)) + #:phases #$(if (pair? phases) + (sexp->gexp phases) + phases) + #:glib-or-gtk-wrap-excluded-outputs + #$glib-or-gtk-wrap-excluded-outputs + #:configure-flags #$configure-flags + #:make-flags #$make-flags + #:out-of-source? #$out-of-source? + #:tests? #$tests? + #:test-target #$test-target + #:parallel-build? #$parallel-build? + #:parallel-tests? #$parallel-tests? + #:validate-runpath? #$validate-runpath? + #:make-dynamic-linker-cache? #$make-dynamic-linker-cache? + #:patch-shebangs? #$patch-shebangs? + #:strip-binaries? #$strip-binaries? + #:strip-flags #$(sexp->gexp strip-flags) + #:strip-directories + #$(sexp->gexp strip-directories)))) + + + (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) + system #:graft? #f))) + (gexp->derivation name builder + #:system system + #:target target + #:modules imported-modules + #:allowed-references allowed-references + #:disallowed-references disallowed-references + #:guile-for-build guile))) + (define glib-or-gtk-build-system (build-system (name 'glib-or-gtk) diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm index 100d1db4b6..b62f2a897b 100644 --- a/guix/build-system/go.scm +++ b/guix/build-system/go.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2017 Leo Famulari <leo@famulari.name> ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il> ;;; ;;; This file is part of GNU Guix. ;;; @@ -30,6 +31,7 @@ #:use-module (guix packages) #:use-module (ice-9 match) #:use-module (ice-9 regex) + #:use-module (srfi srfi-1) #:export (%go-build-system-modules go-build go-build-system @@ -81,6 +83,24 @@ present) if a pseudo-version pattern is not recognized." commit hash and its date rather than a proper release tag." (regexp-exec %go-pseudo-version-rx version)) +(define (go-target target) + ;; Parse the nix-system equivalent of the target and set the + ;; target for compilation accordingly. + (match (string-split (gnu-triplet->nix-system target) #\-) + ((arch os) + (list (match arch + ("aarch64" "arm64") + ("armhf" "arm") + ("powerpc64le" "ppc64le") + ("powerpc64" "ppc64") + ("i686" "386") + ("x86_64" "amd64") + ("mips64el" "mips64le") + (_ arch)) + (match os + ((or "mingw32" "cygwin") "windows") + (_ os)))))) + (define %go-build-system-modules ;; Build-side modules imported and used by default. `((guix build go-build-system) @@ -101,22 +121,37 @@ commit hash and its date rather than a proper release tag." (define private-keywords '(#:target #:go #:inputs #:native-inputs)) - (and (not target) ;XXX: no cross-compilation - (bag - (name name) - (system system) - (host-inputs `(,@(if source - `(("source" ,source)) - '()) - ,@inputs + (bag + (name name) + (system system) + (target target) + (build-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@`(("go" ,go)) + ,@native-inputs + ,@(if target '() inputs) + ,@(if target + ;; Use the standard cross inputs of + ;; 'gnu-build-system'. + (standard-cross-packages target 'host) + '()) + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (host-inputs (if target inputs '())) + + ;; The cross-libc is really a target package, but for bootstrapping + ;; reasons, we can't put it in 'host-inputs'. Namely, 'cross-gcc' is a + ;; native package, so it would end up using a "native" variant of + ;; 'cross-libc' (built with 'gnu-build'), whereas all the other packages + ;; would use a target variant (built with 'gnu-cross-build'.) + (target-inputs (if target + (standard-cross-packages target 'target) + '())) - ;; Keep the standard inputs of 'gnu-build-system'. - ,@(standard-packages))) - (build-inputs `(("go" ,go) - ,@native-inputs)) - (outputs outputs) - (build go-build) - (arguments (strip-keyword-arguments private-keywords arguments))))) + (outputs outputs) + (build (if target go-cross-build go-build)) + (arguments (strip-keyword-arguments private-keywords arguments)))) (define* (go-build name inputs #:key @@ -131,6 +166,8 @@ commit hash and its date rather than a proper release tag." (tests? #t) (allow-go-reference? #f) (system (%current-system)) + (goarch (first (go-target (%current-system)))) + (goos (last (go-target (%current-system)))) (guile #f) (imported-modules %go-build-system-modules) (modules '((guix build go-build-system) @@ -145,6 +182,8 @@ commit hash and its date rather than a proper release tag." #:system #$system #:phases #$phases #:outputs #$(outputs->gexp outputs) + #:goarch #$goarch + #:goos #$goos #:search-paths '#$(sexp->gexp (map search-path-specification->sexp search-paths)) @@ -162,6 +201,98 @@ commit hash and its date rather than a proper release tag." #:system system #:guile-for-build guile))) +(define* (go-cross-build store name + #:key + target native-drvs target-drvs + (phases '(@ (guix build go-build-system) + %standard-phases)) + (outputs '("out")) + (search-paths '()) + (native-search-paths '()) + (install-source? #t) + (import-path "") + (unpack-path "") + (build-flags ''()) + (tests? #f) ; nothing can be done + (allow-go-reference? #f) + (system (%current-system)) + (goarch (first (go-target target))) + (goos (last (go-target target))) + (guile #f) + (imported-modules %go-build-system-modules) + (modules '((guix build go-build-system) + (guix build union) + (guix build utils)))) + "Cross-build NAME using GO, where TARGET is a GNU triplet and with INPUTS." + (define builder + `(begin + (use-modules ,@modules) + (let () + (define %build-host-inputs + ',(map (match-lambda + ((name (? derivation? drv) sub ...) + `(,name . ,(apply derivation->output-path drv sub))) + ((name path) + `(,name . ,path))) + native-drvs)) + + (define %build-target-inputs + ',(map (match-lambda + ((name (? derivation? drv) sub ...) + `(,name . ,(apply derivation->output-path drv sub))) + ((name (? package? pkg) sub ...) + (let ((drv (package-cross-derivation store pkg + target system))) + `(,name . ,(apply derivation->output-path drv sub)))) + ((name path) + `(,name . ,path))) + target-drvs)) + + (go-build #:name ,name + #:source ,(match (assoc-ref native-drvs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:system ,system + #:phases ,phases + #:outputs %outputs + #:target ,target + #:goarch ,goarch + #:goos ,goos + #:inputs %build-target-inputs + #:native-inputs %build-host-inputs + #:search-paths ',(map search-path-specification->sexp + search-paths) + #:native-search-paths ',(map + search-path-specification->sexp + native-search-paths) + #:install-source? ,install-source? + #:import-path ,import-path + #:unpack-path ,unpack-path + #:build-flags ,build-flags + #:tests? ,tests? + #:allow-go-reference? ,allow-go-reference? + #:inputs %build-inputs)))) + + (define guile-for-build + (match guile + ((? package?) + (package-derivation store guile system #:graft? #f)) + (#f ; the default + (let* ((distro (resolve-interface '(gnu packages commencement))) + (guile (module-ref distro 'guile-final))) + (package-derivation store guile system #:graft? #f))))) + + (build-expression->derivation store name builder + #:system system + #:inputs (append native-drvs target-drvs) + #:outputs outputs + #:modules imported-modules + #:guile-for-build guile-for-build)) + (define go-build-system (build-system (name 'go) diff --git a/guix/build-system/linux-module.scm b/guix/build-system/linux-module.scm index 84570b923a..7bafee5a7a 100644 --- a/guix/build-system/linux-module.scm +++ b/guix/build-system/linux-module.scm @@ -159,6 +159,7 @@ (outputs '("out")) (make-flags ''()) (system (%current-system)) + (source-directory ".") (guile #f) (substitutable? #t) (imported-modules @@ -172,6 +173,7 @@ (use-modules #$@(sexp->gexp modules)) (linux-module-build #:name #$name #:source #+source + #:source-directory #$source-directory #:search-paths '#$(sexp->gexp (map search-path-specification->sexp search-paths)) diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm index dae0abde94..dcad3f322d 100644 --- a/guix/build-system/meson.scm +++ b/guix/build-system/meson.scm @@ -212,7 +212,10 @@ has a 'meson.build' file." (map search-path-specification->sexp search-paths)) #:phases build-phases - #:configure-flags #$(sexp->gexp configure-flags) + #:configure-flags + #$(if (pair? configure-flags) + (sexp->gexp configure-flags) + configure-flags) #:build-type #$build-type #:tests? #$tests? #:test-target #$test-target @@ -309,7 +312,9 @@ SOURCE has a 'meson.build' file." #:phases build-phases #:make-dynamic-linker-cache? #$make-dynamic-linker-cache? #:configure-flags `("--cross-file" #+cross-file - ,@#$(sexp->gexp configure-flags)) + ,@#$(if (pair? configure-flags) + (sexp->gexp configure-flags) + configure-flags)) #:build-type #$build-type #:tests? #$tests? #:test-target #$test-target diff --git a/guix/build-system/minetest.scm b/guix/build-system/minetest.scm new file mode 100644 index 0000000000..1fae3a47e9 --- /dev/null +++ b/guix/build-system/minetest.scm @@ -0,0 +1,99 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> +;;; +;;; 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 (guix build-system minetest) + #:use-module (guix build-system copy) + #:use-module (guix build-system gnu) + #:use-module (guix build-system) + #:use-module (guix utils) + #:export (minetest-mod-build-system)) + +;; +;; Build procedure for minetest mods. This is implemented as an extension +;; of ‘copy-build-system’. +;; +;; Code: + +;; Lazily resolve the bindings to avoid circular dependencies. +(define (default-optipng) + ;; Lazily resolve the binding to avoid a circular dependency. + (module-ref (resolve-interface '(gnu packages image)) 'optipng)) + +(define (default-minetest) + (module-ref (resolve-interface '(gnu packages minetest)) 'minetest)) + +(define (default-xvfb-run) + (module-ref (resolve-interface '(gnu packages xorg)) 'xvfb-run)) + +(define %minetest-build-system-modules + ;; Build-side modules imported by default. + `((guix build minetest-build-system) + ,@%copy-build-system-modules)) + +(define %default-modules + ;; Modules in scope in the build-side environment. + '((guix build gnu-build-system) + (guix build minetest-build-system) + (guix build utils))) + +(define (standard-minetest-packages) + "Return the list of (NAME PACKAGE OUTPUT) or (NAME PACKAGE) tuples of +standard packages used as implicit inputs of the Minetest build system." + `(("xvfb-run" ,(default-xvfb-run)) + ("optipng" ,(default-optipng)) + ("minetest" ,(default-minetest)) + ,@(filter (lambda (input) + (member (car input) + '("libc" "tar" "gzip" "bzip2" "xz" "locales"))) + (standard-packages)))) + +(define* (lower-mod name #:key (implicit-inputs? #t) #:allow-other-keys + #:rest arguments) + (define lower (build-system-lower gnu-build-system)) + (apply lower + name + (substitute-keyword-arguments arguments + ;; minetest-mod-build-system adds implicit inputs by itself, + ;; so don't let gnu-build-system add its own implicit inputs + ;; as well. + ((#:implicit-inputs? implicit-inputs? #t) + #f) + ((#:implicit-cross-inputs? implicit-cross-inputs? #t) + #f) + ((#:imported-modules imported-modules %minetest-build-system-modules) + imported-modules) + ((#:modules modules %default-modules) + modules) + ((#:phases phases '%standard-phases) + phases) + ;; Ensure nothing sneaks into the closure. + ((#:allowed-references allowed-references '()) + allowed-references) + ;; Add the implicit inputs. + ((#:native-inputs native-inputs '()) + (if implicit-inputs? + (append native-inputs (standard-minetest-packages)) + native-inputs))))) + +(define minetest-mod-build-system + (build-system + (name 'minetest-mod) + (description "The build system for minetest mods") + (lower lower-mod))) + +;;; minetest.scm ends here diff --git a/guix/build-system/minify.scm b/guix/build-system/minify.scm index 3256b5d30b..7d4745ab32 100644 --- a/guix/build-system/minify.scm +++ b/guix/build-system/minify.scm @@ -46,8 +46,8 @@ (define (default-uglify-js) "Return the default package to minify JavaScript source files." ;; Lazily resolve the binding to avoid a circular dependency. - (let ((mod (resolve-interface '(gnu packages lisp-xyz)))) - (module-ref mod 'uglify-js))) + (let ((mod (resolve-interface '(gnu packages uglifyjs)))) + (module-ref mod 'uglifyjs))) (define* (lower name #:key source inputs native-inputs outputs system |