mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Additional changes to use commit date rather than build date
This effectively replaces the use of GNUCASH_BUILD_DATE with GNUCASH_SCM_REV_DATE. The latter is extracted from the current commit if building from some kind of vcs (currently only works correctly for svn and git). The info extracted while building from vcs is then also added to the dist tarball so it's available when building from tarball as well (via the file libgnucash/core-utils/gnc-vcs-info.h). The same date is also used to set the date in gnucash' man page document. A practical detail: I have changed the substitution variables in the man page template from @- -@ to ${} so we could leverage CONFIGURE_FILE in cmake. The necessary related adjustments have also been made to Makefile.am's substitution rules.
This commit is contained in:
parent
f9b2d8ce57
commit
e56cb37813
@ -3,7 +3,7 @@ if GNUCASH_ENABLE_GUI
|
||||
else
|
||||
GNUCASH_SUBDIR =
|
||||
endif
|
||||
SUBDIRS = . doc borrowed common libgnucash bindings ${GNUCASH_SUBDIR} po data
|
||||
SUBDIRS = . borrowed common libgnucash bindings ${GNUCASH_SUBDIR} doc po data
|
||||
|
||||
GNC_CTAGS_FILE = @GNC_CTAGS_FILE@
|
||||
GNC_ETAGS_FILE = @GNC_ETAGS_FILE@
|
||||
|
@ -28,23 +28,6 @@ SET(doc_DIST ${doc_DIST_local} ${examples_DIST} PARENT_SCOPE)
|
||||
|
||||
FILE(COPY ${doc_DATA} DESTINATION ${DATADIR_BUILD}/doc/gnucash)
|
||||
|
||||
IF (${CMAKE_VERSION} VERSION_GREATER 3.1)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E env date +"%B %Y"
|
||||
OUTPUT_VARIABLE DATE_IN
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
ELSE()
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND date +"%B %Y"
|
||||
OUTPUT_VARIABLE DATE_IN
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# Remove any quotes present in the DATE string
|
||||
STRING(REGEX REPLACE "\"" "" DATE "${DATE_IN}")
|
||||
|
||||
# Generate the tip of the day file.
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
@ -72,9 +55,34 @@ FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}/tip_of_the_day.list
|
||||
DESTINATION ${DATADIR_BUILD}/gnucash)
|
||||
|
||||
# ---
|
||||
IF (BUILDING_FROM_VCS)
|
||||
SET(VCS_INFO_BASE_DIR ${CMAKE_BINARY_DIR})
|
||||
ELSE()
|
||||
SET(VCS_INFO_BASE_DIR ${CMAKE_SOURCE_DIR})
|
||||
ENDIF()
|
||||
SET(VCS_INFO_FILE ${VCS_INFO_BASE_DIR}/libgnucash/core-utils/gnc-vcs-info.h)
|
||||
|
||||
# The copious use of backslashes below is to escape escape sequences that
|
||||
# have to end up in the file being written...
|
||||
# eg \\\" will become \", \\\\1 will become \\1 (which cmake will then interpret as \1)
|
||||
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/manpage.cmake
|
||||
"FILE(STRINGS \${VCS_INFO_FILE} ym_line REGEX \"GNUCASH_SCM_REV_Y_M\")
|
||||
STRING(REGEX REPLACE \"^.* \\\"(.*)\\\"\" \"\\\\1\" DATE \${ym_line})
|
||||
CONFIGURE_FILE(\${SRC} \${DST} )
|
||||
FILE(COPY gnucash.1
|
||||
DESTINATION \${DATADIR_BUILD}/gnucash)
|
||||
")
|
||||
|
||||
|
||||
ADD_CUSTOM_COMMAND(OUTPUT gnucash.1
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.1.in gnc-vcs-info
|
||||
COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/gnucash.1.in
|
||||
-D DST=gnucash.1
|
||||
-D VERSION=${VERSION}
|
||||
-D VCS_INFO_FILE=${VCS_INFO_FILE}
|
||||
-D DATADIR_BUILD=${DATADIR_BUILD}
|
||||
-P ${CMAKE_CURRENT_BINARY_DIR}/manpage.cmake
|
||||
)
|
||||
ADD_CUSTOM_TARGET(gnucash-manpage DEPENDS gnucash.1)
|
||||
|
||||
GNC_CONFIGURE(gnucash.1.in gnucash.1 )
|
||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.1 DESTINATION share/man/man1)
|
||||
|
||||
FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}/gnucash.1
|
||||
DESTINATION ${DATADIR_BUILD}/gnucash)
|
@ -38,18 +38,28 @@ EXTRA_DIST = \
|
||||
tip_of_the_day.list.in \
|
||||
CMakeLists.txt
|
||||
|
||||
gnucash.1: gnucash.1.in Makefile
|
||||
rm -f $@.tmp
|
||||
if BUILDING_FROM_VCS
|
||||
GNUCASH_SCM_REV_Y_M=`perl -ne 'print if $$_=~s/.*GNUCASH_SCM_REV_Y_M "(.*)"/$$1/' ${top_builddir}/libgnucash/core-utils/gnc-vcs-info.h` ; \
|
||||
${SED} < $< > $@.tmp \
|
||||
-e 's:$${VERSION}:${VERSION}:g' \
|
||||
-e 's:$${DATE}:'$${GNUCASH_SCM_REV_Y_M}':g'
|
||||
chmod +x $@.tmp
|
||||
mv $@.tmp $@
|
||||
else
|
||||
GNUCASH_SCM_REV_Y_M=`perl -ne 'print if $$_=~s/.*GNUCASH_SCM_REV_Y_M "(.*)"/$$1/' ${top_srcdir}/libgnucash/core-utils/gnc-vcs-info.h` ; \
|
||||
${SED} < $< > $@.tmp \
|
||||
-e 's:$${VERSION}:${VERSION}:g' \
|
||||
-e 's:$${DATE}:'$${GNUCASH_SCM_REV_Y_M}':g'
|
||||
chmod +x $@.tmp
|
||||
mv $@.tmp $@
|
||||
endif
|
||||
|
||||
## We borrow guile's convention and use @-...-@ as the substitution
|
||||
## brackets here, instead of the usual @...@. This prevents autoconf
|
||||
## from substituting the values directly into the left-hand sides of
|
||||
## the sed substitutions.
|
||||
gnucash.1: gnucash.1.in Makefile
|
||||
rm -f $@.tmp
|
||||
${SED} < $< > $@.tmp \
|
||||
-e 's:@-VERSION-@:${VERSION}:g' \
|
||||
-e 's:@-DATE-@:$(shell date +'%B %Y'):g'
|
||||
chmod +x $@.tmp
|
||||
mv $@.tmp $@
|
||||
|
||||
tip_of_the_day.list: tip_of_the_day.list.in Makefile
|
||||
${CC} -E -P -x c -D'N_(x)=x' -o $@.tmp $<
|
||||
cat -s $@.tmp | ${SED} -e 's/^ *"//' \
|
||||
|
@ -2,7 +2,7 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii foo.1
|
||||
.\"
|
||||
.TH GNUCASH 1 "@-DATE-@" Version "@-VERSION-@"
|
||||
.TH GNUCASH 1 "${DATE}" Version "${VERSION}"
|
||||
.SH NAME
|
||||
gnucash \- personal finance manager
|
||||
.SH SYNOPSIS
|
||||
|
@ -34,6 +34,8 @@ ADD_EXECUTABLE (gnucash
|
||||
${gnucash_SOURCES}
|
||||
)
|
||||
|
||||
ADD_DEPENDENCIES (gnucash gnucash-manpage)
|
||||
|
||||
TARGET_COMPILE_DEFINITIONS(gnucash PRIVATE -DG_LOG_DOMAIN=\"gnc.bin\")
|
||||
|
||||
TARGET_LINK_LIBRARIES (gnucash
|
||||
|
@ -4464,7 +4464,7 @@ gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *window)
|
||||
const gchar *fixed_message = _("The GnuCash personal finance manager. "
|
||||
"The GNU way to manage your money!");
|
||||
gchar *copyright = g_strdup_printf(_("© 1997-%s Contributors"),
|
||||
GNUCASH_BUILD_YEAR);
|
||||
GNUCASH_SCM_REV_YEAR);
|
||||
gchar **authors = get_file_strsplit("AUTHORS");
|
||||
gchar **documenters = get_file_strsplit("DOCUMENTERS");
|
||||
gchar *license = get_file("LICENSE");
|
||||
@ -4483,16 +4483,16 @@ gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *window)
|
||||
2nd %s is the scm type (svn/svk/git/bzr);
|
||||
3rd %s is the scm revision number;
|
||||
4th %s is the build date */
|
||||
message = g_strdup_printf(_("%s\nThis copy was built from %s rev %s on %s."),
|
||||
message = g_strdup_printf(_("%s\nThis copy was built from %s rev %s (commit date %s)."),
|
||||
fixed_message, GNUCASH_SCM, GNUCASH_SCM_REV,
|
||||
GNUCASH_BUILD_DATE);
|
||||
GNUCASH_SCM_REV_DATE);
|
||||
#else
|
||||
/* Translators: 1st %s is a fixed message, which is translated independently;
|
||||
2nd %s is the scm (svn/svk/git/bzr) revision number;
|
||||
3rd %s is the build date */
|
||||
message = g_strdup_printf(_("%s\nThis copy was built from rev %s on %s."),
|
||||
message = g_strdup_printf(_("%s\nThis copy was built from rev %s (commit date %s)."),
|
||||
fixed_message, GNUCASH_SCM_REV,
|
||||
GNUCASH_BUILD_DATE);
|
||||
GNUCASH_SCM_REV_DATE);
|
||||
#endif
|
||||
priv->about_dialog = gtk_about_dialog_new ();
|
||||
g_object_set (priv->about_dialog,
|
||||
|
@ -99,16 +99,16 @@ gnc_show_splash_screen (void)
|
||||
2nd %s is the scm type (svn/svk/git/bzr);
|
||||
3rd %s is the scm revision number;
|
||||
4th %s is the build date */
|
||||
ver_string = g_strdup_printf(_("Version: GnuCash-%s %s (rev %s built %s)"),
|
||||
ver_string = g_strdup_printf(_("Version: GnuCash-%s %s (rev %s, commit date %s)"),
|
||||
VERSION, GNUCASH_SCM, GNUCASH_SCM_REV,
|
||||
GNUCASH_BUILD_DATE);
|
||||
GNUCASH_SCM_REV_DATE);
|
||||
#else
|
||||
/* Dist Tarball */
|
||||
/* Translators: 1st %s is the GnuCash version (eg 2.4.11);
|
||||
2nd %s is the scm (svn/svk/git/bzr) revision number;
|
||||
3rd %s is the build date */
|
||||
ver_string = g_strdup_printf(_("Version: GnuCash-%s (rev %s built %s)"),
|
||||
VERSION, GNUCASH_SCM_REV, GNUCASH_BUILD_DATE);
|
||||
ver_string = g_strdup_printf(_("Version: GnuCash-%s (rev %s, commit date %s)"),
|
||||
VERSION, GNUCASH_SCM_REV, GNUCASH_SCM_REV_DATE);
|
||||
#endif
|
||||
|
||||
version = gtk_label_new(NULL);
|
||||
|
@ -452,9 +452,9 @@ gnc_parse_command_line(int *argc, char ***argv)
|
||||
2nd %s is the scm type (svn/svk/git/bzr);
|
||||
3rd %s is the scm revision number;
|
||||
4th %s is the build date */
|
||||
g_print ( _("%s\nThis copy was built from %s rev %s on %s."),
|
||||
g_print ( _("%s\nThis copy was built from %s rev %s (commit date %s)."),
|
||||
fixed_message, GNUCASH_SCM, GNUCASH_SCM_REV,
|
||||
GNUCASH_BUILD_DATE );
|
||||
GNUCASH_SCM_REV_DATE );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -463,8 +463,8 @@ gnc_parse_command_line(int *argc, char ***argv)
|
||||
/* Translators: 1st %s is a fixed message, which is translated independently;
|
||||
2nd %s is the scm (svn/svk/git/bzr) revision number;
|
||||
3rd %s is the build date */
|
||||
g_print ( _("%s\nThis copy was built from rev %s on %s."),
|
||||
fixed_message, GNUCASH_SCM_REV, GNUCASH_BUILD_DATE );
|
||||
g_print ( _("%s\nThis copy was built from rev %s (commit date %s)."),
|
||||
fixed_message, GNUCASH_SCM_REV, GNUCASH_SCM_REV_DATE );
|
||||
}
|
||||
g_print("\n");
|
||||
g_free (fixed_message);
|
||||
|
@ -57,32 +57,41 @@ SET (GNC_VERSION_H_IN
|
||||
#define GNC_VERSION_H
|
||||
|
||||
#define GNUCASH_SCM \"git\"
|
||||
#define GNUCASH_BUILD_DATE \"@GNUCASH_BUILD_DATE@\"
|
||||
#define GNUCASH_BUILD_YEAR \"@GNUCASH_BUILD_YEAR@\"
|
||||
#include \"gnc-vcs-info.h\"
|
||||
#endif
|
||||
")
|
||||
|
||||
STRING(TIMESTAMP GNUCASH_BUILD_DATE "%Y-%m-%d")
|
||||
STRING(TIMESTAMP GNUCASH_BUILD_YEAR "%Y")
|
||||
|
||||
STRING(CONFIGURE ${GNC_VERSION_H_IN} GNC_VERSION_H_CONTENT)
|
||||
|
||||
FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/gnc-version.h ${GNC_VERSION_H_CONTENT})
|
||||
|
||||
### Create gnc-vcs-info.h
|
||||
# This can only be done when building from a vcs (git/svn/bzr/svk) working directory.
|
||||
# This file is shipped in the distribution tarball, so no need to generate it in that case anyway.
|
||||
# The meta-cmake gymnastics here come from https://cmake.org/pipermail/cmake/2010-July/038015.html
|
||||
|
||||
IF (BUILDING_FROM_VCS)
|
||||
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
|
||||
"/* Autogenerated. Do not change. */\n#define GNUCASH_SCM_REV \"@GNUCASH_SCM_REV@\"\n"
|
||||
)
|
||||
"/* Autogenerated. Do not change. */
|
||||
#define GNUCASH_SCM_REV \"@GNUCASH_SCM_REV@\"
|
||||
#define GNUCASH_SCM_REV_DATE \"@GNUCASH_SCM_REV_DATE@\"
|
||||
#define GNUCASH_SCM_REV_YEAR \"@GNUCASH_SCM_REV_YEAR@\"
|
||||
#define GNUCASH_SCM_REV_Y_M \"@GNUCASH_SCM_REV_Y_M@\"
|
||||
")
|
||||
|
||||
SET(SCM_REV_COMMAND "${CMAKE_SOURCE_DIR}/util/gnc-vcs-info -r")
|
||||
SET(SCM_REV_DATE_COMMAND "${CMAKE_SOURCE_DIR}/util/gnc-vcs-info -d")
|
||||
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
|
||||
"EXECUTE_PROCESS(
|
||||
COMMAND ${SHELL} ${SCM_REV_COMMAND} ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GNUCASH_SCM_REV
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${SHELL} ${SCM_REV_DATE_COMMAND} ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GNUCASH_SCM_REV_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
STRING(SUBSTRING \${GNUCASH_SCM_REV_DATE} 0 4 GNUCASH_SCM_REV_YEAR)
|
||||
STRING(SUBSTRING \${GNUCASH_SCM_REV_DATE} 0 7 GNUCASH_SCM_REV_Y_M)
|
||||
CONFIGURE_FILE(\${SRC} \${DST} @ONLY)
|
||||
")
|
||||
|
||||
@ -101,7 +110,9 @@ ELSE()
|
||||
-P ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
ELSE(BUILDING_FROM_VCS)
|
||||
ADD_CUSTOM_TARGET(gnc-vcs-info DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnc-vcs-info.h)
|
||||
ENDIF(BUILDING_FROM_VCS)
|
||||
### Compile library
|
||||
|
||||
SET(core_utils_noinst_HEADERS
|
||||
|
@ -168,11 +168,10 @@ _gnc-version.h: gnc-vcs-info.h Makefile
|
||||
if [ $$? = 0 ] ; then \
|
||||
echo "#define GNUCASH_SCM \"$$scm_info\"" >> _gnc-version.h ; \
|
||||
fi
|
||||
@echo "#define GNUCASH_BUILD_DATE \"`date +%Y-%m-%d`\"" >> _gnc-version.h
|
||||
@echo "#define GNUCASH_BUILD_YEAR \"`date +%Y`\"" >> _gnc-version.h
|
||||
@echo "#include \"gnc-vcs-info.h\"" >> _gnc-version.h
|
||||
@echo "#endif" >> _gnc-version.h
|
||||
|
||||
if BUILDING_FROM_VCS
|
||||
gnc-vcs-info.h: _gnc-vcs-info.h
|
||||
-if [ ! -f gnc-vcs-info.h ]; then cp _gnc-vcs-info.h gnc-vcs-info.h; fi
|
||||
-cmp -s _gnc-vcs-info.h gnc-vcs-info.h || cp _gnc-vcs-info.h gnc-vcs-info.h
|
||||
@ -180,20 +179,23 @@ gnc-vcs-info.h: _gnc-vcs-info.h
|
||||
|
||||
_gnc-vcs-info.h: Makefile
|
||||
@scm_info=`${top_srcdir}/util/gnc-vcs-info -r ${top_srcdir}` ; \
|
||||
if [ $$? = 0 ] ; then \
|
||||
if [ -z "$$scm_info" ] ; then \
|
||||
info_result=$$? ; \
|
||||
scm_date=`${top_srcdir}/util/gnc-vcs-info -d ${top_srcdir}` ; \
|
||||
date_result=$$? ; \
|
||||
if [ $$info_result != 0 ] || [ $$date_result != 0 ] ; then \
|
||||
echo "You're building from svn/svk/git/bzr... But your build system is broken" ; \
|
||||
echo "Don't do that. Complain to your build-system creator." ; \
|
||||
exit 1 ; \
|
||||
else \
|
||||
if [ -z "$$scm_info" ] || [ -z "$$scm_date" ] ; then \
|
||||
echo "gnc-vcs-info failed. figure out why." ; \
|
||||
echo "can't determine svn/svk/git/bzr revision from ${top_srcdir}." ; \
|
||||
exit 1 ; \
|
||||
fi ; \
|
||||
echo "/* Autogenerated. Do not change. */" > _gnc-vcs-info.h ; \
|
||||
echo "#define GNUCASH_SCM_REV \"$$scm_info\"" >> _gnc-vcs-info.h ; \
|
||||
else \
|
||||
if [ -r $(srcdir)/gnc-vcs-info.h ] ; then \
|
||||
cp $(srcdir)/gnc-vcs-info.h _gnc-vcs-info.h ; \
|
||||
else \
|
||||
echo "You're building from svn/svk/git/bzr... But your build system is broken" ; \
|
||||
echo "Don't do that. Complain to your build-system creator." ; \
|
||||
exit 1 ; \
|
||||
fi ; \
|
||||
echo "#define GNUCASH_SCM_REV_DATE \"$$scm_date\"" >> _gnc-vcs-info.h ; \
|
||||
echo "#define GNUCASH_SCM_REV_YEAR \"$${scm_date%%-*}\"" >> _gnc-vcs-info.h ; \
|
||||
echo "#define GNUCASH_SCM_REV_Y_M \"$${scm_date%-*}\"" >> _gnc-vcs-info.h ; \
|
||||
fi
|
||||
endif
|
||||
|
@ -83,6 +83,12 @@ then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$request" = "date" ]
|
||||
then
|
||||
echo $(svn info "$real_srcdir}" | awk '/Last Changed Date/ { print $4 }')
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# svnversion without options returns the most recent revision in the repo
|
||||
# at the time of the last svn update/checkout even if that revision
|
||||
# didn't hold any changes in the current path. Not very useful as a
|
||||
@ -116,9 +122,10 @@ then
|
||||
[ -n "$GIT_CMD" ] || GIT_CMD=git
|
||||
if [ "$request" = "date" ]
|
||||
then
|
||||
exec "$GIT_CMD" --git-dir "${real_gitdir}" log -1 --format=%ct
|
||||
exec "$GIT_CMD" --git-dir "${real_gitdir}" log -1 --format=%cd --date=format:"%Y-%m-%d"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
githead=`"$GIT_CMD" --git-dir "${real_gitdir}" log -1 --pretty=format:"%h" HEAD 2>/dev/null` # short hash only
|
||||
if test $? = 0 ; then
|
||||
/bin/echo -n $githead
|
||||
@ -143,6 +150,13 @@ then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$request" = "date" ]
|
||||
then
|
||||
# FIXME Don't know how to extract the commit's date from a bzr commit...
|
||||
echo $(date +%Y-%m-%d)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
bzrhead=`(cd "${real_srcdir}"; bzr version-info --custom --template='{revno}\n')`
|
||||
if test $? = 0 ; then
|
||||
echo "$bzrhead";
|
||||
@ -180,6 +194,14 @@ then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$request" = "date" ]
|
||||
then
|
||||
# FIXME Don't know how to extract the commit's date from an svk commit...
|
||||
echo $(date +%Y-%m-%d)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Parse out the revision info, print it out, and then output 0. Just combine
|
||||
# all the revision numbers into a single string by combining them
|
||||
# with periods.
|
||||
|
Loading…
Reference in New Issue
Block a user