Debian Codegraph @

games/guile-compile

raw
1 #!/bin/sh
2 # -*- scheme -*-
3 this="$0"
4 srcdir="$1"
5 builddir="$2"
6 GUILE="$3"
7
8 shift 3
9
10 export GUILE_AUTO_COMPILE=0
11 export GUILE_LOAD_PATH=".:${srcdir}"
12 export GUILE_LOAD_COMPILED_PATH=.
13 export GUILE_WARN_DEPRECATED="detailed"
14
15 exec ${GUILE:-/bin/false} -e '(@@ (guild) main)' -s "$this" "$@"
16 !#
17
18 ;;;; guild --- running scripts bundled with Guile
19 ;;;; Andy Wingo <[email protected]> --- April 2009
20 ;;;;
21 ;;;; Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
22 ;;;;
23 ;;;; This library is free software; you can redistribute it and/or
24 ;;;; modify it under the terms of the GNU Lesser General Public
25 ;;;; License as published by the Free Software Foundation; either
26 ;;;; version 3 of the License, or (at your option) any later version.
27 ;;;;
28 ;;;; This library is distributed in the hope that it will be useful,
29 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
30 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 ;;;; Lesser General Public License for more details.
32 ;;;;
33 ;;;; You should have received a copy of the GNU Lesser General Public
34 ;;;; License along with this library; if not, write to the Free
35 ;;;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 ;;;; Boston, MA 02110-1301 USA
37
38 ;; We need to provide a dummy module for our internal API
39
40 (define-module (aisleriot interface))
41
42 ;; empty
43
44 (primitive-load-path "api")
45
46 ;; Copied from guile code: guild
47
48 (define-module (guild)
49 #:use-module (ice-9 getopt-long)
50 #:use-module (ice-9 command-line)
51 #:autoload (ice-9 format) (format))
52
53 ;; Hack to provide scripts with the bug-report address.
54 (module-define! the-scm-module
55 '%guile-bug-report-address
56 "[email protected]")
57
58
59 (define *option-grammar*
60 '((help (single-char #\h))
61 (version (single-char #\v))))
62
63 (define (display-version)
64 (version-etc "GNU Guile"
65 (version)
66 #:command-name "guild"
67 #:license *LGPLv3+*))
68
69 (define (find-script s)
70 (resolve-module (list 'scripts (string->symbol s)) #:ensure #f))
71
72 (define (main args)
73 (if (defined? 'setlocale)
74 (catch 'system-error
75 (lambda ()
76 (setlocale LC_ALL ""))
77 (lambda args
78 (format (current-error-port)
79 "warning: failed to install locale: ~a~%"
80 (strerror (system-error-errno args))))))
81
82 (let* ((options (getopt-long args *option-grammar*
83 #:stop-at-first-non-option #t))
84 (args (option-ref options '() '())))
85 (cond
86 ((option-ref options 'help #f)
87 (apply (module-ref (resolve-module '(scripts help)) 'main) args)
88 (exit 0))
89 ((option-ref options 'version #f)
90 (display-version)
91 (exit 0))
92 ((find-script (if (null? args) "help" (car args)))
93 => (lambda (mod)
94 (exit (apply (module-ref mod 'main) (if (null? args)
95 '()
96 (cdr args))))))
97 (else
98 (format (current-error-port)
99 "guild: unknown script ~s~%" (car args))
100 (format (current-error-port)
101 "Try `guild help' for more information.~%")
102 (exit 1)))))