From ecffeb75360134139092cd9d78d2f9387f0124e6 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Fri, 10 Jun 2016 23:33:16 +0200 Subject: [PATCH] job: Add record type. * src/cuirass/job.scm: New file. * Makefile.am (dist_pkgmodule_DATA): Add it. * bin/cuirass.in (evaluate, build-packages): Use it. --- Makefile.am | 1 + bin/cuirass.in | 16 +++++++++------- src/cuirass/job.scm | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/cuirass/job.scm diff --git a/Makefile.am b/Makefile.am index 5c1490b..4dd954a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,7 @@ noinst_SCRIPTS = pre-inst-env dist_pkgmodule_DATA = \ src/cuirass/base.scm \ + src/cuirass/job.scm \ src/cuirass/ui.scm nodist_pkgmodule_DATA = \ diff --git a/bin/cuirass.in b/bin/cuirass.in index ea55264..862bcc7 100644 --- a/bin/cuirass.in +++ b/bin/cuirass.in @@ -22,6 +22,7 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" ;;; along with Cuirass. If not, see . (use-modules (cuirass base) + (cuirass job) (cuirass ui) (ice-9 getopt-long) (ice-9 match)) @@ -74,12 +75,11 @@ DIR if required." m)) (define (build-packages store jobs) - "Build JOBS which is a list of job. ((job-symbol pair ...) ...)" - (map (lambda (thing) - (let ((name (symbol->string (car thing))) - (drv (cdadr thing))) - (format #t "building ~A => ~A~%" name drv) - ((guix-variable 'derivations 'build-derivations) store (list drv)))) + "Build JOBS which is a list of objects." + (map (match-lambda + (($ name drv) + (format #t "building ~A => ~A~%" name drv) + ((guix-variable 'derivations 'build-derivations) store (list drv)))) jobs)) (define (evaluate dir spec) @@ -101,7 +101,9 @@ DIR if required." (map (lambda (job thunk) (format (current-error-port) "evaluating '~a'... " job) (force-output (current-error-port)) - (cons job (call-with-time-display thunk))) + (make-job (symbol->string job) + (assoc-ref (call-with-time-display thunk) + 'derivation))) names thunks))))) (lambda () ((guix-variable 'store 'close-connection) store))))) diff --git a/src/cuirass/job.scm b/src/cuirass/job.scm new file mode 100644 index 0000000..4efba9e --- /dev/null +++ b/src/cuirass/job.scm @@ -0,0 +1,32 @@ +;;;; job.scm - data structures for jobs +;;; +;;; Copyright © 2016 Mathieu Lirzin +;;; +;;; This file is part of Cuirass. +;;; +;;; Cuirass 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. +;;; +;;; Cuirass 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 Cuirass. If not, see . + +(define-module (cuirass job) + #:use-module (srfi srfi-9) + #:export ( + make-job + job? + job-name + job-derivation)) + +(define-record-type + (make-job name derivation) + job? + (name job-name) ;string + (derivation job-derivation)) ;string