Skip to content

Commit

Permalink
grass.py: used space as delimiter to get GRASS_VERSION_STRING (#405)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people committed Apr 20, 2020
1 parent 4bb3a3a commit f59a1c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lib/init/Makefile
Expand Up @@ -68,6 +68,7 @@ endif
sed \
-e 's#@GISBASE@#$(RUN_GISBASE)#' \
-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#@START_UP@#$(START_UP)#' \
-e 's#@CONFIG_PROJSHARE@#$(PROJSHARE)#' \
Expand All @@ -78,6 +79,7 @@ $(ARCH_DISTDIR)/$(START_UP).tmp: grass.py
rm -f $@
sed \
-e 's#@GRASS_VERSION_NUMBER@#$(GRASS_VERSION_NUMBER)#' \
-e 's#@GRASS_VERSION_GIT@#$(GRASS_VERSION_GIT)#' \
-e 's#@START_UP@#$(START_UP)#' \
-e 's#@GRASS_CONFIG_DIR@#$(GRASS_CONFIG_DIR)#' \
-e 's#@LD_LIBRARY_PATH_VAR@#$(LD_LIBRARY_PATH_VAR)#' \
Expand Down
24 changes: 14 additions & 10 deletions lib/init/grass.py
Expand Up @@ -339,7 +339,7 @@ def help_message(default_gui):
gui=_("use $DEFAULT_GUI graphical user interface"),
gui_detail=_("and set as default"),
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"),
gisdbase=_("initial GRASS database directory"),
gisdbase_detail=_("directory containing Locations"),
Expand Down Expand Up @@ -1990,10 +1990,10 @@ def print_params():
"""Write compile flags and other configuration to stderr"""
params = sys.argv[2:]
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
dev_params = ["arch", "compiler", "build", "revision"]
dev_params = ["arch", "compiler", "build", "date"]
if any([param in dev_params for param in params]):
plat = gpath('include', 'Make', 'Platform.make')
if not os.path.exists(plat):
Expand All @@ -2019,13 +2019,7 @@ def print_params():
val = grep('CC', linesplat)
sys.stdout.write("%s\n" % val[0].split('=')[1].strip())
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':
filerev = open(gpath('etc', 'VERSIONNUMBER'))
linerev = filerev.readline().rstrip('\n')
Expand All @@ -2037,6 +2031,16 @@ def print_params():
sys.stdout.write("No SVN revision defined\n")
elif arg == '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:
message(_("Parameter <%s> not supported") % arg)

Expand Down

0 comments on commit f59a1c0

Please sign in to comment.