source: project/chicken/branches/release/misc/setversion.scm @ 7276

Last change on this file since 7276 was 7276, checked in by felix winkelmann, 12 years ago

merged trunk

File size: 1.4 KB
Line 
1;;;; setversion.scm - Bump version-number
2
3(use utils)
4
5(define buildversion (->string (car (read-file "buildversion"))))
6(define buildbinaryversion (car (read-file "buildbinaryversion")))
7
8(define files '("README" "manual/The User's Manual"))
9
10(define (patch which rx subst)
11  (match which
12    ((from to) 
13     (print "patching " from " ...")
14     (with-output-to-file to
15       (lambda ()
16         (with-input-from-file from
17           (lambda ()
18             (let loop ()
19               (let ((ln (read-line)))
20                 (unless (eof-object? ln)
21                   (write-line (string-substitute rx subst ln #t)) 
22                   (loop) ) ) ) ) ) ) ) )
23    (both
24     (let ((tmp (create-temporary-file)))
25       (patch (list both tmp) rx subst)
26       (system* "mv ~S ~S" tmp both ) ) ) ) )
27
28(define (main args)
29  (cond ((member "-set" args) =>
30         (lambda (a) (set! buildversion (cadr a))) )
31        ((not (member "-noinc" args))
32         (set! buildversion (number->string (+ (string->number buildversion) 0.001))) ) )
33  (with-output-to-file "buildversion" (cut display buildversion))
34  (with-output-to-file "version.scm" 
35    (lambda ()
36      (write `(define-constant +build-version+ ,buildversion))
37      (newline) ) )
38  (system* "cat version.scm")
39  (let ([vstr (sprintf "version ~A" buildversion)])
40    (for-each (cut patch <> "version [0-9][-.0-9a-zA-Z]+" vstr) files) )
41  (with-output-to-file "DONE" (cut print "- version is " buildversion))
42  0)
43
44(main (command-line-arguments))
Note: See TracBrowser for help on using the repository browser.