diff options
| author | Mathieu Lirzin <mthl@gnu.org> | 2018-01-17 17:14:24 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-01-23 10:13:16 +0100 |
| commit | cba386c1295b7054df22dfb4662b1b92f668e2c0 (patch) | |
| tree | 76078a073f62240b582c39cc20f8c9625edb6380 /scripts | |
| parent | 341afe2a36125b11c1bc08bdc8f63421edaba008 (diff) | |
build: Expand ‘scripts/guix’ at Make time.
This moves the complexity of Autotools variable expansion outside of the
application code.
* scripts/guix.in (config-lookup): Delete.
(maybe-augment-load-paths!, run-guix-main): Use fully expanded variables
instead of calling ‘config-lookup’.
* configure.ac: Don't use AC_CONFIG_FILES for ‘scripts/guix’.
Use AC_PROG_SED.
* Makefile.am (scripts/guix): New rule.
(do_subst): New variable.
(CLEANFILES, EXTRA_DIST): Adapt.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/guix.in | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/scripts/guix.in b/scripts/guix.in index e20c274242a..af50a782bbb 100644 --- a/scripts/guix.in +++ b/scripts/guix.in | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | !# | 3 | !# |
| 4 | ;;; GNU Guix --- Functional package management for GNU | 4 | ;;; GNU Guix --- Functional package management for GNU |
| 5 | ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org> | 5 | ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org> |
| 6 | ;;; Copyright © 2018 Mathieu Lirzin <mthl@gnu.org> | ||
| 6 | ;;; | 7 | ;;; |
| 7 | ;;; This file is part of GNU Guix. | 8 | ;;; This file is part of GNU Guix. |
| 8 | ;;; | 9 | ;;; |
| @@ -22,35 +23,15 @@ | |||
| 22 | ;; IMPORTANT: We must avoid loading any modules from Guix here, | 23 | ;; IMPORTANT: We must avoid loading any modules from Guix here, |
| 23 | ;; because we need to adjust the guile load paths first. | 24 | ;; because we need to adjust the guile load paths first. |
| 24 | ;; It's okay to import modules from core Guile though. | 25 | ;; It's okay to import modules from core Guile though. |
| 25 | (use-modules (ice-9 regex) | 26 | (use-modules (srfi srfi-26)) |
| 26 | (srfi srfi-26)) | ||
| 27 | 27 | ||
| 28 | (let () | 28 | (let () |
| 29 | (define-syntax-rule (push! elt v) (set! v (cons elt v))) | 29 | (define-syntax-rule (push! elt v) (set! v (cons elt v))) |
| 30 | 30 | ||
| 31 | (define config-lookup | ||
| 32 | (let ((config '(("prefix" . "@prefix@") | ||
| 33 | ("exec_prefix" . "@exec_prefix@") | ||
| 34 | ("datarootdir" . "@datarootdir@") | ||
| 35 | ("guilemoduledir" . "@guilemoduledir@") | ||
| 36 | ("guileobjectdir" . "@guileobjectdir@") | ||
| 37 | ("localedir" . "@localedir@"))) | ||
| 38 | (var-ref-regexp (make-regexp "\\$\\{([a-z_]+)\\}"))) | ||
| 39 | (define (expand-var-ref match) | ||
| 40 | (lookup (match:substring match 1))) | ||
| 41 | (define (expand str) | ||
| 42 | (regexp-substitute/global #f var-ref-regexp str | ||
| 43 | 'pre expand-var-ref 'post)) | ||
| 44 | (define (lookup name) | ||
| 45 | (expand (assoc-ref config name))) | ||
| 46 | lookup)) | ||
| 47 | |||
| 48 | (define (maybe-augment-load-paths!) | 31 | (define (maybe-augment-load-paths!) |
| 49 | (unless (getenv "GUIX_UNINSTALLED") | 32 | (unless (getenv "GUIX_UNINSTALLED") |
| 50 | (let ((module-dir (config-lookup "guilemoduledir")) | 33 | (push! "@guilemoduledir@" %load-path) |
| 51 | (object-dir (config-lookup "guileobjectdir"))) | 34 | (push! "@guileobjectdir@" %load-compiled-path) |
| 52 | (push! module-dir %load-path) | ||
| 53 | (push! object-dir %load-compiled-path)) | ||
| 54 | (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME") | 35 | (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME") |
| 55 | (and=> (getenv "HOME") | 36 | (and=> (getenv "HOME") |
| 56 | (cut string-append <> "/.config"))) | 37 | (cut string-append <> "/.config"))) |
| @@ -64,8 +45,8 @@ | |||
| 64 | (define (run-guix-main) | 45 | (define (run-guix-main) |
| 65 | (let ((guix-main (module-ref (resolve-interface '(guix ui)) | 46 | (let ((guix-main (module-ref (resolve-interface '(guix ui)) |
| 66 | 'guix-main))) | 47 | 'guix-main))) |
| 67 | (bindtextdomain "guix" (config-lookup "localedir")) | 48 | (bindtextdomain "guix" "@localedir@") |
| 68 | (bindtextdomain "guix-packages" (config-lookup "localedir")) | 49 | (bindtextdomain "guix-packages" "@localedir@") |
| 69 | (apply guix-main (command-line)))) | 50 | (apply guix-main (command-line)))) |
| 70 | 51 | ||
| 71 | (maybe-augment-load-paths!) | 52 | (maybe-augment-load-paths!) |
