@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -56,22 +57,28 @@ (define* (lower name
(define private-keywords
'(#:target #:scons #:inputs #:native-inputs))
- (and (not target) ;XXX: no cross-compilation
- (bag
- (name name)
- (system system)
- (host-inputs `(,@(if source
- `(("source" ,source))
- '())
- ,@inputs
-
- ;; Keep the standard inputs of 'gnu-build-system'.
- ,@(standard-packages)))
- (build-inputs `(("scons" ,scons)
- ,@native-inputs))
- (outputs outputs)
- (build scons-build)
- (arguments (strip-keyword-arguments private-keywords arguments)))))
+ (bag
+ (name name)
+ (system system)
+ (target target)
+ (build-inputs `(("scons" ,scons)
+ ,@(if source
+ `(("source" ,source))
+ '())
+ ,@native-inputs
+
+ ,@(if target '() inputs)
+ ,@(if target
+ (standard-cross-packages target 'host)
+ '())
+ ,@(standard-packages system)))
+ (host-inputs (if target inputs '()))
+ (target-inputs (if target
+ (standard-cross-packages target 'target)
+ '()))
+ (outputs outputs)
+ (build (if target scons-build-cross scons-build))
+ (arguments (strip-keyword-arguments private-keywords arguments))))
(define* (scons-build name inputs
#:key
@@ -122,6 +129,74 @@ (define* (scons-build name inputs
#:graft? #f
#:guile-for-build guile))
+(define* (scons-build-cross name
+ #:key
+ target
+ build-inputs target-inputs host-inputs
+ guile source
+ (tests? #f)
+ (scons-flags ''())
+ (build-targets #~'())
+ (test-target "test")
+ (install-targets #~'("install"))
+ (phases '%standard-phases)
+ (outputs '("out"))
+ (search-paths '())
+ (native-search-paths '())
+ (system (%current-system))
+ (build (nix-system->gnu-triplet system))
+ (imported-modules %scons-build-system-modules)
+ (modules '((guix build scons-build-system)
+ (guix build utils))))
+ (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))
+
+ (scons-build #:name #$name
+ #:source #+source
+ #:scons-flags #$(if (pair? scons-flags)
+ (sexp->gexp scons-flags)
+ scons-flags)
+ #:system #$system
+ #:build #$build
+ #:target #$target
+ #:build-targets #$build-targets
+ #:test-target #$test-target
+ #:tests? #$tests?
+ #:install-targets #$install-targets
+ #:phases #$(if (pair? phases)
+ (sexp->gexp phases)
+ phases)
+ #: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)))))
+
+ (gexp->derivation name builder
+ #:system system
+ #:target target
+ #:graft? #f
+ #:modules imported-modules
+ #:guile-for-build guile))
+
(define scons-build-system
(build-system
(name 'scons)