Commit cc5e205e authored by Sandro Santilli's avatar Sandro Santilli

Add support for GIT only revision references

Backports revisions 4388-4396 from trunk

Fixes #794 for 3.6 branch

git-svn-id: http://svn.osgeo.org/geos/branches/3.6@4396 5242fede-7e19-0410-aef8-94bd7d2200fb
parent dfe1f716
Pipeline #7427769 passed with stage
in 33 minutes and 40 seconds
......@@ -3,7 +3,7 @@ _build
aclocal.m4
Makefile.in
Makefile
geos_svn_revision.h
geos_revision.h
.libs
.deps
.vimrc
......
......@@ -241,8 +241,8 @@ include_directories(${PROJECT_BINARY_DIR}/capi)
# for including build-specific version.h, platform.h and geos_c.h
include_directories(${PROJECT_BINARY_DIR}/include)
# for geos_ts.cpp which does #include "../geos_svn_revision.h" whereas
# CMake generates geos_svn_revision.h in build directory,
# for geos_ts.cpp which does #include "../geos_revision.h" whereas
# CMake generates geos_revision.h in build directory,
# to not to pollute source tree.
include_directories(${PROJECT_BINARY_DIR})
......@@ -272,11 +272,11 @@ if(EXISTS "${PROJECT_SOURCE_DIR}/.svn")
GET_SVN_REVISION()
endif()
# geos_svn_revision.h does not exists in source or binary directory, we generate it
if( NOT EXISTS "${PROJECT_SOURCE_DIR}/geos_svn_revision.h" AND
NOT EXISTS "${PROJECT_BINARY_DIR}/geos_svn_revision.h")
# geos_revision.h does not exists in source or binary directory, we generate it
if( NOT EXISTS "${PROJECT_SOURCE_DIR}/geos_revision.h" AND
NOT EXISTS "${PROJECT_BINARY_DIR}/geos_revision.h")
message(STATUS "Generating GEOS revision header in ${PROJECT_BINARY_DIR}/geos_svn_revision.h")
message(STATUS "Generating GEOS revision header in ${PROJECT_BINARY_DIR}/geos_revision.h")
# CI builds (Travis CI, AppVeyor, etc.) perform git clone, not svn checkout.
# So, CI environment needs a dummy revision to generate the required header.
......@@ -285,22 +285,22 @@ if( NOT EXISTS "${PROJECT_SOURCE_DIR}/geos_svn_revision.h" AND
endif()
if ( NOT ${Project_WC_REVISION} EQUAL 0 )
set( GEOS_SVN_REVISION ${Project_WC_REVISION} )
set( GEOS_REVISION ${Project_WC_REVISION} )
configure_file (
"${PROJECT_SOURCE_DIR}/tools/geos_svn_revision_cmake.h.in"
"${PROJECT_BINARY_DIR}/geos_svn_revision.h" )
"${PROJECT_SOURCE_DIR}/tools/geos_revision_cmake.h.in"
"${PROJECT_BINARY_DIR}/geos_revision.h" )
else()
find_program(SH sh)
if(SH)
execute_process(COMMAND ${SH} -c
"cd ${PROJECT_SOURCE_DIR} && ${PROJECT_SOURCE_DIR}/tools/svn_repo_revision.sh")
"cd ${PROJECT_SOURCE_DIR} && ${PROJECT_SOURCE_DIR}/tools/repo_revision.sh")
file(RENAME "${PROJECT_SOURCE_DIR}/geos_svn_revision.h"
"${PROJECT_BINARY_DIR}/geos_svn_revision.h")
file(RENAME "${PROJECT_SOURCE_DIR}/geos_revision.h"
"${PROJECT_BINARY_DIR}/geos_revision.h")
else()
message("*** sh-compatible command not found, cannot create geos_svn_revision.h")
message("*** sh-compatible command not found, cannot create geos_revision.h")
message("*** Check SVN revision and create revision header manually:")
message("*** echo '#define GEOS_SVN_REVISION XYZ' > ${PROJECT_SOURCE_DIR}/geos_svn_revision.h")
message("*** echo '#define GEOS_REVISION XYZ' > ${PROJECT_SOURCE_DIR}/geos_revision.h")
endif()
endif()
endif()
......
......@@ -22,12 +22,12 @@ SUBDIRS = \
tests \
tools
BUILT_SOURCES = geos_svn_revision.h
BUILT_SOURCES = geos_revision.h
EXTRA_DIST = acsite.m4 makefile.vc nmake.opt autogen.bat CMakeLists.txt \
cmake/modules/CheckPrototypeExists.cmake \
cmake/modules/COPYING-CMAKE-SCRIPTS \
cmake/cmake_uninstall.cmake.in geos_svn_revision.h
cmake/cmake_uninstall.cmake.in geos_revision.h
ACLOCAL_AMFLAGS = -I macros
......@@ -56,12 +56,12 @@ authors.git: authors.svn
svnrebase: authors.git
cd $(srcdir) && git svn rebase --authors-file authors.git
geos_svn_revision.h:
top_srcdir=$(srcdir) sh $(srcdir)/tools/svn_repo_revision.sh
geos_revision.h:
top_srcdir=$(srcdir) sh $(srcdir)/tools/repo_revision.sh
VALGRIND = $(LIBTOOL) --mode=execute valgrind --leak-check=full --error-exitcode=1
valgrindcheck:
$(VALGRIND) tests/unit/geos_unit
.PHONY: geos_svn_revision.h
.PHONY: geos_revision.h
......@@ -14,4 +14,4 @@ set GEOS_HEADERS=include\geos
COPY %GEOS_HEADERS%\version.h.vc %GEOS_HEADERS%\version.h
COPY %GEOS_HEADERS%\platform.h.vc %GEOS_HEADERS%\platform.h
COPY capi\geos_c.h.in capi\geos_c.h
@ECHO #define GEOS_SVN_REVISION 0 > geos_svn_revision.h
\ No newline at end of file
@ECHO #define GEOS_REVISION "0" > geos_revision.h
......@@ -103,7 +103,7 @@
#define GEOSWKBWriter_t geos::io::WKBWriter
#include "geos_c.h"
#include "../geos_svn_revision.h"
#include "../geos_revision.h"
// Intentional, to allow non-standard C elements like C99 functions to be
// imported through C++ headers of C library, like <cmath>.
......@@ -3690,7 +3690,7 @@ GEOSGetSRID_r(GEOSContextHandle_t extHandle, const Geometry *g)
const char* GEOSversion()
{
static char version[256];
sprintf(version, "%s r%d", GEOS_CAPI_VERSION, GEOS_SVN_REVISION);
sprintf(version, "%s " GEOS_REVISION, GEOS_CAPI_VERSION);
return version;
}
......
......@@ -2,4 +2,4 @@
# This file is part of project GEOS (http://trac.osgeo.org/geos/)
bin_SCRIPTS = geos-config
EXTRA_DIST = CMakeLists.txt svn_repo_revision.sh
EXTRA_DIST = CMakeLists.txt repo_revision.sh
#define GEOS_REVISION "@GEOS_REVISION@"
#define GEOS_SVN_REVISION @GEOS_SVN_REVISION@
......@@ -3,7 +3,7 @@
LC_ALL="C" # what for ?
[ -z "$top_srcdir" ] && top_srcdir="."
rev_file=$top_srcdir'/geos_svn_revision.h'
rev_file=$top_srcdir'/geos_revision.h'
read_rev() {
......@@ -29,14 +29,24 @@ read_rev_git() {
echo 0;
fi
rev=`cd ${top_srcdir} && ${git_exe} log --grep=git-svn -1 | grep git-svn | cut -d@ -f2 | cut -d' ' -f1`
last_commit=`cd ${top_srcdir} && ${git_exe} log -1`
if test -z "$rev"; then
echo "Can't fetch SVN revision from git log" >&2
if test -z "$last_commit"; then
echo "Can't fetch last commit info from git log" >&2
echo 0
else
echo $rev
return
fi
svnrev=`echo "$last_commit" | grep git-svn | cut -d@ -f2 | cut -d' ' -f1`
if test -n "$svnrev"; then
# Last commit has SVN metadata, we'll use that
echo r$svnrev
return
fi
# Last commit has no SVN metadata, we'll use sha
sha=`cd ${top_srcdir} && ${git_exe} describe --always`
echo $sha
}
read_rev_svn() {
......@@ -57,7 +67,7 @@ read_rev_svn() {
echo "Can't fetch SVN revision with `svn info`" >&2
echo 0
else
echo ${svn_info}
echo r${svn_info}
fi
}
......@@ -68,19 +78,19 @@ write_defn() {
# Do not override the file if new detected
# revision isn't zero nor different from the existing one
if test -f $rev_file; then
oldrev=`grep GEOS_SVN_REVISION ${rev_file} | awk '{print $2}'`
oldrev=`grep GEOS_REVISION ${rev_file} | awk '{print $2}'`
if test "$rev" = 0 -o "$rev" = "$oldrev"; then
echo "Not updating existing rev file at $oldrev" >&2
return;
fi
fi
echo "#define GEOS_SVN_REVISION $rev" | tee $rev_file
echo "#define GEOS_REVISION \"$rev\"" | tee $rev_file
echo "Wrote rev '$rev' in file '$rev_file'" >&2
}
# Read the svn revision number
svn_rev=`read_rev`
# Write it
# Write it
write_defn $svn_rev
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment