all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Arun Isaac <arunisaac@systemreboot.net>
To: 29392@debbugs.gnu.org
Subject: [bug#29392] [PATCH 02/11] build-system: Add scons-build-system.
Date: Tue, 28 Nov 2017 22:36:42 +0530	[thread overview]
Message-ID: <20171128170651.6136-3-arunisaac@systemreboot.net> (raw)
In-Reply-To: <20171128170651.6136-1-arunisaac@systemreboot.net>

* 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                     |  16 ++++-
 guix/build-system/scons.scm       | 134 ++++++++++++++++++++++++++++++++++++++
 guix/build/scons-build-system.scm |  65 ++++++++++++++++++
 4 files changed, 217 insertions(+), 1 deletion(-)
 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 <leo@famulari.name>
 # Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
 # Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+# Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
 #
 # 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 05042cb20..ad517a8a5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41,7 +41,8 @@ Copyright @copyright{} 2017 Marius Bakke@*
 Copyright @copyright{} 2017 Hartmut Goebel@*
 Copyright @copyright{} 2017 Maxim Cournoyer@*
 Copyright @copyright{} 2017 Tobias Geerinckx-Rice@*
-Copyright @copyright{} 2017 George Clemmer
+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,19 @@ 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 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.  The version of Python used to run SCons
+can be specified by selecting the appropriate SCons package with the
+@code{#:scons} 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..da09cc7de
--- /dev/null
+++ b/guix/build-system/scons.scm
@@ -0,0 +1,134 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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 (default-scons)
+  "Return the default SCons package."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((python (resolve-interface '(gnu packages python))))
+    (module-ref python 'scons)))
+
+(define* (lower name
+                #:key source inputs native-inputs outputs system target
+                (scons (default-scons))
+                #:allow-other-keys
+                #:rest arguments)
+  "Return a bag for NAME."
+  (define private-keywords
+    '(#:source #:target #:scons #: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" ,scons)
+                         ,@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..a8760968d
--- /dev/null
+++ b/guix/build/scons-build-system.scm
@@ -0,0 +1,65 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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

  parent reply	other threads:[~2017-11-28 17:08 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22  8:41 [bug#29392] [PATCH 00/11] New scons build system Arun Isaac
2017-11-22  9:34 ` [bug#29392] [PATCH 01/11] gnu: scons: Update to 3.0.1 Arun Isaac
2017-11-22  9:34   ` [bug#29392] [PATCH 02/11] build-system: Add scons-build-system Arun Isaac
2017-11-26 21:04     ` Leo Famulari
2017-11-22  9:34   ` [bug#29392] [PATCH 03/11] gnu: linuxdcpp: Use scons-build-system Arun Isaac
2017-11-22  9:35   ` [bug#29392] [PATCH 04/11] gnu: gpick: " Arun Isaac
2017-11-22  9:35   ` [bug#29392] [PATCH 05/11] gnu: serf: " Arun Isaac
2017-11-22  9:35   ` [bug#29392] [PATCH 06/11] gnu: metabat: " Arun Isaac
2017-11-22  9:35   ` [bug#29392] [PATCH 07/11] gnu: godot: " Arun Isaac
2017-11-22  9:35   ` [bug#29392] [PATCH 08/11] gnu: pingus: " Arun Isaac
2017-11-22  9:35   ` [bug#29392] [PATCH 09/11] gnu: klick: " Arun Isaac
2017-11-22  9:35   ` [bug#29392] [PATCH 10/11] gnu: mongodb: " Arun Isaac
2017-11-22  9:35   ` [bug#29392] [PATCH 11/11] gnu: pingus: Use HTTPS for home page Arun Isaac
2017-11-25 16:04 ` [bug#29392] [PATCH 00/11] New scons build system Leo Famulari
2017-11-25 16:05 ` Leo Famulari
2017-11-26 11:17   ` Arun Isaac
2017-11-26  1:26 ` Leo Famulari
2017-11-26 16:17   ` Ludovic Courtès
2017-11-26 18:51     ` Leo Famulari
2017-11-28 17:06 ` [bug#29392] [PATCH 00/11] Add " Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 01/11] gnu: scons: Update to 3.0.1 Arun Isaac
2017-11-28 17:06   ` Arun Isaac [this message]
2017-11-28 17:06   ` [bug#29392] [PATCH 03/11] gnu: linuxdcpp: Use scons-build-system Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 04/11] gnu: gpick: " Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 05/11] gnu: serf: " Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 06/11] gnu: metabat: " Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 07/11] gnu: godot: " Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 08/11] gnu: pingus: " Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 09/11] gnu: klick: " Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 10/11] gnu: mongodb: " Arun Isaac
2017-11-28 17:06   ` [bug#29392] [PATCH 11/11] gnu: pingus: Use HTTPS for home page Arun Isaac
2017-11-28 21:38   ` [bug#29392] [PATCH 00/11] Add scons build system Leo Famulari
2017-11-29  8:19     ` Arun Isaac
2017-11-29 21:29       ` Leo Famulari
2017-11-30 13:40         ` bug#29392: " Arun Isaac
2017-11-30 17:05           ` [bug#29392] " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171128170651.6136-3-arunisaac@systemreboot.net \
    --to=arunisaac@systemreboot.net \
    --cc=29392@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.