~ chicken-core (chicken-5) /build-version.scm
Trap1;;;; build-version.scm2;3; Copyright (c) 2011-2022, The CHICKEN Team4; All rights reserved.5;6; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following7; conditions are met:8;9; Redistributions of source code must retain the above copyright notice, this list of conditions and the following10; disclaimer.11; Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following12; disclaimer in the documentation and/or other materials provided with the distribution.13; Neither the name of the author nor the names of its contributors may be used to endorse or promote14; products derived from this software without specific prior written permission.15;16; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS17; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY18; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR19; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR20; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR21; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY22; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR23; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE24; POSSIBILITY OF SUCH DAMAGE.252627(declare28 (unit build-version))2930;; (read-version filename): Read line from FILENAME and return31;; as a string; return #f if non-existent file or blank line.32(define-syntax read-version33 (er-macro-transformer34 (lambda (x r c)35 (let ((fn (cadr x)))36 (and (##sys#file-exists? fn #t #f #f)37 (call-with-input-file (cadr x)38 (lambda (p)39 (let ((ver ((##sys#slot (##sys#slot p 2) 8) p 256))) ; read-line40 (if (or (eof-object? ver) (string=? ver ""))41 #f42 ver)))))))))4344(define ##sys#build-id (read-version "buildid"))45(define ##sys#build-branch (read-version "buildbranch"))46(define ##sys#build-version (read-version "buildversion"))