[Asterisk-code-review] build tools: Update for git (repotools[master])
George Joseph
asteriskteam at digium.com
Thu Jul 14 15:22:46 CDT 2016
George Joseph has uploaded a new change for review.
https://gerrit.asterisk.org/3208
Change subject: build_tools: Update for git
......................................................................
build_tools: Update for git
Update to allow make_version and Makefile.version to work when run
in a git repo as well as a svn repo.
Also fixed make_cpu_versions to allow compiler versions greater
than 4.3.x.
Change-Id: Ib0f959d84b06afbdeeb153424a5931bc85b3d75c
---
M build_tools/Makefile.version
M build_tools/make_cpu_flavors
M build_tools/make_version
3 files changed, 107 insertions(+), 3 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/repotools refs/changes/08/3208/1
diff --git a/build_tools/Makefile.version b/build_tools/Makefile.version
index b4a412f..7b00d80 100644
--- a/build_tools/Makefile.version
+++ b/build_tools/Makefile.version
@@ -3,10 +3,12 @@
export $(VERSION_VARIABLE)
-$(VERSION_VARIABLE):=$(shell build_tools/make_version . $(VERSION_PRODUCT_PATH))
+DIR_PREFIX = $(shell [ -d repotools ] && echo repotools/)
+
+$(VERSION_VARIABLE):=$(shell $(DIR_PREFIX)build_tools/make_version . $(VERSION_PRODUCT_PATH))
$(VERSION_HEADER): version_FORCE
- @build_tools/make_version_h $(VERSION_VARIABLE) > $@.tmp
+ @$(DIR_PREFIX)build_tools/make_version_h $(VERSION_VARIABLE) > $@.tmp
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
diff --git a/build_tools/make_cpu_flavors b/build_tools/make_cpu_flavors
index ff6ef60..22a2e84 100755
--- a/build_tools/make_cpu_flavors
+++ b/build_tools/make_cpu_flavors
@@ -1,7 +1,7 @@
#!/bin/bash -e
cat <<EOF | gcc -E -o /dev/null - || exit 1
-#if (__GNUC__ < 4) || (__GNUC_MINOR__ < 3)
+#if (__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3))
#error GCC 4.3.x or higher required.
#endif
EOF
diff --git a/build_tools/make_version b/build_tools/make_version
index 996020c..cd90325 100755
--- a/build_tools/make_version
+++ b/build_tools/make_version
@@ -78,6 +78,108 @@
else
echo SVN-${RESULT}-r${REV}${BASE:+-${BASE}}
fi
+elif [ -d ${1}/.git ]; then
+ AWK=${AWK:-awk}
+ GIT=${GIT:-git}
+ GREP=${GREP:-grep}
+
+ if [ -z ${GIT} ]; then
+ GIT="git"
+ fi
+
+ if ! command -v ${GIT} >/dev/null 2>&1; then
+ echo "UNKNOWN__and_probably_unsupported"
+ exit 1
+ fi
+ # If the first log commit messages indicates that this is checked into
+ # subversion, we'll just use the SVN- form of the revision.
+ MODIFIED=""
+ SVN_REV=`${GIT} log --pretty=full -1 | ${GREP} -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"`
+ if [ -z "$SVN_REV" ]; then
+ VERSION=`${GIT} describe --long --always --tags --dirty=M 2> /dev/null`
+ if [ $? -ne 0 ]; then
+ if [ "`${GIT} ls-files -m | wc -l`" != "0" ]; then
+ MODIFIED="M"
+ fi
+ # Some older versions of git do not support all the above
+ # options.
+ VERSION=`${GIT} rev-parse --short --verify HEAD`${MODIFIED}
+ fi
+ echo GIT-${MAINLINE_BRANCH}-${VERSION}
+ else
+ PARTS=`LANG=C ${GIT} log --pretty=full | ${GREP} -F "git-svn-id:" | head -1 | ${AWK} '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'`
+ BRANCH=0
+ TEAM=0
+ TAG=0
+ FEATURE=0
+
+ if [ "`${GIT} ls-files -m | wc -l`" != "0" ]; then
+ MODIFIED="M"
+ fi
+
+ for PART in $PARTS ; do
+ if [ ${TAG} != 0 ] ; then
+ if [ "${PART}" = "autotag_for_be" ] ; then
+ continue
+ fi
+ if [ "${PART}" = "autotag_for_sx00i" ] ; then
+ continue
+ fi
+ RESULT="${PART}"
+ break
+ fi
+
+ if [ ${BRANCH} != 0 ] ; then
+ RESULT="${RESULT}-${PART}"
+ if [ ${FEATURE} != 0 ] ; then
+ RESULT="${RESULT}-${FEATURE_NAME}"
+ fi
+ break
+ fi
+
+ if [ ${TEAM} != 0 ] ; then
+ if [ -z "${RESULT}" ] ; then
+ RESULT="${PART}"
+ else
+ RESULT="${RESULT}-${PART}"
+ fi
+ continue
+ fi
+
+ if [ "${PART}" = "certified" ] ; then
+ FEATURE=1
+ FEATURE_NAME="cert"
+ continue
+ fi
+
+ if [ "${PART}" = "branches" ] ; then
+ BRANCH=1
+ RESULT="branch"
+ continue
+ fi
+
+ if [ "${PART}" = "tags" ] ; then
+ TAG=1
+ continue
+ fi
+
+ if [ "${PART}" = "team" ] ; then
+ TEAM=1
+ continue
+ fi
+
+ if [ "${PART}" = "trunk" ]; then
+ echo SVN-trunk-r${SVN_REV}${MODIFIED}
+ exit 0
+ fi
+ done
+
+ if [ ${TAG} != 0 ] ; then
+ echo ${RESULT}
+ else
+ echo SVN-${RESULT##-}-r${SVN_REV}${MODIFIED}
+ fi
+ fi
else
echo "UNKNOWN_and_probably_unsupported"
fi
--
To view, visit https://gerrit.asterisk.org/3208
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0f959d84b06afbdeeb153424a5931bc85b3d75c
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: George Joseph <gjoseph at digium.com>
More information about the asterisk-code-review
mailing list