[epiphany/gnome-3-26] Compile gsettings schemas in build directory



commit 965e04d4a2ca0836e6b2d5588118bc401d6dacde
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Fri Mar 2 20:46:43 2018 -0600

    Compile gsettings schemas in build directory
    
    This allows us to run the tests in situations where Epiphany is not
    installed on the host system, e.g. when running under BuildStream.
    
    As a bonus, we'll point Epiphany here as well when built in developer
    mode, so that it can be run from the build directory when uninstalled.
    This is needed to facilitate easy build/test/run inside BuildStream.

 data/meson.build  |   26 ++++++++++++++-
 src/ephy-main.c   |    4 ++
 src/meson.build   |    1 +
 tests/meson.build |   92 +++++++++++++++++++++++++++++++++++++++++++----------
 4 files changed, 104 insertions(+), 19 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index fc9e926..30729f1 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -19,14 +19,23 @@ i18n.merge_file('appdata-file',
   po_dir: '../po'
 )
 
+# We need three custom_target() calls because Meson doesn't have very
+# good support for GSettings yet. First, generate our GSettings enums
+# in the build directory. Then, copy the gschema into the build
+# directory to ensure it is in the same place as the enums file. Then
+# we can run glib-compile-schemas on it. We have to compile schemas in
+# the build directory to ensure that our tests don't fail if run on a
+# system where epiphany is not already installed. epiphany will also
+# look for schemas here if built in developer mode.
+#
 # https://github.com/mesonbuild/meson/issues/1687
-custom_target('gsettings-enums',
+generate_enums = custom_target('gsettings-enums',
   input: '../lib/ephy-prefs.h',
   output: 'org.gnome.Epiphany.enums.xml',
   install: true,
   install_dir: join_paths(datadir, 'glib-2.0', 'schemas'),
   capture: true,
-  command: ['glib-mkenums',
+  command: [find_program('glib-mkenums'),
     '--comments', '<!-- @comment@ -->',
     '--fhead', '<schemalist>',
     '--vhead', '  <@type@ id="org.gnome.Epiphany.@EnumName@">',
@@ -36,6 +45,19 @@ custom_target('gsettings-enums',
     '@INPUT@'
   ]
 )
+copy_gschema = custom_target('copy-gschema-to-builddir',
+  input: 'org.gnome.epiphany.gschema.xml',
+  output: 'renamed-hack.gschema.xml',
+  command: ['cp', '@INPUT@', '@OUTPUT@']
+)
+compile_schemas = custom_target('glib-compile-schemas',
+  output: 'gschemas.compiled',
+  install: false,
+  command: [find_program('glib-compile-schemas'),
+    meson.current_build_dir()
+  ],
+  depends: [generate_enums, copy_gschema]
+)
 install_data('org.gnome.epiphany.gschema.xml',
   install_dir: join_paths(datadir, 'glib-2.0', 'schemas')
 )
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 9c4687e..9877b49 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -196,6 +196,10 @@ main (int   argc,
   EphyFileHelpersFlags flags;
   GDesktopAppInfo *desktop_info = NULL;
 
+#if DEVELOPER_MODE
+  g_setenv ("GSETTINGS_SCHEMA_DIR", BUILD_ROOT "/data", FALSE);
+#endif
+
   /* Initialize the i18n stuff */
   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
diff --git a/src/meson.build b/src/meson.build
index 8c9e97e..8f51755 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -42,6 +42,7 @@ libephymain_sources = [
   'prefs-dialog.c',
   'synced-tabs-dialog.c',
   'window-commands.c',
+  compile_schemas,
   enums
 ]
 
diff --git a/tests/meson.build b/tests/meson.build
index 5526d2c..8f5800a 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,3 +1,10 @@
+envs = [
+  'G_TEST_SRCDIR=' + meson.current_source_dir(),
+  'G_TEST_BUILDDIR=' + meson.current_build_dir(),
+  'GSETTINGS_SCHEMA_DIR=' + join_paths(meson.build_root(), 'data'),
+  'GSETTINGS_BACKEND=memory',
+]
+
 if get_option('unit_tests')
   # FIXME: The tests that need ephy-test-utils are all disabled....
   #
@@ -14,65 +21,95 @@ if get_option('unit_tests')
     'ephy-completion-model-test.c',
     dependencies: ephymain_dep
   )
-  test('Completion model test', completion_model_test)
+  test('Completion model test',
+       completion_model_test,
+       env: envs
+  )
 
   # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=778153
   # download_test = executable('test-ephy-download',
   #   'ephy-download-test.c',
   #   dependencies: ephymain_dep
   # )
-  # test('Download test', download_test)
+  # test('Download test',
+  #      download_test,
+  #      env: envs
+  # )
 
   # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=773448
   # embed_shell_test = executable('test-ephy-embed-shell',
   #   'ephy-embed-shell-test.c',
   #   dependencies: ephymain_dep
   # )
-  # test('Embed shell test', embed_shell_test)
+  # test('Embed shell test',
+  #      embed_shell_test,
+  #      env: envs
+  # )
 
   embed_utils_test = executable('test-ephy-embed-utils',
     'ephy-embed-utils-test.c',
     dependencies: ephymain_dep
   )
-  test('Embed utils test', embed_utils_test)
+  test('Embed utils test',
+       embed_utils_test,
+       env: envs
+  )
 
   encodings_test = executable('test-ephy-encodings',
     'ephy-encodings-test.c',
     dependencies: ephymain_dep
   )
-  test('Encodings test', encodings_test)
+  test('Encodings test',
+       encodings_test,
+       env: envs
+  )
 
   # https://bugzilla.gnome.org/show_bug.cgi?id=786001
   # file_helpers_test = executable('test-ephy-file-helpers',
   #   'ephy-file-helpers-test.c',
   #   dependencies: ephymain_dep
   # )
-  # test('File helpers test', file_helpers_test)
+  # test('File helpers test',
+  #      file_helpers_test,
+  #      env: envs
+  # )
 
   history_test = executable('test-ephy-history',
     'ephy-history-test.c',
     dependencies: ephymain_dep
   )
-  test('History test', history_test)
+  test('History test',
+       history_test,
+       env: envs
+  )
 
   location_entry_test = executable('test-location-entry',
     'ephy-location-entry-test.c',
     dependencies: ephymain_dep
   )
-  test('Location entry test', location_entry_test)
+  test('Location entry test',
+       location_entry_test,
+       env: envs
+  )
 
   migration_test = executable('test-ephy-migration',
     'ephy-migration-test.c',
     dependencies: ephymain_dep
   )
-  test('Migration test', migration_test)
+  test('Migration test',
+       migration_test,
+       env: envs
+  )
 
   # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=707220
   # session_test = executable('test-ephy-session',
   #   'ephy-session-test.c',
   #   dependencies: ephytestutils_dep
   # )
-  # test('Session test', session_test)
+  # test('Session test',
+  #      session_test,
+  #      env: envs
+  # )
 
   # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=693369
   # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=695703
@@ -81,44 +118,65 @@ if get_option('unit_tests')
   #   'ephy-shell-test.c',
   #   dependencies: ephytestutils_dep
   # )
-  # test('Shell test', shell_test)
+  # test('Shell test',
+  #      shell_test,
+  #      env: envs
+  # )
 
   # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=762753
   # snapshot_service_test = executable('test-snapshot-service',
   #   'ephy-snapshot-service-test.c',
   #   dependencies: ephymain_dep
   # )
-  # test('Snapshot service test', snapshot_service_test)
+  # test('Snapshot service test',
+  #      snapshot_service_test,
+  #      env: envs
+  # )
 
   sqlite_test = executable('test-ephy-sqlite',
     'ephy-sqlite-test.c',
     dependencies: ephymain_dep
   )
-  test('SQLite test', sqlite_test)
+  test('SQLite test',
+       sqlite_test,
+       env: envs
+  )
 
   string_test = executable('test-ephy-string',
     'ephy-string-test.c',
     dependencies: ephymain_dep
   )
-  test('String test', string_test)
+  test('String test',
+       string_test,
+       env: envs
+  )
 
   uri_helpers_test = executable('test-ephy-uri-helpers',
     'ephy-uri-helpers-test.c',
     dependencies: ephymain_dep
   )
-  test('URI helpers test', uri_helpers_test)
+  test('URI helpers test',
+       uri_helpers_test,
+       env: envs,
+  )
 
   # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=759256
   # web_app_utils_test = executable('test-ephy-web-app-utils',
   #   'ephy-web-app-utils-test.c',
   #   dependencies: ephymain_dep
   # )
-  # test('Web app utils test', web_app_utils_test)
+  # test('Web app utils test',
+  #      web_app_utils_test,
+  #      env: envs
+  # )
 
   # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=780280
   # web_view_test = executable('test-ephy-web-view',
   #   'ephy-web-view-test.c',
   #   dependencies: ephymain_dep
   # )
-  # test('Web view test', web_view_test)
+  # test('Web view test',
+  #      web_view_test,
+  #      env: envs
+  # )
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]