build-system.scm 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (guix build-system)
  19. #:use-module (guix records)
  20. #:use-module (ice-9 match)
  21. #:export (build-system
  22. build-system?
  23. build-system-name
  24. build-system-description
  25. build-system-lower
  26. bag
  27. bag?
  28. bag-name
  29. bag-system
  30. bag-target
  31. bag-build-inputs
  32. bag-host-inputs
  33. bag-target-inputs
  34. bag-outputs
  35. bag-arguments
  36. bag-build
  37. make-bag))
  38. (define-record-type* <build-system> build-system make-build-system
  39. build-system?
  40. (name build-system-name) ; symbol
  41. (description build-system-description) ; short description
  42. (lower build-system-lower)) ; args ... -> bags
  43. ;; "Bags" are low-level representations of "packages". The system and target
  44. ;; of a bag is fixed when it's created. This is because build systems may
  45. ;; choose inputs as a function of the system and target.
  46. (define-record-type* <bag> bag %make-bag
  47. bag?
  48. (name bag-name) ;string
  49. (system bag-system) ;string
  50. (target bag-target ;string | #f
  51. (default #f))
  52. ;; Here we use build/host/target in the sense of the GNU tool chain (info
  53. ;; "(autoconf) Specifying Target Triplets").
  54. (build-inputs bag-build-inputs ;list of packages
  55. (default '()))
  56. (host-inputs bag-host-inputs ;list of packages
  57. (default '()))
  58. ;; "Target inputs" are packages that are built natively, but that are used
  59. ;; by target programs in a cross-compilation environment. Thus, they act
  60. ;; like 'inputs' as far as search paths are concerned. The only example of
  61. ;; that is the cross-libc: it is an input of 'cross-gcc', thus built
  62. ;; natively; yet, we want it to be considered as a target input for the
  63. ;; purposes of $CPATH, $LIBRARY_PATH, etc.
  64. (target-inputs bag-target-inputs
  65. (default '()))
  66. (outputs bag-outputs ;list of strings
  67. (default '("out")))
  68. (arguments bag-arguments ;list
  69. (default '()))
  70. (build bag-build)) ;bag -> derivation
  71. (define* (make-bag build-system name
  72. #:key source (inputs '()) (native-inputs '())
  73. (outputs '()) (arguments '())
  74. system target)
  75. "Ask BUILD-SYSTEM to return a 'bag' for NAME, with the given SOURCE,
  76. INPUTS, NATIVE-INPUTS, OUTPUTS, and additional ARGUMENTS. If TARGET is not
  77. #f, it must be a string with the GNU triplet of a cross-compilation target.
  78. This is the mechanism by which a package is \"lowered\" to a bag, which is the
  79. intermediate representation just above derivations."
  80. (match build-system
  81. (($ <build-system> _ description lower)
  82. (apply lower name
  83. #:system system
  84. #:source source
  85. #:inputs inputs
  86. #:native-inputs native-inputs
  87. #:outputs outputs
  88. #:target target
  89. arguments))))