diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-06-13 17:03:34 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-06-13 17:03:34 +0200 |
commit | c36db98c8eaeded5243ecfa1c66e06f38da10692 (patch) | |
tree | 2d2fa5ebede4f7f08065e20f07e15bd88e946db4 /guix/build/utils.scm | |
parent | bcdd83ec69cb818c0a809ca03b1297e9725ad95b (diff) | |
download | gnu-guix-c36db98c8eaeded5243ecfa1c66e06f38da10692.tar gnu-guix-c36db98c8eaeded5243ecfa1c66e06f38da10692.tar.gz |
Add supporting tools for the GNU Build System.
* guix/derivations.scm (build-expression->derivation): Add all of INPUTS
as inputs to the final derivation.
* guix/build/gnu-build-system.scm, guix/build/utils.scm,
guix/gnu-build-system.scm: New files.
* tests/builders.scm ("gnu-build"): New test.
Diffstat (limited to 'guix/build/utils.scm')
-rw-r--r-- | guix/build/utils.scm | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm new file mode 100644 index 0000000000..db1814486c --- /dev/null +++ b/guix/build/utils.scm @@ -0,0 +1,65 @@ +;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- +;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> +;;; +;;; This file is part of Guix. +;;; +;;; 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. +;;; +;;; 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 Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (guix build utils) + #:use-module (srfi srfi-1) + #:export (directory-exists? + set-path-environment-variable)) + +(define (directory-exists? dir) + "Return #t if DIR exists and is a directory." + (pk 'dir-exists? dir + (let ((s (pk 'stat dir (stat dir #f)))) + (and s + (eq? 'directory (stat:type s)))))) + +(define (search-path-as-list sub-directories input-dirs) + "Return the list of directories among SUB-DIRECTORIES that exist in +INPUT-DIRS. Example: + + (search-path-as-list '(\"share/emacs/site-lisp\" \"share/emacs/24.1\") + (list \"/package1\" \"/package2\" \"/package3\")) + => (\"/package1/share/emacs/site-lisp\" + \"/package3/share/emacs/site-lisp\") + +" + (append-map (lambda (input) + (filter-map (lambda (dir) + (let ((dir (string-append input "/" + dir))) + (and (directory-exists? dir) + dir))) + sub-directories)) + input-dirs)) + +(define (list->search-path-as-string lst separator) + (string-join lst separator)) + +(define* (set-path-environment-variable env-var sub-directories input-dirs + #:key (separator ":")) + "Look for each of SUB-DIRECTORIES in INPUT-DIRS. Set ENV-VAR to a +SEPARATOR-separated path accordingly. Example: + + (set-path-environment-variable \"PKG_CONFIG\" + '(\"lib/pkgconfig\") + (list package1 package2)) +" + (setenv env-var + (list->search-path-as-string (search-path-as-list sub-directories + input-dirs) + separator))) |