File doc/guix.texi changed (mode: 100644) (index 8514dfe86f..e084144a82) |
... |
... |
cross-compiling: |
6558 |
6558 |
It is an error to refer to @code{this-package} outside a package definition. |
It is an error to refer to @code{this-package} outside a package definition. |
6559 |
6559 |
@end deffn |
@end deffn |
6560 |
6560 |
|
|
|
6561 |
|
Because packages are regular Scheme objects that capture a complete |
|
6562 |
|
dependency graph and associated build procedures, it is often useful to |
|
6563 |
|
write procedures that take a package and return a modified version |
|
6564 |
|
thereof according to some parameters. Below are a few examples. |
|
6565 |
|
|
|
6566 |
|
@cindex tool chain, choosing a package's tool chain |
|
6567 |
|
@deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain} |
|
6568 |
|
Return a variant of @var{package} that uses @var{toolchain} instead of |
|
6569 |
|
the default GNU C/C++ toolchain. @var{toolchain} must be a list of |
|
6570 |
|
inputs (label/package tuples) providing equivalent functionality, such |
|
6571 |
|
as the @code{gcc-toolchain} package. |
|
6572 |
|
|
|
6573 |
|
The example below returns a variant of the @code{hello} package built |
|
6574 |
|
with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the |
|
6575 |
|
GNU C Library) instead of the default tool chain: |
|
6576 |
|
|
|
6577 |
|
@lisp |
|
6578 |
|
(let ((toolchain (specification->package "gcc-toolchain@@10"))) |
|
6579 |
|
(package-with-c-toolchain hello `(("toolchain" ,toolchain)))) |
|
6580 |
|
@end lisp |
|
6581 |
|
|
|
6582 |
|
The build tool chain is part of the @dfn{implicit inputs} of |
|
6583 |
|
packages---it's usually not listed as part of the various ``inputs'' |
|
6584 |
|
fields and is instead pulled in by the build system. Consequently, this |
|
6585 |
|
procedure works by changing the build system of @var{package} so that it |
|
6586 |
|
pulls in @var{toolchain} instead of the defaults. @ref{Build Systems}, |
|
6587 |
|
for more on build systems. |
|
6588 |
|
@end deffn |
|
6589 |
|
|
6561 |
6590 |
@node origin Reference |
@node origin Reference |
6562 |
6591 |
@subsection @code{origin} Reference |
@subsection @code{origin} Reference |
6563 |
6592 |
|
|
|
... |
... |
ornamentation---in other words, a bag is a lower-level representation of |
6694 |
6723 |
a package, which includes all the inputs of that package, including some |
a package, which includes all the inputs of that package, including some |
6695 |
6724 |
that were implicitly added by the build system. This intermediate |
that were implicitly added by the build system. This intermediate |
6696 |
6725 |
representation is then compiled to a derivation (@pxref{Derivations}). |
representation is then compiled to a derivation (@pxref{Derivations}). |
|
6726 |
|
The @code{package-with-c-toolchain} is an example of a way to change the |
|
6727 |
|
implicit inputs that a package's build system pulls in (@pxref{package |
|
6728 |
|
Reference, @code{package-with-c-toolchain}}). |
6697 |
6729 |
|
|
6698 |
6730 |
Build systems accept an optional list of @dfn{arguments}. In package |
Build systems accept an optional list of @dfn{arguments}. In package |
6699 |
6731 |
definitions, these are passed @i{via} the @code{arguments} field |
definitions, these are passed @i{via} the @code{arguments} field |
File guix/build-system.scm changed (mode: 100644) (index 4174972b98..76d670995c) |
1 |
1 |
;;; GNU Guix --- Functional package management for GNU |
;;; GNU Guix --- Functional package management for GNU |
2 |
|
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> |
|
|
2 |
|
;;; Copyright © 2012, 2013, 2014, 2020 Ludovic Courtès <ludo@gnu.org> |
3 |
3 |
;;; |
;;; |
4 |
4 |
;;; This file is part of GNU Guix. |
;;; This file is part of GNU Guix. |
5 |
5 |
;;; |
;;; |
|
18 |
18 |
|
|
19 |
19 |
(define-module (guix build-system) |
(define-module (guix build-system) |
20 |
20 |
#:use-module (guix records) |
#:use-module (guix records) |
|
21 |
|
#:use-module (srfi srfi-1) |
21 |
22 |
#:use-module (ice-9 match) |
#:use-module (ice-9 match) |
22 |
23 |
#:export (build-system |
#:export (build-system |
23 |
24 |
build-system? |
build-system? |
|
37 |
38 |
bag-arguments |
bag-arguments |
38 |
39 |
bag-build |
bag-build |
39 |
40 |
|
|
40 |
|
make-bag)) |
|
|
41 |
|
make-bag |
|
42 |
|
|
|
43 |
|
build-system-with-c-toolchain)) |
41 |
44 |
|
|
42 |
45 |
(define-record-type* <build-system> build-system make-build-system |
(define-record-type* <build-system> build-system make-build-system |
43 |
46 |
build-system? |
build-system? |
|
... |
... |
intermediate representation just above derivations." |
98 |
101 |
#:outputs outputs |
#:outputs outputs |
99 |
102 |
#:target target |
#:target target |
100 |
103 |
arguments)))) |
arguments)))) |
|
104 |
|
|
|
105 |
|
(define (build-system-with-c-toolchain bs toolchain) |
|
106 |
|
"Return a variant of BS, a build system, that uses TOOLCHAIN instead of the |
|
107 |
|
default GNU C/C++ toolchain. TOOLCHAIN must be a list of |
|
108 |
|
inputs (label/package tuples) providing equivalent functionality, such as the |
|
109 |
|
'gcc-toolchain' package." |
|
110 |
|
(define lower |
|
111 |
|
(build-system-lower bs)) |
|
112 |
|
|
|
113 |
|
(define toolchain-packages |
|
114 |
|
;; These are the GNU toolchain packages pulled in by GNU-BUILD-SYSTEM and |
|
115 |
|
;; all the build systems that inherit from it. Keep the list in sync with |
|
116 |
|
;; 'standard-packages' in (guix build-system gnu). |
|
117 |
|
'("gcc" "binutils" "libc" "libc:static" "ld-wrapper")) |
|
118 |
|
|
|
119 |
|
(define (lower* . args) |
|
120 |
|
(let ((lowered (apply lower args))) |
|
121 |
|
(bag |
|
122 |
|
(inherit lowered) |
|
123 |
|
(build-inputs |
|
124 |
|
(append (fold alist-delete |
|
125 |
|
(bag-build-inputs lowered) |
|
126 |
|
toolchain-packages) |
|
127 |
|
toolchain))))) |
|
128 |
|
|
|
129 |
|
(build-system |
|
130 |
|
(inherit bs) |
|
131 |
|
(lower lower*))) |
File guix/packages.scm changed (mode: 100644) (index 4f2bb432be..24d6417065) |
124 |
124 |
package-patched-vulnerabilities |
package-patched-vulnerabilities |
125 |
125 |
package-with-patches |
package-with-patches |
126 |
126 |
package-with-extra-patches |
package-with-extra-patches |
|
127 |
|
package-with-c-toolchain |
127 |
128 |
package/inherit |
package/inherit |
128 |
129 |
|
|
129 |
130 |
transitive-input-references |
transitive-input-references |
|
... |
... |
specifies modules in scope when evaluating SNIPPET." |
790 |
791 |
(append (origin-patches (package-source original)) |
(append (origin-patches (package-source original)) |
791 |
792 |
patches))) |
patches))) |
792 |
793 |
|
|
|
794 |
|
(define (package-with-c-toolchain package toolchain) |
|
795 |
|
"Return a variant of PACKAGE that uses TOOLCHAIN instead of the default GNU |
|
796 |
|
C/C++ toolchain. TOOLCHAIN must be a list of inputs (label/package tuples) |
|
797 |
|
providing equivalent functionality, such as the 'gcc-toolchain' package." |
|
798 |
|
(let ((bs (package-build-system package))) |
|
799 |
|
(package/inherit package |
|
800 |
|
(build-system (build-system-with-c-toolchain bs toolchain))))) |
|
801 |
|
|
793 |
802 |
(define (transitive-inputs inputs) |
(define (transitive-inputs inputs) |
794 |
803 |
"Return the closure of INPUTS when considering the 'propagated-inputs' |
"Return the closure of INPUTS when considering the 'propagated-inputs' |
795 |
804 |
edges. Omit duplicate inputs, except for those already present in INPUTS |
edges. Omit duplicate inputs, except for those already present in INPUTS |
File tests/packages.scm changed (mode: 100644) (index 5d5abcbd76..2d13d91344) |
1430 |
1430 |
(derivation-file-name |
(derivation-file-name |
1431 |
1431 |
(package-derivation %store coreutils)))))))) |
(package-derivation %store coreutils)))))))) |
1432 |
1432 |
|
|
|
1433 |
|
(test-assert "package-with-c-toolchain" |
|
1434 |
|
(let* ((dep (dummy-package "chbouib" |
|
1435 |
|
(build-system gnu-build-system) |
|
1436 |
|
(native-inputs `(("x" ,grep))))) |
|
1437 |
|
(p0 (dummy-package "thingie" |
|
1438 |
|
(build-system gnu-build-system) |
|
1439 |
|
(inputs `(("foo" ,grep) |
|
1440 |
|
("bar" ,dep))))) |
|
1441 |
|
(tc (dummy-package "my-toolchain")) |
|
1442 |
|
(p1 (package-with-c-toolchain p0 `(("toolchain" ,tc))))) |
|
1443 |
|
(define toolchain-packages |
|
1444 |
|
'("gcc" "binutils" "glibc" "ld-wrapper")) |
|
1445 |
|
|
|
1446 |
|
(match (bag-build-inputs (package->bag p1)) |
|
1447 |
|
((("foo" foo) ("bar" bar) (_ (= package-name packages) . _) ...) |
|
1448 |
|
(and (not (any (cut member <> packages) toolchain-packages)) |
|
1449 |
|
(member "my-toolchain" packages) |
|
1450 |
|
(eq? foo grep) |
|
1451 |
|
(eq? bar dep)))))) |
|
1452 |
|
|
1433 |
1453 |
(test-equal "package-patched-vulnerabilities" |
(test-equal "package-patched-vulnerabilities" |
1434 |
1454 |
'(("CVE-2015-1234") |
'(("CVE-2015-1234") |
1435 |
1455 |
("CVE-2016-1234" "CVE-2018-4567") |
("CVE-2016-1234" "CVE-2018-4567") |