From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHRhN-0007et-QM for guix-patches@gnu.org; Wed, 22 Nov 2017 04:52:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHRhK-00082U-Lk for guix-patches@gnu.org; Wed, 22 Nov 2017 04:52:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:43165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eHRhK-00082O-DY for guix-patches@gnu.org; Wed, 22 Nov 2017 04:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eHRhK-0005PS-6j for guix-patches@gnu.org; Wed, 22 Nov 2017 04:52:02 -0500 Subject: [bug#29392] [PATCH 02/11] build-system: Add scons-build-system. Resent-Message-ID: From: Arun Isaac Date: Wed, 22 Nov 2017 15:04:58 +0530 Message-Id: <20171122093507.6827-2-arunisaac@systemreboot.net> In-Reply-To: <20171122093507.6827-1-arunisaac@systemreboot.net> References: <20171122093507.6827-1-arunisaac@systemreboot.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 29392@debbugs.gnu.org * guix/build-system/scons.scm: New file. * guix/build/scons-build-system.scm: New file. * Makefile.am (MODULES): Register them. * doc/guix.texi (Build Systems): Add scons-build-system. --- Makefile.am | 3 + doc/guix.texi | 10 +++ guix/build-system/scons.scm | 127 ++++++++++++++++++++++++++++++++++++++ guix/build/scons-build-system.scm | 65 +++++++++++++++++++ 4 files changed, 205 insertions(+) create mode 100644 guix/build-system/scons.scm create mode 100644 guix/build/scons-build-system.scm diff --git a/Makefile.am b/Makefile.am index eab49181a..24a803a21 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,6 +8,7 @@ # Copyright © 2017 Leo Famulari # Copyright © 2017 Ricardo Wurmus # Copyright © 2017 Jan Nieuwenhuizen +# Copyright © 2017 Arun Isaac # # This file is part of GNU Guix. # @@ -94,6 +95,7 @@ MODULES = \ guix/build-system/waf.scm \ guix/build-system/r.scm \ guix/build-system/ruby.scm \ + guix/build-system/scons.scm \ guix/build-system/texlive.scm \ guix/build-system/trivial.scm \ guix/ftp-client.scm \ @@ -127,6 +129,7 @@ MODULES = \ guix/build/ocaml-build-system.scm \ guix/build/r-build-system.scm \ guix/build/ruby-build-system.scm \ + guix/build/scons-build-system.scm \ guix/build/texlive-build-system.scm \ guix/build/waf-build-system.scm \ guix/build/haskell-build-system.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 2b3ffc9a8..6f93b1c8e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -42,6 +42,7 @@ Copyright @copyright{} 2017 Hartmut Goebel@* Copyright @copyright{} 2017 Maxim Cournoyer@* Copyright @copyright{} 2017 Tobias Geerinckx-Rice@* Copyright @copyright{} 2017 George Clemmer +Copyright @copyright{} 2017 Arun Isaac Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -3865,6 +3866,15 @@ Python package is used to run the script can be specified with the @code{#:python} parameter. @end defvr +@defvr {Scheme Variable} scons-build-system +This variable is exported by @code{(guix build-system scons)}. It +implements the build procedure used by the @code{scons} software +construction tool. This build system runs @code{scons} to build the +package, @code{scons test} to run tests, and then @code{scons install} +to install the package. Additional flags to be passed to @code{scons} +can be specified with the @code{#:scons-flags} parameter. +@end defvr + @defvr {Scheme Variable} haskell-build-system This variable is exported by @code{(guix build-system haskell)}. It implements the Cabal build procedure used by Haskell packages, which diff --git a/guix/build-system/scons.scm b/guix/build-system/scons.scm new file mode 100644 index 000000000..132a2d4df --- /dev/null +++ b/guix/build-system/scons.scm @@ -0,0 +1,127 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Arun Isaac +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build-system scons) + #:use-module (guix utils) + #:use-module (guix packages) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (ice-9 match) + #:export (%scons-build-system-modules + scons-build + scons-build-system)) + +;; Commentary: +;; +;; Standard build procedure for applications using 'scons'. This is +;; implemented as an extension of 'gnu-build-system'. +;; +;; Code: + +(define %scons-build-system-modules + ;; Build-side modules imported by default. + `((guix build scons-build-system) + ,@%gnu-build-system-modules)) + +(define* (lower name + #:key source inputs native-inputs outputs system target + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:source #:target #: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-python2" ,(module-ref (resolve-interface '(gnu packages python)) 'scons-python2)) + ,@native-inputs)) + (outputs outputs) + (build scons-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define* (scons-build store name inputs + #:key + (tests? #t) + (scons-flags ''()) + (test-target "test") + (phases '(@ (guix build scons-build-system) + %standard-phases)) + (outputs '("out")) + (search-paths '()) + (system (%current-system)) + (guile #f) + (imported-modules %scons-build-system-modules) + (modules '((guix build scons-build-system) + (guix build utils)))) + "Build SOURCE using SCONS, and with INPUTS. This assumes that SOURCE +provides a 'SConstruct' file as its build system." + (define builder + `(begin + (use-modules ,@modules) + (scons-build #:name ,name + #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:scons-flags ,scons-flags + #:system ,system + #:test-target ,test-target + #:tests? ,tests? + #:phases ,phases + #:outputs %outputs + #:search-paths ',(map search-path-specification->sexp + search-paths) + #:inputs %build-inputs))) + + (define guile-for-build + (match guile + ((? package?) + (package-derivation store guile system #:graft? #f)) + (#f ; the default + (let* ((distro (resolve-interface '(gnu packages commencement))) + (guile (module-ref distro 'guile-final))) + (package-derivation store guile system #:graft? #f))))) + + (build-expression->derivation store name builder + #:inputs inputs + #:system system + #:modules imported-modules + #:outputs outputs + #:guile-for-build guile-for-build)) + +(define scons-build-system + (build-system + (name 'scons) + (description "The standard scons build system") + (lower lower))) + +;;; scons.scm ends here diff --git a/guix/build/scons-build-system.scm b/guix/build/scons-build-system.scm new file mode 100644 index 000000000..b49e924d9 --- /dev/null +++ b/guix/build/scons-build-system.scm @@ -0,0 +1,65 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Arun Isaac +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build scons-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build utils) + #:export (%standard-phases + scons-build)) + +;; Commentary: +;; +;; Builder-side code of the scons build system. +;; +;; Code: + +(define* (build #:key outputs (scons-flags '()) (parallel-build? #t) #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (mkdir-p out) + (zero? (apply system* "scons" + (append (if parallel-build? + (list "-j" (number->string + (parallel-job-count))) + (list)) + scons-flags))))) + +(define* (check #:key tests? test-target (scons-flags '()) #:allow-other-keys) + "Run the test suite of a given scons application." + (cond (tests? + (zero? (apply system* "scons" test-target scons-flags))) + (else + (format #t "test suite not run~%") + #t))) + +(define* (install #:key outputs (scons-flags '()) #:allow-other-keys) + "Install a given scons application." + (zero? (apply system* "scons" "install" scons-flags))) + +(define %standard-phases + (modify-phases gnu:%standard-phases + (delete 'configure) + (replace 'build build) + (replace 'check check) + (replace 'install install))) + +(define* (scons-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build a given scons application, applying all of PHASES in order." + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) + +;;; scons-build-system.scm ends here -- 2.15.0