]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
configure.ac: add --disable-gitversion 4025/head
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 12 Mar 2015 21:17:09 +0000 (22:17 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 19 Mar 2015 08:38:46 +0000 (09:38 +0100)
During development each git commit cause currently a complete
rebuild of the source tree. By passing --disable-gitversion to
configure we set a generic version string for ceph to prevent
getting after each commit a new version set.

remove src/check_version and replace with a extended version
of src/make_version which allows detecting changes in .git_version
and ceph_ver.h to avoid not needed updates.

This change also forces to call make_version each time to make
sure that changes from configure or the NO_VERSION env variable
are processed.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
configure.ac
src/Makefile.am
src/check_version [deleted file]
src/make_version

index 05f0cf9cd91c4f5b9a2f9acca56eb7a9348888ab..f0aace731ea2b65298ef12fcbdbb6244d0e6d5c2 100644 (file)
@@ -279,6 +279,12 @@ else
     AC_MSG_FAILURE([no suitable crypto library found])
 fi
 
+AC_ARG_ENABLE(gitversion,
+    [AC_HELP_STRING([--enable-gitversion], [build Ceph with git version string])],
+    [], [enable_gitversion=yes])
+
+AM_CONDITIONAL(NO_GIT_VERSION, [test "x$enable_gitversion" = "xno"])
+
 AC_ARG_ENABLE([root-make-check],
             [AS_HELP_STRING([--enable-root-make-check], [enable make check tests that require root privileges])],
             [],
index 116be9d32e81a50658f413cbc3a7dccc45cb54e7..f26da2782da06eca1436814b8069fb2483efa926 100644 (file)
@@ -3,7 +3,9 @@ include Makefile-env.am
 SUBDIRS += ocf java tracing
 DIST_SUBDIRS += gmock ocf libs3 java tracing
 
-
+if NO_GIT_VERSION
+export NO_VERSION="yes"
+endif
 
 # subdirs
 
@@ -164,7 +166,6 @@ EXTRA_DIST += \
        $(srcdir)/init-rbdmap \
        $(srcdir)/ceph-clsinfo \
        $(srcdir)/make_version \
-       $(srcdir)/check_version \
        $(srcdir)/.git_version \
        $(srcdir)/ceph-rbdnamer \
        $(srcdir)/test/encoding/readable.sh \
@@ -670,19 +671,17 @@ base: core-daemons admin-tools \
 
 FORCE:
 .git_version: FORCE
-       $(srcdir)/check_version $(srcdir)/.git_version
+       $(srcdir)/make_version -g $(srcdir)/.git_version
 
 # if NO_VERSION is set, only generate a new ceph_ver.h if there currently 
 # is none, and call "make_version -n" to fill it with a fixed string.
 # Otherwise, set it from the contents of .git_version.
 
-ceph_ver.h: .git_version
+ceph_ver.h: .git_version FORCE
        if [ -n "$$NO_VERSION" ] ; then \
-           if [ ! -f ./ceph_ver.h ] ; then \
-               $(srcdir)/make_version -n ./ceph_ver.h ; \
-           fi; \
-        else \
-           $(srcdir)/make_version $(srcdir)/.git_version ./ceph_ver.h ; \
+               $(srcdir)/make_version -g $(srcdir)/.git_version -c $(srcdir)/ceph_ver.h -n ; \
+       else \
+               $(srcdir)/make_version -g $(srcdir)/.git_version -c $(srcdir)/ceph_ver.h ; \
        fi
 
 ceph_ver.c: ./ceph_ver.h
@@ -693,7 +692,7 @@ sample.fetch_config: fetch_config
        cp -f $(srcdir)/fetch_config ./sample.fetch_config
 
 dist-hook:
-       $(srcdir)/check_version $(srcdir)/.git_version
+       $(srcdir)/make_version -g $(srcdir)/.git_version
 
 CLEANFILES += ceph_ver.h sample.fetch_config
 
diff --git a/src/check_version b/src/check_version
deleted file mode 100755 (executable)
index 8600c55..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-dname=`dirname $0`
-
-if [ ! -d $dname/../.git ]; then
-    echo "not updating .git_version (no $dname/../.git)"
-    exit 0
-fi
-
-cur=`cd $dname && git rev-parse HEAD 2>/dev/null; git describe 2>/dev/null`
-[ -e $1 ] && old=`cat $1`
-
-if [ "$cur" != "$old" ]; then
-    echo regenerating $1 with $cur
-    echo "$cur" > $1
-else
-    echo $1 is up to date.
-fi
-
index 3ed2bac691d8b0a4bee4499d45ed05f4696ee3b3..db7a58bdaf66b797ed92b77e8ca88bc1ef0b8fbf 100755 (executable)
 #!/bin/sh
 
-echo '$1: '$1
+GIT_VERSION_FILE=
+CEPH_VER_HEADER=
+NO_VERSION=0
 
-if [ "$1" =  "-n" ] ; then
-   cur="no_version"
-   v="Development"
-else
-   cur=`head -1 $1`
-   v=`tail -1 $1 | cut -c 2-`
-fi
+is_git() {
+    type git > /dev/null 2>&1 || { echo "Could not find git command. Please install. Aborting."; exit 1; }
+    git status > /dev/zero 2>&1;
+    if [ $? -ne 0 ]; then
+        echo "This is no git repository, not updating .git_version"
+        return 1
+    else
+        return 0
+    fi
+}
+
+check_gitversion() {
+    if is_git; then
+        current=`git rev-parse HEAD 2> /dev/null; git describe 2> /dev/null`
+        if [ -f $GIT_VERSION_FILE ] ; then
+            old=`cat $GIT_VERSION_FILE`
+
+            if [ "$current" != "$old" ]; then
+                echo "$current" > $GIT_VERSION_FILE
+            fi
+        else
+            echo "$current" > $GIT_VERSION_FILE
+        fi
+    fi
+}
+
+print_ceph_ver() {
+    # print the content of the ceph_ver.h file
+    if [ $NO_VERSION -eq 1 ]; then
+        ver="no_version"
+        ver_nice="Development"
+    else
+        ver=`head -1 $GIT_VERSION_FILE`
+        ver_nice=`tail -1 $GIT_VERSION_FILE | cut -c 2-`
+    fi
 
-print_all() {
-       echo "#ifndef CEPH_VERSION_H"
-       echo "#define CEPH_VERSION_H"
-       echo
-       echo "#define CEPH_GIT_VER $cur"
-       echo "#define CEPH_GIT_NICE_VER \"$v\""
-       echo
-       echo "#endif"
+    echo "#ifndef CEPH_VERSION_H"
+    echo "#define CEPH_VERSION_H"
+    echo
+    echo "#define CEPH_GIT_VER $ver"
+    echo "#define CEPH_GIT_NICE_VER \"$ver_nice\""
+    echo
+    echo "#endif"
 }
 
-print_all > $2
+set_ceph_ver() {
+    # compare new and old CEPH_VER_HEADER
+    if [ -f $CEPH_VER_HEADER ]; then
+       tmpfile=$(mktemp -t "ceph_ver_h.XXXXXXXXXXXXX")
+        print_ceph_ver > $tmpfile
+        cur_ver=`cat $CEPH_VER_HEADER`
+        new_ver=`cat $tmpfile`
+        if [ "$cur_ver" != "$new_ver" ]; then
+            mv $tmpfile $CEPH_VER_HEADER
+       else
+           rm $tmpfile
+        fi
+    else
+        print_ceph_ver > $CEPH_VER_HEADER
+    fi
+}
+
+usage() {
+    printf "usage: $0 -g FILEPATH [options]\n"
+    printf "\t-g|--git-version-file\tFILEPATH for git version file (e.g. ./src/.git_version)\n"
+    printf "\t-c|--ceph-ver-header\tFILEPATH for ceph version header (e.g. ./src/ceph_ver.h)\n"
+    printf "\t-n|--no-version\t\tdon't generate version from git\n"
+    printf "\t-h|--help\t\tprint this usage instructions\n"
+}
+
+until [ -z "$1" ]; do
+case $1 in
+    -n|--no-version)
+        NO_VERSION=1;
+        ;;
+    -g|--git-version-file)
+        GIT_VERSION_FILE=$2
+        shift;
+        ;;
+    -c|--ceph-ver-header)
+        CEPH_VER_HEADER=$2
+        shift;
+        ;;
+    -h|--help)
+        usage;
+        ;;
+    *)
+        ;;
+esac
+shift
+done;
+
+if [ -n "$GIT_VERSION_FILE" ] ; then
+    if [ -z "$CEPH_VER_HEADER" ] ; then
+        check_gitversion
+    else
+        check_gitversion
+        set_ceph_ver
+    fi
+else
+    usage
+fi