[geos-commits] r4396 - in branches/3.6: . capi tools

Sandro Santilli strk at kbt.io
Tue Apr 4 02:19:56 PDT 2017


Author: strk
Date: 2017-04-04 02:19:55 -0700 (Tue, 04 Apr 2017)
New Revision: 4396

Added:
   branches/3.6/tools/geos_revision_cmake.h.in
   branches/3.6/tools/repo_revision.sh
Removed:
   branches/3.6/tools/geos_svn_revision_cmake.h.in
   branches/3.6/tools/svn_repo_revision.sh
Modified:
   branches/3.6/.gitignore
   branches/3.6/CMakeLists.txt
   branches/3.6/Makefile.am
   branches/3.6/autogen.bat
   branches/3.6/capi/geos_ts_c.cpp
   branches/3.6/tools/Makefile.am
Log:
Add support for GIT only revision references

Backports revisions 4388-4396 from trunk

Fixes #794 for 3.6 branch

Modified: branches/3.6/.gitignore
===================================================================
--- branches/3.6/.gitignore	2017-04-02 09:31:00 UTC (rev 4395)
+++ branches/3.6/.gitignore	2017-04-04 09:19:55 UTC (rev 4396)
@@ -3,7 +3,7 @@
 aclocal.m4
 Makefile.in
 Makefile
-geos_svn_revision.h
+geos_revision.h
 .libs
 .deps
 .vimrc

Modified: branches/3.6/CMakeLists.txt
===================================================================
--- branches/3.6/CMakeLists.txt	2017-04-02 09:31:00 UTC (rev 4395)
+++ branches/3.6/CMakeLists.txt	2017-04-04 09:19:55 UTC (rev 4396)
@@ -241,8 +241,8 @@
 # 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 @@
   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 @@
   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()

Modified: branches/3.6/Makefile.am
===================================================================
--- branches/3.6/Makefile.am	2017-04-02 09:31:00 UTC (rev 4395)
+++ branches/3.6/Makefile.am	2017-04-04 09:19:55 UTC (rev 4396)
@@ -22,12 +22,12 @@
     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 @@
 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

Modified: branches/3.6/autogen.bat
===================================================================
--- branches/3.6/autogen.bat	2017-04-02 09:31:00 UTC (rev 4395)
+++ branches/3.6/autogen.bat	2017-04-04 09:19:55 UTC (rev 4396)
@@ -14,4 +14,4 @@
 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
- at ECHO #define GEOS_SVN_REVISION 0 > geos_svn_revision.h
\ No newline at end of file
+ at ECHO #define GEOS_REVISION "0" > geos_revision.h

Modified: branches/3.6/capi/geos_ts_c.cpp
===================================================================
--- branches/3.6/capi/geos_ts_c.cpp	2017-04-02 09:31:00 UTC (rev 4395)
+++ branches/3.6/capi/geos_ts_c.cpp	2017-04-04 09:19:55 UTC (rev 4396)
@@ -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 @@
 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;
 }
 

Modified: branches/3.6/tools/Makefile.am
===================================================================
--- branches/3.6/tools/Makefile.am	2017-04-02 09:31:00 UTC (rev 4395)
+++ branches/3.6/tools/Makefile.am	2017-04-04 09:19:55 UTC (rev 4396)
@@ -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

Added: branches/3.6/tools/geos_revision_cmake.h.in
===================================================================
--- branches/3.6/tools/geos_revision_cmake.h.in	                        (rev 0)
+++ branches/3.6/tools/geos_revision_cmake.h.in	2017-04-04 09:19:55 UTC (rev 4396)
@@ -0,0 +1 @@
+#define GEOS_REVISION "@GEOS_REVISION@"

Deleted: branches/3.6/tools/geos_svn_revision_cmake.h.in
===================================================================
--- branches/3.6/tools/geos_svn_revision_cmake.h.in	2017-04-02 09:31:00 UTC (rev 4395)
+++ branches/3.6/tools/geos_svn_revision_cmake.h.in	2017-04-04 09:19:55 UTC (rev 4396)
@@ -1 +0,0 @@
-#define GEOS_SVN_REVISION @GEOS_SVN_REVISION@ 

Copied: branches/3.6/tools/repo_revision.sh (from rev 4385, branches/3.6/tools/svn_repo_revision.sh)
===================================================================
--- branches/3.6/tools/repo_revision.sh	                        (rev 0)
+++ branches/3.6/tools/repo_revision.sh	2017-04-04 09:19:55 UTC (rev 4396)
@@ -0,0 +1,96 @@
+#!/bin/sh
+
+LC_ALL="C" # what for ?
+
+[ -z "$top_srcdir" ] && top_srcdir="."
+rev_file=$top_srcdir'/geos_revision.h'
+
+read_rev() {
+
+    if test -d $top_srcdir"/.svn"; then
+      read_rev_svn
+    elif test -d $top_srcdir"/.git"; then
+      read_rev_git
+    else
+      echo "Can't fetch local revision (neither .svn nor .git found)" >&2
+      echo 0
+    fi
+}
+
+read_rev_git() {
+
+  # TODO: test on old systems, I think I saw some `which`
+  #       implementations returning "nothing found" or something
+  #       like that, making the later if ( ! $svn_exe ) always false
+  #
+  git_exe=`which git`;
+  if test -z "$git_exe"; then
+    echo "Can't fetch SVN revision: no git executable found" >&2
+    echo 0;
+  fi
+
+  last_commit=`cd ${top_srcdir} && ${git_exe} log -1`
+
+  if test -z "$last_commit"; then
+    echo "Can't fetch last commit info from git log" >&2
+    echo 0
+    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() {
+
+  # TODO: test on old systems, I think I saw some `which`
+  #       implementations returning "nothing found" or something
+  #       like that, making the later if ( ! $svn_exe ) always false
+  #
+  svn_exe=`which svn`
+  if test -z "$svn_exe"; then
+    echo "Can't fetch SVN revision: no svn executable found" >&2
+    echo 0;
+  fi
+
+  svn_info=`"${svn_exe}" info | grep 'Last Changed Rev:' | cut -d: -f2`
+
+  if test -z "$svn_info"; then
+    echo "Can't fetch SVN revision with `svn info`" >&2
+    echo 0
+  else
+    echo r${svn_info}
+  fi
+}
+
+write_defn() {
+  rev=$1
+  oldrev=0
+
+  # 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_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_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_defn $svn_rev

Deleted: branches/3.6/tools/svn_repo_revision.sh
===================================================================
--- branches/3.6/tools/svn_repo_revision.sh	2017-04-02 09:31:00 UTC (rev 4395)
+++ branches/3.6/tools/svn_repo_revision.sh	2017-04-04 09:19:55 UTC (rev 4396)
@@ -1,86 +0,0 @@
-#!/bin/sh
-
-LC_ALL="C" # what for ?
-
-[ -z "$top_srcdir" ] && top_srcdir="."
-rev_file=$top_srcdir'/geos_svn_revision.h'
-
-read_rev() {
-
-    if test -d $top_srcdir"/.svn"; then
-      read_rev_svn
-    elif test -d $top_srcdir"/.git"; then
-      read_rev_git
-    else
-      echo "Can't fetch local revision (neither .svn nor .git found)" >&2
-      echo 0
-    fi
-}
-
-read_rev_git() {
-
-  # TODO: test on old systems, I think I saw some `which`
-  #       implementations returning "nothing found" or something
-  #       like that, making the later if ( ! $svn_exe ) always false
-  #
-  git_exe=`which git`;
-  if test -z "$git_exe"; then
-    echo "Can't fetch SVN revision: no git executable found" >&2
-    echo 0;
-  fi
-
-  rev=`cd ${top_srcdir} && ${git_exe} log --grep=git-svn -1 | grep git-svn | cut -d@ -f2 | cut -d' ' -f1`
-
-  if test -z "$rev"; then
-    echo "Can't fetch SVN revision from git log" >&2 
-    echo 0
-  else
-    echo $rev
-  fi
-}
-
-read_rev_svn() {
-
-  # TODO: test on old systems, I think I saw some `which`
-  #       implementations returning "nothing found" or something
-  #       like that, making the later if ( ! $svn_exe ) always false
-  #
-  svn_exe=`which svn`
-  if test -z "$svn_exe"; then
-    echo "Can't fetch SVN revision: no svn executable found" >&2
-    echo 0;
-  fi
-
-  svn_info=`"${svn_exe}" info | grep 'Last Changed Rev:' | cut -d: -f2`
-
-  if test -z "$svn_info"; then
-    echo "Can't fetch SVN revision with `svn info`" >&2
-    echo 0
-  else
-    echo ${svn_info}
-  fi
-}
-
-write_defn() {
-  rev=$1
-  oldrev=0
-
-  # 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}'`
-    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 "Wrote rev '$rev' in file '$rev_file'" >&2
-}
-
-# Read the svn revision number
-svn_rev=`read_rev`
-
-# Write it 
-write_defn $svn_rev



More information about the geos-commits mailing list