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.
This commit is contained in:
Geert Janssens 2021-09-28 11:57:53 +02:00
parent a84891a43c
commit dee4f5e511
4 changed files with 22 additions and 6 deletions

View File

@ -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)

View File

@ -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})

View File

@ -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

View File

@ -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