gnucash maint: Rethink how gsettings migration file is constructed

Geert Janssens gjanssens at code.gnucash.org
Tue Sep 28 06:07:55 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/dee4f5e5 (commit)
	from  https://github.com/Gnucash/gnucash/commit/a84891a4 (commit)



commit dee4f5e511011ed3b7d52553071943d60e9398e2
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Tue Sep 28 11:57:53 2021 +0200

    Rethink how gsettings migration file is constructed
    
    The order in which cmake processes subdirectories in gnucash
    matters because that also defines the order in which install
    rules will be executed.
    We have an install rule to compile the install gschema files.
    That rule has to be run after all gschema files are installed.
    Considering how our code is organized that means directory
    gnucash/gschema should be processed after gnucash/import-export.
    That requirement was incompatible with how migratable-prefs.xml
    was generated (it required the exact opposite processing order).
    This conflict causes gnucash to crash on startup because not
    all gschema files are compiled as they should.
    The changes in this commit should fix this.

diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt
index 2973dcc48..01d3c27ff 100644
--- a/gnucash/CMakeLists.txt
+++ b/gnucash/CMakeLists.txt
@@ -4,11 +4,11 @@
 set(SCHEMADIR_BUILD ${DATADIR_BUILD}/glib-2.0/schemas)
 file(MAKE_DIRECTORY ${SCHEMADIR_BUILD})
 unset(gschema_depends CACHE)
+unset(gschema_migration_files CACHE)
 # The subdirectories
 add_subdirectory (gnome)
 add_subdirectory (gnome-utils)
 add_subdirectory (gnome-search)
-add_subdirectory (gschemas)
 add_subdirectory (gtkbuilder)
 add_subdirectory (html)
 add_subdirectory (import-export)
@@ -16,6 +16,9 @@ add_subdirectory (python)
 add_subdirectory (register)
 add_subdirectory (report)
 add_subdirectory (ui)
+# gschemas directory goes last to ensure all schema files are installed
+# before glib-compile-schemas is called
+add_subdirectory (gschemas)
 
 add_definitions (-DHAVE_CONFIG_H)
 
diff --git a/gnucash/gschemas/CMakeLists.txt b/gnucash/gschemas/CMakeLists.txt
index 57dcf69f7..63da362f4 100644
--- a/gnucash/gschemas/CMakeLists.txt
+++ b/gnucash/gschemas/CMakeLists.txt
@@ -22,8 +22,19 @@ set(gschema_SOURCES
 
 add_gschema_targets("${gschema_SOURCES}")
 
+set(local_migration_files ${gschema_migration_files})
+list(APPEND local_migration_files ${CMAKE_CURRENT_SOURCE_DIR}/migratable-prefs.xml)
+set(gschema_migration_files ${local_migration_files} CACHE INTERNAL "gschema migration files")
+
 # Provide gnucash runtime with a list of migratable preferences
-configure_file(migratable-prefs.xml ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml COPYONLY)
+add_custom_command(
+    OUTPUT ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml
+    COMMAND ${CMAKE_COMMAND} -E cat ${gschema_migration_files} > ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml
+    DEPENDS ${gschema_migration_files}
+)
+
+add_custom_target(migratable-prefs ALL DEPENDS ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml)
+
 install(FILES ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml
         DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
 
diff --git a/gnucash/import-export/aqb/gschemas/CMakeLists.txt b/gnucash/import-export/aqb/gschemas/CMakeLists.txt
index 0265a2237..db4016a3b 100644
--- a/gnucash/import-export/aqb/gschemas/CMakeLists.txt
+++ b/gnucash/import-export/aqb/gschemas/CMakeLists.txt
@@ -4,8 +4,9 @@ if (WITH_AQBANKING)
 
   add_gschema_targets("${aqb_GSCHEMA}")
 
-  file(READ migratable-prefs.xml migratable-prefs)
-  file(APPEND ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml ${migratable-prefs})
+  set(local_migration_files ${gschema_migration_files})
+  list(APPEND local_migration_files ${CMAKE_CURRENT_SOURCE_DIR}/migratable-prefs.xml)
+  set(gschema_migration_files ${local_migration_files} CACHE INTERNAL "gschema migration files")
 endif()
 
 set_dist_list(aqbanking_gschema_DIST
diff --git a/gnucash/import-export/ofx/gschemas/CMakeLists.txt b/gnucash/import-export/ofx/gschemas/CMakeLists.txt
index 3dea7b61b..30626519c 100644
--- a/gnucash/import-export/ofx/gschemas/CMakeLists.txt
+++ b/gnucash/import-export/ofx/gschemas/CMakeLists.txt
@@ -4,8 +4,9 @@ if (WITH_OFX)
 
   add_gschema_targets("${ofx_GSCHEMA}")
 
-  file(READ migratable-prefs.xml migratable-prefs)
-  file(APPEND ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml ${migratable-prefs})
+  set(local_migration_files ${gschema_migration_files})
+  list(APPEND local_migration_files ${CMAKE_CURRENT_SOURCE_DIR}/migratable-prefs.xml)
+  set(gschema_migration_files ${local_migration_files} CACHE INTERNAL "gschema migration files")
 endif()
 
 set_dist_list(ofx_gschema_DIST



Summary of changes:
 gnucash/CMakeLists.txt                            |  5 ++++-
 gnucash/gschemas/CMakeLists.txt                   | 13 ++++++++++++-
 gnucash/import-export/aqb/gschemas/CMakeLists.txt |  5 +++--
 gnucash/import-export/ofx/gschemas/CMakeLists.txt |  5 +++--
 4 files changed, 22 insertions(+), 6 deletions(-)



More information about the gnucash-changes mailing list