From dd1812892747e37bacff1bb428c8bda4a98fc2c2 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 17 Feb 2020 14:13:18 +0100 Subject: [PATCH] Tweak appdata file generation some more Should make it easier for packagers to provide their own releases data. --- CMakeLists.txt | 8 ++++- cmake/CMakeLists.txt | 4 +-- cmake/configure-appdata.cmake | 33 +++++++++++++++++++ ....cmake => configure-gnucash-desktop.cmake} | 8 ++--- gnucash/gnome/CMakeLists.txt | 10 +++--- gnucash/gnome/gnucash.appdata.xml.in.in | 2 +- gnucash/gnome/gnucash.releases.xml | 1 + 7 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 cmake/configure-appdata.cmake rename cmake/{insert-vcs-data.cmake => configure-gnucash-desktop.cmake} (75%) create mode 100644 gnucash/gnome/gnucash.releases.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index fe7a38b8b7..e20d0e2d7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,9 +62,15 @@ option (DISABLE_DEPRECATED_GNOME "don't use deprecated gnome functions" OFF) # Use gsettings-desktop-schemas for a better integration with GNOME set(COMPILE_GSCHEMAS ON CACHE BOOL "Compile the GSettings schema") -set(GNUCASH_BUILD_ID "" CACHE STRING "Overrides the GnuCash build identification (Build ID) which defaults to a description of the vcs commit from which gnucash is built. Distributions may want to insert a package management based version number instead") # GENERATE_SWIG_WRAPPERS - Controls whether to generate the swig wrappers for guile and python. If not set the wrappers will only be generated when building from a git worktree, commented out here, but will be evaluated later on in this file +# Support for downstream packagers +set(GNUCASH_BUILD_ID "" CACHE STRING "Overrides the GnuCash build identification (Build ID) which defaults to a description of the vcs commit from which gnucash is built. Distributions may want to insert a package management based version number instead") +# In addition to the GNUCASH_BUILD_ID environment variable, packagers can overwrite +# gnucash/gnome/gnucash.releases.xml with (package) release details to be included +# in the appdata file. It should follow appdata node conventions. + + # Check that all of the absolute install paths are inside # ${CMAKE_INSTALL_PREFIX}. If they're not, disable binreloc as it # won't be able to find paths that aren't relative to the location of diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index a72d38f803..c8aa8da9f6 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -9,6 +9,6 @@ endif() set_dist_list(cmake_DIST CMakeLists.txt README_CMAKE.txt cmake_uninstall.cmake.in - insert-vcs-data.cmake configure-manpage.cmake git2version-info.cmake - version-info2env.cmake + configure-appdata.cmake configure-gnucash-desktop.cmake configure-manpage.cmake + git2version-info.cmake version-info2env.cmake ) diff --git a/cmake/configure-appdata.cmake b/cmake/configure-appdata.cmake new file mode 100644 index 0000000000..c5ddeacdc7 --- /dev/null +++ b/cmake/configure-appdata.cmake @@ -0,0 +1,33 @@ +# Command to configure the gnucash appdata file +# These commands are stored in a separate cmake file as they have to be +# rerun depending on build conditions, not depending on cmake conditions +# (such as did the version string change or not) +# +# Logic is as follows: +# - the source file /releases.xml will be +# configured with version information found in gnc-vcs-info.h +# and an optional GNUCASH_BUILD_ID variable +# - the result of this configuration will be applied to the +# appdata input file +# The default releases.xml file will just be a single release line in +# appdata node format. Handling this in a separate file allows +# packagers to override it to supply their own (package) release details. +# +# The following environment variables are used and should be properly set +# by the calling code: +# - SRC_DIR (top level source code directory) +# - SRC (full path to gnucash.appdata.xml.in) +# - DST (full path to destination for gnucash.appdata.xml) +# - REL_FILE (path to file containg (packaging) release info) +# - VCS_INFO_FILE (full path to gnc-vcs-info.h - can be in source tree (release builds) or build tree (git builds)) +# - GNUCASH_BUILD_ID (optional, extra version information supplied by packagers) + +include (${SRC_DIR}/cmake/version-info2env.cmake) +versioninfo2env (${VCS_INFO_FILE}) +if (GNUCASH_BUILD_ID AND NOT "${GNUCASH_BUILD_ID}" STREQUAL "${GNC_VCS_REV}") + set (GNC_VCS_REV "${GNC_VCS_REV} (${GNUCASH_BUILD_ID})") +endif() + +file (READ ${REL_FILE} REL_INFO_IN) +string(CONFIGURE "${REL_INFO_IN}" REL_INFO) +configure_file(${SRC} ${DST}) diff --git a/cmake/insert-vcs-data.cmake b/cmake/configure-gnucash-desktop.cmake similarity index 75% rename from cmake/insert-vcs-data.cmake rename to cmake/configure-gnucash-desktop.cmake index bcd95ffd38..d55d05b60b 100644 --- a/cmake/insert-vcs-data.cmake +++ b/cmake/configure-gnucash-desktop.cmake @@ -1,4 +1,4 @@ -# Command to configure the gnucash appdata file +# Command to configure the gnucash desktop file # These commands are stored in a separate cmake file as they have to be # rerun depending on build conditions, not depending on cmake conditions # (such as did the version string change or not) @@ -6,10 +6,10 @@ # The following environment variables are used and should be properly set # by the calling code: # - SRC_DIR (top level source code directory) -# - SRC (full path to gnc-vcs-info.h.in) -# - DST (full path to destination for gnc-vcs-info.h) +# - SRC (full path to gnucash.desktop.in) +# - DST (full path to destination for gnucash.desktop) # - VCS_INFO_FILE (full path to gnc-vcs-info.h - can be in source tree (release builds) or build tree (git builds)) -# - DATADIR_BUILD (path to applicication data directory, typically {CMAKE_BINARY_DIR}/share) +# - DATADIR_BUILD (path to application data directory, typically {CMAKE_BINARY_DIR}/share) include (${SRC_DIR}/cmake/version-info2env.cmake) versioninfo2env (${VCS_INFO_FILE}) diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt index 2dee010354..fcec8b8548 100644 --- a/gnucash/gnome/CMakeLists.txt +++ b/gnucash/gnome/CMakeLists.txt @@ -183,14 +183,14 @@ endif() add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml - DEPENDS ${GNC_APPDATA_IN} ${VCS_INFO_FILE} + DEPENDS ${GNC_APPDATA_IN} ${VCS_INFO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.releases.xml COMMAND ${CMAKE_COMMAND} -D SRC=${GNC_APPDATA_IN} -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml -D VCS_INFO_FILE=${VCS_INFO_FILE} -D GNUCASH_BUILD_ID=${GNUCASH_BUILD_ID} - -D PROJECT_VERSION=${PROJECT_VERSION} -D SRC_DIR=${CMAKE_SOURCE_DIR} - -P ${CMAKE_SOURCE_DIR}/cmake/insert-vcs-data.cmake) + -D REL_FILE=${CMAKE_CURRENT_SOURCE_DIR}/gnucash.releases.xml + -P ${CMAKE_SOURCE_DIR}/cmake/configure-appdata.cmake) add_custom_target(gnucash-appdata ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml) @@ -234,7 +234,7 @@ add_custom_command ( -D VCS_INFO_FILE=${VCS_INFO_FILE} -D PROJECT_VERSION=${PROJECT_VERSION} -D SRC_DIR=${CMAKE_SOURCE_DIR} - -P ${CMAKE_SOURCE_DIR}/cmake/insert-vcs-data.cmake) + -P ${CMAKE_SOURCE_DIR}/cmake/configure-gnucash-desktop.cmake) add_custom_target(gnucash-desktop ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop) @@ -242,5 +242,5 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop DESTINATION ${CMAKE_I set_dist_list(gnome_DIST CMakeLists.txt gnome.i gnucash.appdata.xml.in.in gnucash.desktop.in.in - ${gnc_gnome_noinst_HEADERS} ${gnc_gnome_SOURCES}) + gnucash.releases.xml ${gnc_gnome_noinst_HEADERS} ${gnc_gnome_SOURCES}) dist_add_generated(${BUILDING_FROM_VCS} gnucash.appdata.xml.in gnucash.desktop.in) diff --git a/gnucash/gnome/gnucash.appdata.xml.in.in b/gnucash/gnome/gnucash.appdata.xml.in.in index 008c4f8cec..cd4da35994 100644 --- a/gnucash/gnome/gnucash.appdata.xml.in.in +++ b/gnucash/gnome/gnucash.appdata.xml.in.in @@ -35,7 +35,7 @@ CC0-1.0 GPL-2.0+ - +${REL_INFO} diff --git a/gnucash/gnome/gnucash.releases.xml b/gnucash/gnome/gnucash.releases.xml new file mode 100644 index 0000000000..d196d79333 --- /dev/null +++ b/gnucash/gnome/gnucash.releases.xml @@ -0,0 +1 @@ +