]> granicus.if.org Git - graphviz/commitdiff
push build system version computation into Python
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Nov 2022 17:31:19 +0000 (09:31 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 24 Nov 2022 18:50:23 +0000 (10:50 -0800)
The Autotools build system was doing quite a bit of work to try and find a
`date` syntax that worked on the current platform and still failing (this logic
does not work on NetBSD). We can side step all of this by just doing date
manipulation in Python which we were calling anyway.

Gitlab: #2317

autogen.sh
configure.ac
gen_version.py

index e9aba690d2d1b5bb479c924eae847bb785c272b5..e194d5ca6f95cc652804d8968a99db9c7947c593 100755 (executable)
@@ -4,28 +4,12 @@ GRAPHVIZ_VERSION_MAJOR=$( python3 gen_version.py --major )
 GRAPHVIZ_VERSION_MINOR=$( python3 gen_version.py --minor )
 GRAPHVIZ_VERSION_PATCH=$( python3 gen_version.py --patch )
 
-if ! GRAPHVIZ_GIT_DATE=$( python3 gen_version.py --committer-date-iso ) ; then
-    echo "Error: Failed to set date" >&2
-    exit 1
-fi
-if [ "$GRAPHVIZ_GIT_DATE" = "0" ]; then
-    GRAPHVIZ_VERSION_DATE="0"
+GRAPHVIZ_VERSION_DATE=$( python3 gen_version.py --committer-date-graphviz )
+GRAPHVIZ_CHANGE_DATE=$( python3 gen_version.py --committer-date-changelog )
+
+if [ "$GRAPHVIZ_VERSION_DATE" = "0" ]; then
     echo "Warning: build not started in a Git clone, or Git is not installed: setting version date to 0." >&2
 else
-    GRAPHVIZ_AUTHOR_NAME=$( git log -n 1 --format="%an" )
-    GRAPHVIZ_AUTHOR_EMAIL=$( git log -n 1 --format="%ae" )
-    if ! GRAPHVIZ_VERSION_DATE=$( date -u +%Y%m%d.%H%M -d "$GRAPHVIZ_GIT_DATE" 2>/dev/null ) ; then
-        # try date with FreeBSD syntax
-        if ! GRAPHVIZ_VERSION_DATE=$( date -u -j -f "%Y-%m-%d %H:%M:%S" "$GRAPHVIZ_GIT_DATE" "+%Y%m%d.%H%M" 2>/dev/null); then
-            echo "Warning: we do not know how to invoke date correctly." >&2
-        fi    
-    fi
-    if ! GRAPHVIZ_CHANGE_DATE=$( date -u +"%a %b %e %Y" -d "$GRAPHVIZ_GIT_DATE" 2>/dev/null ) ; then
-        # try date with FreeBSD syntax
-        if ! GRAPHVIZ_CHANGE_DATE=$( date -u -j -f "%Y-%m-%d %H:%M:%S"  "$GRAPHVIZ_GIT_DATE" "+%a %b %e %Y" 2>/dev/null); then
-            echo "Warning: we do not know how to invoke date correctly." >&2
-        fi    
-    fi
     echo "Graphviz: version date is based on time of last commit: $GRAPHVIZ_VERSION_DATE"
 fi
 
@@ -39,7 +23,6 @@ m4_define([graphviz_version_micro],[$GRAPHVIZ_VERSION_PATCH])
 
 m4_define([graphviz_version_date],[$GRAPHVIZ_VERSION_DATE])
 m4_define([graphviz_change_date],["$GRAPHVIZ_CHANGE_DATE"])
-m4_define([graphviz_git_date],["$GRAPHVIZ_GIT_DATE"])
 m4_define([graphviz_author_name],["$GRAPHVIZ_AUTHOR_NAME"])
 m4_define([graphviz_author_email],[$GRAPHVIZ_AUTHOR_EMAIL])
 
index 67aff3626bd947bf5f79676e7020fc4f5f51e824..a15bd0bc179df0956604f38f1892466eb3fa71fb 100644 (file)
@@ -24,7 +24,6 @@ GRAPHVIZ_VERSION_MICRO=graphviz_version_micro()
 # NB: date/time of last commit - or "0"
 GRAPHVIZ_VERSION_DATE=graphviz_version_date()
 
-GRAPHVIZ_GIT_DATE=graphviz_git_date()
 GRAPHVIZ_AUTHOR_NAME=graphviz_author_name()
 GRAPHVIZ_AUTHOR_EMAIL=graphviz_author_email()
 GRAPHVIZ_CHANGE_DATE=graphviz_change_date()
@@ -33,7 +32,6 @@ AC_SUBST([GRAPHVIZ_VERSION_MAJOR])
 AC_SUBST([GRAPHVIZ_VERSION_MINOR])
 AC_SUBST([GRAPHVIZ_VERSION_MICRO])
 AC_SUBST([GRAPHVIZ_VERSION_DATE])
-AC_SUBST([GRAPHVIZ_GIT_DATE])
 AC_SUBST([GRAPHVIZ_AUTHOR_NAME])
 AC_SUBST([GRAPHVIZ_AUTHOR_EMAIL])
 AC_SUBST([GRAPHVIZ_CHANGE_DATE])
index f8430f455c72c96a420fd2dd2aa4c7d8098c9853..e277186f78b4566ff548ad5ae93a074bb08fc20a 100644 (file)
@@ -82,14 +82,14 @@ def get_version() -> Tuple[int, int, int, str]:
   return major, minor, patch, coll
 
 graphviz_date_format = "%Y%m%d.%H%M"
-iso_date_format = "%Y-%m-%d %H:%M:%S"
+changelog_date_format = "%a %b %e %Y"
 
 parser = argparse.ArgumentParser(description="Generate Graphviz version.")
-parser.add_argument("--committer-date-iso",
+parser.add_argument("--committer-date-changelog",
                     dest="date_format",
                     action="store_const",
-                    const=iso_date_format,
-                    help="Print ISO formatted committer date in UTC instead of version"
+                    const=changelog_date_format,
+                    help="Print changelog formatted committer date in UTC instead of version"
 )
 parser.add_argument("--committer-date-graphviz",
                     dest="date_format",