meson-configuration.scm 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
  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 meson-configuration)
  19. #:use-module (ice-9 match)
  20. #:export (write-section-header write-assignment write-assignments))
  21. ;; Commentary:
  22. ;;
  23. ;; Utilities for generating a ‘Cross build definition file’ for
  24. ;; the Meson build system. Configuration values are currently
  25. ;; never escaped. In practice this is unlikely to be a problem
  26. ;; in the build environment.
  27. ;;
  28. ;; Code:
  29. (define (write-section-header port section-name)
  30. "Write a section header for a section named SECTION-NAME to PORT."
  31. (format port "[~a]~%" section-name))
  32. (define (write-assignment port key value)
  33. "Write an assignment of VALUE to KEY to PORT.
  34. VALUE must be a string (without any special characters such as quotes),
  35. a boolean or an integer. Lists are currently not supported"
  36. (match value
  37. ((? string?)
  38. (format port "~a = '~a'~%" key value))
  39. ((? integer?)
  40. (format port "~a = ~a~%" key value))
  41. (#f
  42. (format port "~a = true~%" key))
  43. (#t
  44. (format port "~a = false~%" key))))
  45. (define* (write-assignments port alist)
  46. "Write the assignments in ALIST, an association list, to PORT."
  47. (for-each (match-lambda
  48. ((key . value)
  49. (write-assignment port key value)))
  50. alist))