scons-build-system.scm 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
  3. ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (guix build scons-build-system)
  20. #:use-module ((guix build gnu-build-system) #:prefix gnu:)
  21. #:use-module (guix build utils)
  22. #:export (%standard-phases
  23. scons-build))
  24. ;; Commentary:
  25. ;;
  26. ;; Builder-side code of the SCons build system.
  27. ;;
  28. ;; Code:
  29. (define* (build #:key outputs (build-targets '()) (scons-flags '()) (parallel-build? #t) #:allow-other-keys)
  30. (let ((out (assoc-ref outputs "out")))
  31. (mkdir-p out)
  32. (apply invoke "scons"
  33. (append (if parallel-build?
  34. (list "-j" (number->string
  35. (parallel-job-count)))
  36. (list))
  37. scons-flags
  38. build-targets))))
  39. (define* (check #:key tests? test-target (scons-flags '()) #:allow-other-keys)
  40. "Run the test suite of a given SCons application."
  41. (if tests?
  42. (apply invoke "scons" test-target scons-flags)
  43. (format #t "test suite not run~%"))
  44. #t)
  45. (define* (install #:key outputs (install-targets '("install")) (scons-flags '()) #:allow-other-keys)
  46. "Install a given SCons application."
  47. (apply invoke "scons" (append scons-flags install-targets)))
  48. (define %standard-phases
  49. (modify-phases gnu:%standard-phases
  50. (delete 'bootstrap)
  51. (delete 'configure)
  52. (replace 'build build)
  53. (replace 'check check)
  54. (replace 'install install)))
  55. (define* (scons-build #:key inputs (phases %standard-phases)
  56. #:allow-other-keys #:rest args)
  57. "Build a given SCons application, applying all of PHASES in order."
  58. (apply gnu:gnu-build #:inputs inputs #:phases phases args))
  59. ;;; scons-build-system.scm ends here