Ticket #631: 0001-Add-unit-build-version-with-build-branch-tag-and-ID-.patch
File 0001-Add-unit-build-version-with-build-branch-tag-and-ID-.patch, 6.7 KB (added by , 13 years ago) |
---|
-
Makefile.mingw
From 29f49d79886243d7aa4db5c9e178e6fe18ae1fad Mon Sep 17 00:00:00 2001 From: Jim Ursetto <zbigniewsz@gmail.com> Date: Fri, 1 Jul 2011 18:15:25 -0500 Subject: [PATCH 1/3] Add unit build-version with build branch, tag and ID variables Generate new files buildtag and buildbranch during the make process, as well as buildid (containing the git hash of HEAD, via identify-revision.sh). Make their contents available via ##sys variables in new Unit build-version, and pull this unit into Unit library. --- Makefile.mingw | 1 + build-version.scm | 45 +++++++++++++++++++++++++++++++++++++++++++++ defaults.make | 3 ++- distribution/manifest | 2 ++ identify-revision.sh | 9 +++++++++ library.scm | 1 + rules.make | 24 +++++++++++++++++++++++- 7 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 build-version.scm create mode 100755 identify-revision.sh diff --git a/Makefile.mingw b/Makefile.mingw index c5c8282..b153b58 100644
a b endif 32 32 SEP = $(strip \) 33 33 SRCDIR =.$(SEP) 34 34 BRANCHNAME = 35 BUILD_ID = 35 36 36 37 # platform configuration 37 38 -
new file uild-version.scm
diff --git a/build-version.scm b/build-version.scm new file mode 100644 index 0000000..933dffa
- + 1 ;;;; build-version.scm 2 ; 3 ; Copyright (c) 2008-2011, The Chicken Team 4 ; Copyright (c) 2000-2007, Felix L. Winkelmann 5 ; All rights reserved. 6 ; 7 ; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following 8 ; conditions are met: 9 ; 10 ; Redistributions of source code must retain the above copyright notice, this list of conditions and the following 11 ; disclaimer. 12 ; Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 13 ; disclaimer in the documentation and/or other materials provided with the distribution. 14 ; Neither the name of the author nor the names of its contributors may be used to endorse or promote 15 ; products derived from this software without specific prior written permission. 16 ; 17 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 18 ; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 19 ; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 20 ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 ; POSSIBILITY OF SUCH DAMAGE. 26 27 28 (declare 29 (unit build-version)) 30 31 ;; (read-version filename): Read line from FILENAME and return 32 ;; as a string; return #f if non-existent file or blank line. 33 (define-syntax read-version 34 (lambda (x r c) 35 (let ((fn (cadr x))) 36 (and (file-exists? fn) 37 (let ((ver (with-input-from-file (cadr x) read-line))) 38 (if (string=? ver "") 39 #f 40 ver)))))) 41 42 (define ##sys#build-version (read-version "buildversion")) 43 (define ##sys#build-tag (read-version "buildtag")) 44 (define ##sys#build-id (read-version "buildid")) 45 (define ##sys#build-branch (read-version "buildbranch")) -
defaults.make
diff --git a/defaults.make b/defaults.make index 95a069d..01f7c16 100644
a b SEP ?= / 43 43 SRCDIR ?= .$(SEP) 44 44 DESTDIR ?= 45 45 PREFIX ?= /usr/local 46 BRANCHNAME ?= $(shell sh identify-branch.sh $(SRCDIR))46 BRANCHNAME ?= $(shell sh $(SRCDIR)identify-branch.sh $(SRCDIR)) 47 47 48 48 BINDIR = $(PREFIX)/bin 49 49 LIBDIR = $(PREFIX)/lib … … UNAME_SYS ?= $(shell uname) 237 237 COPY_COMMAND = cp 238 238 endif 239 239 BUILD_TAG ?= compiled $(BUILD_TIME) on $(HOSTNAME) ($(UNAME_SYS)) 240 BUILD_ID ?= $(shell sh $(SRCDIR)identify-revision.sh $(SRCDIR)) 240 241 COPYMANY = 241 242 242 243 -
distribution/manifest
diff --git a/distribution/manifest b/distribution/manifest index e81ead8..0d48b71 100644
a b NEWS 7 7 README 8 8 config-arch.sh 9 9 identify-branch.sh 10 identify-revision.sh 10 11 banner.scm 11 12 batch-driver.scm 12 13 batch-driver.c … … srfi-4.scm 95 96 stub.scm 96 97 support.scm 97 98 tcp.scm 99 build-version.scm 98 100 tests/thread-list.scm 99 101 tests/gobble.scm 100 102 tests/test-optional.scm -
new file identify-revision.sh
diff --git a/identify-revision.sh b/identify-revision.sh new file mode 100755 index 0000000..a7980ea
- + 1 #!/bin/sh 2 # 3 # identify-revision.sh - check for .git directory and obtain checked out revision 4 # 5 # usage: identify-revision.sh SOURCEDIR 6 7 if test -d "$1/.git"; then 8 GIT_DIR="$1/.git" git rev-parse --short HEAD 2>/dev/null 9 fi -
library.scm
diff --git a/library.scm b/library.scm index 4e8a538..f05256f 100644
a b 27 27 28 28 (declare 29 29 (unit library) 30 (uses build-version) 30 31 (disable-interrupts) 31 32 (hide ##sys#dynamic-unwind ##sys#find-symbol 32 33 ##sys#grow-vector ##sys#default-parameter-vector -
rules.make
diff --git a/rules.make b/rules.make index 8ad5110..bca0358 100644
a b SETUP_API_OBJECTS_1 = setup-api setup-download 38 38 LIBCHICKEN_OBJECTS_1 = \ 39 39 library eval data-structures ports files extras lolevel utils tcp srfi-1 srfi-4 srfi-13 \ 40 40 srfi-14 srfi-18 srfi-69 $(POSIXFILE) irregex scheduler \ 41 profiler stub expand modules chicken-syntax chicken-ffi-syntax runtime 41 profiler stub expand modules chicken-syntax chicken-ffi-syntax runtime build-version 42 42 LIBCHICKEN_SHARED_OBJECTS = $(LIBCHICKEN_OBJECTS_1:=$(O)) 43 43 LIBCHICKEN_STATIC_OBJECTS = $(LIBCHICKEN_OBJECTS_1:=-static$(O)) 44 44 … … ifdef WINDOWS_SHELL 461 461 $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)csibatch.bat" 462 462 endif 463 463 464 # build versioning 465 466 .PHONY: buildtag buildbranch buildid 467 468 ifdef WINDOWS_SHELL 469 buildtag: 470 echo.$(BUILD_TAG)>buildtag 471 buildbranch: 472 echo.$(BRANCHNAME)>buildbranch 473 buildid: 474 echo.$(BUILD_ID)>buildid 475 else 476 buildtag: 477 echo "$(BUILD_TAG)" > buildtag 478 buildbranch: 479 echo "$(BRANCHNAME)" > buildbranch 480 buildid: 481 echo "$(BUILD_ID)" > buildid 482 endif 483 464 484 # bootstrapping c sources 465 485 466 486 define declare-emitted-import-lib-dependency … … profiler.c: $(SRCDIR)profiler.scm $(SRCDIR)common-declarations.scm 526 546 $(bootstrap-lib) 527 547 stub.c: $(SRCDIR)stub.scm $(SRCDIR)common-declarations.scm 528 548 $(bootstrap-lib) 549 build-version.c: $(SRCDIR)build-version.scm buildtag buildbranch buildid $(SRCDIR)buildversion 550 $(bootstrap-lib) 529 551 530 552 define declare-bootstrap-import-lib 531 553 $(1).import.c: $$(SRCDIR)$(1).import.scm