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 Jim Ursetto, 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 
    3232SEP = $(strip \)
    3333SRCDIR =.$(SEP)
    3434BRANCHNAME =
     35BUILD_ID =
    3536
    3637# platform configuration
    3738
  • 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 ?= / 
    4343SRCDIR ?= .$(SEP)
    4444DESTDIR ?=
    4545PREFIX ?= /usr/local
    46 BRANCHNAME ?= $(shell sh identify-branch.sh $(SRCDIR))
     46BRANCHNAME ?= $(shell sh $(SRCDIR)identify-branch.sh $(SRCDIR))
    4747
    4848BINDIR = $(PREFIX)/bin
    4949LIBDIR = $(PREFIX)/lib
    UNAME_SYS ?= $(shell uname) 
    237237COPY_COMMAND = cp
    238238endif
    239239BUILD_TAG ?= compiled $(BUILD_TIME) on $(HOSTNAME) ($(UNAME_SYS))
     240BUILD_ID ?= $(shell sh $(SRCDIR)identify-revision.sh $(SRCDIR))
    240241COPYMANY =
    241242
    242243
  • distribution/manifest

    diff --git a/distribution/manifest b/distribution/manifest
    index e81ead8..0d48b71 100644
    a b NEWS 
    77README
    88config-arch.sh
    99identify-branch.sh
     10identify-revision.sh
    1011banner.scm
    1112batch-driver.scm
    1213batch-driver.c
    srfi-4.scm 
    9596stub.scm
    9697support.scm
    9798tcp.scm
     99build-version.scm
    98100tests/thread-list.scm
    99101tests/gobble.scm
    100102tests/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
     7if test -d "$1/.git"; then
     8    GIT_DIR="$1/.git" git rev-parse --short HEAD 2>/dev/null
     9fi
  • library.scm

    diff --git a/library.scm b/library.scm
    index 4e8a538..f05256f 100644
    a b  
    2727
    2828(declare
    2929  (unit library)
     30  (uses build-version)
    3031  (disable-interrupts)
    3132  (hide ##sys#dynamic-unwind ##sys#find-symbol
    3233        ##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 
    3838LIBCHICKEN_OBJECTS_1 = \
    3939       library eval data-structures ports files extras lolevel utils tcp srfi-1 srfi-4 srfi-13 \
    4040       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
    4242LIBCHICKEN_SHARED_OBJECTS = $(LIBCHICKEN_OBJECTS_1:=$(O))
    4343LIBCHICKEN_STATIC_OBJECTS = $(LIBCHICKEN_OBJECTS_1:=-static$(O))
    4444
    ifdef WINDOWS_SHELL 
    461461        $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)csibatch.bat"
    462462endif
    463463
     464# build versioning
     465
     466.PHONY: buildtag buildbranch buildid
     467
     468ifdef WINDOWS_SHELL
     469buildtag:
     470        echo.$(BUILD_TAG)>buildtag
     471buildbranch:
     472        echo.$(BRANCHNAME)>buildbranch
     473buildid:
     474        echo.$(BUILD_ID)>buildid
     475else
     476buildtag:
     477        echo "$(BUILD_TAG)" > buildtag
     478buildbranch:
     479        echo "$(BRANCHNAME)" > buildbranch
     480buildid:
     481        echo "$(BUILD_ID)" > buildid
     482endif
     483
    464484# bootstrapping c sources
    465485
    466486define declare-emitted-import-lib-dependency
    profiler.c: $(SRCDIR)profiler.scm $(SRCDIR)common-declarations.scm 
    526546        $(bootstrap-lib)
    527547stub.c: $(SRCDIR)stub.scm $(SRCDIR)common-declarations.scm
    528548        $(bootstrap-lib)
     549build-version.c: $(SRCDIR)build-version.scm buildtag buildbranch buildid $(SRCDIR)buildversion
     550        $(bootstrap-lib)
    529551
    530552define declare-bootstrap-import-lib
    531553$(1).import.c: $$(SRCDIR)$(1).import.scm