Browse Source

grass.py: used space as delimiter to get GRASS_VERSION_STRING (#405)

* use space delimiter for GIS_H_VERSION

* choose GRASS_VERSION_STRING list element

* report header version and date

* write GRASS_VERSION_GIT to grass.py

* use GRASS_VERSION_GIT

* write GRASS_VERSION_GIT to grass.py

* fix tab indent

* add date

* add date

* get date correctly after #325

* get date correctly after #325

* date: no indent, no quotes

* Update lib/init/grass.py

Co-Authored-By: Markus Neteler <neteler@gmail.com>

Co-authored-by: Stefan Blumentrath <stefan@vm-srv-wallace.vm.ntnu.no>
Co-authored-by: Martin Landa <landa.martin@gmail.com>
Co-authored-by: Markus Neteler <neteler@gmail.com>
Stefan Blumentrath 5 years ago
parent
commit
f59a1c088b
2 changed files with 16 additions and 10 deletions
  1. 2 0
      lib/init/Makefile
  2. 14 10
      lib/init/grass.py

+ 2 - 0
lib/init/Makefile

@@ -68,6 +68,7 @@ endif
 	sed \
 	sed \
 	-e 's#@GISBASE@#$(RUN_GISBASE)#' \
 	-e 's#@GISBASE@#$(RUN_GISBASE)#' \
 	-e 's#@GRASS_VERSION_NUMBER@#$(GRASS_VERSION_NUMBER)#' \
 	-e 's#@GRASS_VERSION_NUMBER@#$(GRASS_VERSION_NUMBER)#' \
+	-e 's#@GRASS_VERSION_GIT@#$(GRASS_VERSION_GIT)#' \
 	-e 's#@LD_LIBRARY_PATH_VAR@#$(LD_LIBRARY_PATH_VAR)#' \
 	-e 's#@LD_LIBRARY_PATH_VAR@#$(LD_LIBRARY_PATH_VAR)#' \
 	-e 's#@START_UP@#$(START_UP)#' \
 	-e 's#@START_UP@#$(START_UP)#' \
 	-e 's#@CONFIG_PROJSHARE@#$(PROJSHARE)#' \
 	-e 's#@CONFIG_PROJSHARE@#$(PROJSHARE)#' \
@@ -78,6 +79,7 @@ $(ARCH_DISTDIR)/$(START_UP).tmp: grass.py
 	rm -f $@
 	rm -f $@
 	sed \
 	sed \
 	-e 's#@GRASS_VERSION_NUMBER@#$(GRASS_VERSION_NUMBER)#' \
 	-e 's#@GRASS_VERSION_NUMBER@#$(GRASS_VERSION_NUMBER)#' \
+	-e 's#@GRASS_VERSION_GIT@#$(GRASS_VERSION_GIT)#' \
 	-e 's#@START_UP@#$(START_UP)#' \
 	-e 's#@START_UP@#$(START_UP)#' \
 	-e 's#@GRASS_CONFIG_DIR@#$(GRASS_CONFIG_DIR)#' \
 	-e 's#@GRASS_CONFIG_DIR@#$(GRASS_CONFIG_DIR)#' \
 	-e 's#@LD_LIBRARY_PATH_VAR@#$(LD_LIBRARY_PATH_VAR)#' \
 	-e 's#@LD_LIBRARY_PATH_VAR@#$(LD_LIBRARY_PATH_VAR)#' \

+ 14 - 10
lib/init/grass.py

@@ -339,7 +339,7 @@ def help_message(default_gui):
             gui=_("use $DEFAULT_GUI graphical user interface"),
             gui=_("use $DEFAULT_GUI graphical user interface"),
             gui_detail=_("and set as default"),
             gui_detail=_("and set as default"),
             config=_("print GRASS configuration parameters"),
             config=_("print GRASS configuration parameters"),
-            config_detail=_("options: arch,build,compiler,path,revision,svn_revision,version"),
+            config_detail=_("options: arch,build,compiler,date,path,revision,svn_revision,version"),
             params=_("Parameters"),
             params=_("Parameters"),
             gisdbase=_("initial GRASS database directory"),
             gisdbase=_("initial GRASS database directory"),
             gisdbase_detail=_("directory containing Locations"),
             gisdbase_detail=_("directory containing Locations"),
@@ -1990,10 +1990,10 @@ def print_params():
     """Write compile flags and other configuration to stderr"""
     """Write compile flags and other configuration to stderr"""
     params = sys.argv[2:]
     params = sys.argv[2:]
     if not params:
     if not params:
-        params = ['arch', 'build', 'compiler', 'path', 'revision', 'version']
+        params = ['arch', 'build', 'compiler', 'path', 'revision', 'version', 'date']
 
 
     # check if we are dealing with parameters which require dev files
     # check if we are dealing with parameters which require dev files
-    dev_params = ["arch", "compiler", "build", "revision"]
+    dev_params = ["arch", "compiler", "build", "date"]
     if any([param in dev_params for param in params]):
     if any([param in dev_params for param in params]):
         plat = gpath('include', 'Make', 'Platform.make')
         plat = gpath('include', 'Make', 'Platform.make')
         if not os.path.exists(plat):
         if not os.path.exists(plat):
@@ -2019,13 +2019,7 @@ def print_params():
             val = grep('CC', linesplat)
             val = grep('CC', linesplat)
             sys.stdout.write("%s\n" % val[0].split('=')[1].strip())
             sys.stdout.write("%s\n" % val[0].split('=')[1].strip())
         elif arg == 'revision':
         elif arg == 'revision':
-            rev = gpath('include', 'grass', 'gis.h')
-            filerev = open(rev)
-            linesrev = filerev.readlines()
-            val = grep('#define GIS_H_VERSION', linesrev)
-            filerev.close()
-            sys.stdout.write(
-                "%s\n" % val[0].split(':')[1].rstrip('$"\n').strip())
+            sys.stdout.write("@GRASS_VERSION_GIT@\n")
         elif arg == 'svn_revision':
         elif arg == 'svn_revision':
             filerev = open(gpath('etc', 'VERSIONNUMBER'))
             filerev = open(gpath('etc', 'VERSIONNUMBER'))
             linerev = filerev.readline().rstrip('\n')
             linerev = filerev.readline().rstrip('\n')
@@ -2037,6 +2031,16 @@ def print_params():
                sys.stdout.write("No SVN revision defined\n")
                sys.stdout.write("No SVN revision defined\n")
         elif arg == 'version':
         elif arg == 'version':
             sys.stdout.write("%s\n" % GRASS_VERSION)
             sys.stdout.write("%s\n" % GRASS_VERSION)
+        elif arg == 'date':
+            date_str = "#define GRASS_HEADERS_DATE "
+            gdate = gpath('include', 'grass', 'version.h')
+            with open(gdate) as filegdate:
+                for line in filegdate.readlines():
+                    if line.startswith(date_str):
+                        sys.stdout.write('{}\n'.format(
+                            line.replace(date_str, '').lstrip()[1:-2]) # remove quotes
+                        )
+                        break
         else:
         else:
             message(_("Parameter <%s> not supported") % arg)
             message(_("Parameter <%s> not supported") % arg)