Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: enable read Git hash and date from file #3435

Merged
merged 8 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ test_keyvalue_result.txt

# ignore paths generated by helper tools
node_modules
include/VERSION_GIT
33 changes: 32 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -4939,6 +4939,7 @@ GRASS_BIN="${DSTDIR}/bin.${ARCH}"
# Set GRASS_VERSION_*

GRASS_VERSION_FILE=include/VERSION
GRASS_VERSION_GIT_FILE=include/VERSION_GIT
GRASS_VERSION_MAJOR=`sed -n 1p "${GRASS_VERSION_FILE}"`
GRASS_VERSION_MINOR=`sed -n 2p "${GRASS_VERSION_FILE}"`
GRASS_VERSION_RELEASE=`sed -n 3p "${GRASS_VERSION_FILE}"`
Expand Down Expand Up @@ -4996,6 +4997,27 @@ printf "%s\n" "no" >&6; }
fi


as_ac_File=`printf "%s\n" "ac_cv_file_$GRASS_VERSION_GIT_FILE" | $as_tr_sh`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $GRASS_VERSION_GIT_FILE" >&5
printf %s "checking for $GRASS_VERSION_GIT_FILE... " >&6; }

test "$cross_compiling" = yes &&
as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
if test -r "$GRASS_VERSION_GIT_FILE"; then
eval "$as_ac_File=yes"
else
eval "$as_ac_File=no"
fi
eval ac_res=\$$as_ac_File
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
printf "%s\n" "$ac_res" >&6; }
if eval test \"x\$"$as_ac_File"\" = x"yes"
then :

fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GRASS GIS headers commit date" >&5
printf %s "checking for GRASS GIS headers commit date... " >&6; }
if test "$GIT" != "no" ; then
GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null`
if test -z "$GRASS_VERSION_GIT"; then
Expand All @@ -5005,11 +5027,20 @@ if test "$GIT" != "no" ; then
if test -z "$GRASS_HEADERS_GIT_HASH"; then
GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}"
fi
GRASS_HEADERS_GIT_DATE=`date -d $($GIT log -1 --pretty=format:"%cI" -- "${SRCDIR}/include") -u +%FT%T%z | sed 's/\(..\)$/:\1/'` 2>/dev/null
gitdate_utc_local=$(TZ=UTC0 git log -1 --date=iso-local --pretty=format:"%cd" -- include)
GRASS_HEADERS_GIT_DATE=$(echo "$gitdate_utc_local" | sed 's/ /T/' | sed 's/ //' | sed 's/\(..\)$/:\1/')
if test -z "$GRASS_HEADERS_GIT_DATE"; then
GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'`
fi
fi
if test $GRASS_VERSION_GIT == "exported" && \
test "$ac_cv_file_include_VERSION_GIT" == "yes"; then
GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}")
GRASS_VERSION_GIT=$GRASS_HEADERS_GIT_HASH
GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}")
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $GRASS_HEADERS_GIT_DATE" >&5
printf "%s\n" "$GRASS_HEADERS_GIT_DATE" >&6; }



Expand Down
13 changes: 12 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ AC_SUBST(GRASS_BIN)
# Set GRASS_VERSION_*

GRASS_VERSION_FILE=include/VERSION
GRASS_VERSION_GIT_FILE=include/VERSION_GIT
GRASS_VERSION_MAJOR=`sed -n 1p "${GRASS_VERSION_FILE}"`
GRASS_VERSION_MINOR=`sed -n 2p "${GRASS_VERSION_FILE}"`
GRASS_VERSION_RELEASE=`sed -n 3p "${GRASS_VERSION_FILE}"`
Expand All @@ -160,6 +161,8 @@ GRASS_VERSION_GIT="exported"
GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}"
GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'`
AC_PATH_PROG(GIT, git, no)
AC_CHECK_FILE([$GRASS_VERSION_GIT_FILE])
AC_MSG_CHECKING(for GRASS GIS headers commit date)
if test "$GIT" != "no" ; then
GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null`
if test -z "$GRASS_VERSION_GIT"; then
Expand All @@ -169,11 +172,19 @@ if test "$GIT" != "no" ; then
if test -z "$GRASS_HEADERS_GIT_HASH"; then
GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}"
fi
GRASS_HEADERS_GIT_DATE=`date -d $($GIT log -1 --pretty=format:"%cI" -- "${SRCDIR}/include") -u +%FT%T%z | sed 's/\(..\)$/:\1/'` 2>/dev/null
gitdate_utc_local=$(TZ=UTC0 git log -1 --date=iso-local --pretty=format:"%cd" -- include)
GRASS_HEADERS_GIT_DATE=$(echo "$gitdate_utc_local" | sed 's/ /T/' | sed 's/ //' | sed 's/\(..\)$/:\1/')
if test -z "$GRASS_HEADERS_GIT_DATE"; then
GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'`
fi
fi
if test $GRASS_VERSION_GIT == "exported" && \
test "$ac_cv_file_include_VERSION_GIT" == "yes"; then
GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}")
GRASS_VERSION_GIT=$GRASS_HEADERS_GIT_HASH
GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}")
fi
AC_MSG_RESULT($GRASS_HEADERS_GIT_DATE)

AC_SUBST(GRASS_VERSION_FILE)
AC_SUBST(GRASS_VERSION_MAJOR)
Expand Down
27 changes: 27 additions & 0 deletions utils/generate_version_git_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -eu

this_script=$(basename "$0")
version_file=include/VERSION
version_git_file=include/VERSION_GIT

if [ ! -f "$version_file" ]; then
echo "Error: execute ${this_script} from repository top level."
exit 1
fi

if ! (git log -1 >/dev/null); then
echo "Error: git not available."
exit 1
fi

grass_version_git=$(git rev-parse --short HEAD)
gitdate_utc_local=$(TZ=UTC0 git log -1 --date=iso-local --pretty=format:"%cd" -- include)
grass_headers_git_date=$(echo "$gitdate_utc_local" \
| sed 's/ /T/' | sed 's/ //' | sed 's/\(..\)$/:\1/')
nilason marked this conversation as resolved.
Show resolved Hide resolved

cat << EOF > "$version_git_file"
$grass_version_git
$grass_headers_git_date
EOF
Loading