Improve SWITCH_VERSION_REVISION generation

The revision was no longer picking up the last git commit.  Instead,
it was showing the last release.  This commit appends the last git
commit hash to the last release if a git repository is available.
Further, it checks whether there are uncommitted changes in the git
repository and adds an unclean tag to the version if this is the case.

Note that currently this will append the git commit hash even on a
tagged release if built directly from a git repository.  Perhaps this
isn't such a bad thing, but if it turns out not to be desired, I have
an idea on how to squelch this without making unwarranted assumptions
about the remote layout of someone's local repository.
上级 ec27618f
@SWITCH_VERSION_REVISION@
...@@ -415,29 +415,19 @@ $(OUR_MODULES): $(switch_builddir)/modules.conf libfreeswitch.la ...@@ -415,29 +415,19 @@ $(OUR_MODULES): $(switch_builddir)/modules.conf libfreeswitch.la
$(switch_builddir)/quiet_libtool: $(switch_builddir)/libtool $(switch_builddir)/quiet_libtool: $(switch_builddir)/libtool
@cat libtool | sed -e 's|$$show "$$command"|if test -z "$$suppress_output" ; then $$show "Compiling $$srcfile ..." ; fi|' > $(switch_builddir)/quiet_libtool @cat libtool | sed -e 's|$$show "$$command"|if test -z "$$suppress_output" ; then $$show "Compiling $$srcfile ..." ; fi|' > $(switch_builddir)/quiet_libtool
src/include/switch_version.h: src/include/switch_version.h.in .version $(libfreeswitch_la_SOURCES) $(library_include_HEADERS) src/include/switch_version.h: src/include/switch_version.h.in Makefile $(libfreeswitch_la_SOURCES) $(library_include_HEADERS)
@have_version=1 ; \ @cat $< > $@; \
force=0 ; \ if [ -d .git ]; then \
grep -- "@SWITCH_VERSION_REVISION@" src/include/switch_version.h.in > /dev/null || have_version=0 ; \ xdate="$$(date -d "$$(git log -n1 --format='%ci' HEAD)" -u '+%Y%m%dT%H%M%SZ')"; \
test ! -f src/include/switch_version.h || grep -- "@SWITCH_VERSION_REVISION@" src/include/switch_version.h > /dev/null && force=1 ; \ xcommit="$$(git rev-list -n1 --abbrev=10 --abbrev-commit HEAD)"; \
if test $$have_version = 1 ; then \ xver="+git~$$xdate~$$xcommit"; \
cat src/include/switch_version.h.in > src/include/switch_version.h ; \ if ! git diff-index --quiet HEAD; then \
touch .version ; \ xver="$$xver+unclean~$$(date -u +%Y%m%dT%H%M%SZ)"; \
else \ fi; \
if [ -d .git ] ; then \ sed \
version=`git log --pretty=format:"%h %ci" -1 HEAD | head -1 | sed -e 's|:|-|g' || echo hacked` ; \ -e "/#define *SWITCH_VERSION_REVISION/{s/\"\([^\"]*\)\"/\"\1$$xver\"/; :l n; b l}" \
if [ "x$$version" = "xhacked" ] ; then \ $< > $@; \
version="hacked-`date -u +%Y%m%dT%H%M%SZ`" ; \ fi;
else \
version="git-$$version" ; \
fi ;\
fi ; \
oldversion=`cat .version 2>/dev/null || echo "0"` ; \
if test "$$oldversion" != "$$version" || test $$force = 1 ; then \
cat src/include/switch_version.h.in | sed "s/@SWITCH_VERSION_REVISION@/$$version/g" > src/include/switch_version.h ; \
echo $$version > .version ; \
fi ; \
fi ;
## ##
## Dependency targets ## Dependency targets
...@@ -544,7 +534,6 @@ is-scm: ...@@ -544,7 +534,6 @@ is-scm:
update: is-scm update: is-scm
@if test -d .git ; then \ @if test -d .git ; then \
test ! -f .version || rm -f .version ; \
echo "Pulling updates..." ; \ echo "Pulling updates..." ; \
git pull ; \ git pull ; \
else \ else \
......
...@@ -10,7 +10,6 @@ AC_SUBST(SWITCH_VERSION_MICRO, [0]) ...@@ -10,7 +10,6 @@ AC_SUBST(SWITCH_VERSION_MICRO, [0])
AC_SUBST(SWITCH_VERSION_REVISION, [-rc2]) AC_SUBST(SWITCH_VERSION_REVISION, [-rc2])
AC_CONFIG_FILES([src/include/switch_version.h.in:src/include/switch_version.h.template]) AC_CONFIG_FILES([src/include/switch_version.h.in:src/include/switch_version.h.template])
AC_CONFIG_FILES([.version:.version.in])
AC_CONFIG_AUX_DIR(build/config) AC_CONFIG_AUX_DIR(build/config)
AM_INIT_AUTOMAKE(libfreeswitch,0.1) AM_INIT_AUTOMAKE(libfreeswitch,0.1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论