summaryrefslogtreecommitdiffstats
path: root/bld.scm
blob: b12ecb99be4a7a055004afde4e4afe5883785d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
:;exec ./scmlit -f $0 -e"(bi)" build $*

(require 'build)
(require 'getopt)
(require 'getopt-parameters)

(define (build-from-argv argv)
  (cond ((string? argv)
	 (require 'read-command)
	 (set! argv (call-with-input-string argv read-command))))
  (let ()
    (define command (string->symbol (list-ref argv *optind*)))
    (define argc (length argv))
    (cond
     ((pair? argv)
      (set! *optind* (+ 1 *optind*))
      ((make-command-server build '*commands*)
       command
       (lambda (comname comval options positions arities types
			defaulters checks aliases)
	 (let* ((params (getopt->parameter-list
			 argc argv options arities types aliases))
		(fparams (fill-empty-parameters defaulters params)))
	   (cond ((not (list? params)) #f)
		 ((not (check-parameters checks fparams)) #f)
		 ((not (check-arities (map arity->arity-spec arities) fparams))
		  (slib:error 'build-from-argv "arity error" fparams) #f)
		 (else (comval fparams))))))))))

(define (build-from-whole-argv argv)
  (set! *optind* 0)
  (set! *optarg* #f)
  (build-from-argv argv))

(define b build-from-whole-argv)

(define (b*)
  (require 'read-command)
  (do ((e (read-command) (read-command)))
      ((eof-object? e))
    (cond ((null? e))
	  (else
	   (cond ((not (string-ci=? (car e) "build"))
		  (set! e (cons "build" e))))
	   (write (build-from-whole-argv e))
	   (newline)))
    (display "build> ")
    (force-output)))

(define (bi) (build-from-argv *argv*))

(cond (*interactive*
       (display "type (b \"build <command-line>\") to build") (newline)
       (display "type (b*) to enter build command loop") (newline)))

;;; Local Variables:
;;; mode:scheme
;;; End: