From 175a4615adf9c4c1a13f957cf0347c35e464b7be Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Mon, 10 Jun 2024 22:50:12 +0800 Subject: [PATCH] build: Compile schemas locally for use in build tests So they don't need to be installed system-wide before build testing can work. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3368 (cherry picked from commit b684b5cf0563e29ade366fc2f1a5ad72368d58d7) --- data/meson.build | 17 +++++++++++++++-- src/tests/clutter/conform/meson.build | 1 + src/tests/cogl/conform/meson.build | 1 + src/tests/cogl/unit/meson.build | 1 + src/tests/meson.build | 4 +++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/data/meson.build b/data/meson.build index e97df81e7..12c4428e8 100644 --- a/data/meson.build +++ b/data/meson.build @@ -27,20 +27,33 @@ gschema_config.set('XWAYLAND_GRAB_DEFAULT_ACCESS_RULES', xwayland_grab_default_access_rules) schemadir = datadir / 'glib-2.0' / 'schemas' -configure_file( +schema_xmls = [] +schema_xmls += configure_file( input: 'org.gnome.mutter.gschema.xml.in', output: 'org.gnome.mutter.gschema.xml', configuration: gschema_config, install_dir: schemadir ) -configure_file( +schema_xmls += configure_file( input: 'org.gnome.mutter.wayland.gschema.xml.in', output: 'org.gnome.mutter.wayland.gschema.xml', configuration: gschema_config, install_dir: schemadir ) +locally_compiled_schemas_dir = meson.current_build_dir() + +locally_compiled_schemas = custom_target( + output: 'gschemas.compiled', + depend_files: schema_xmls, + command: ['glib-compile-schemas', locally_compiled_schemas_dir], +) + +locally_compiled_schemas_dep = declare_dependency( + sources: locally_compiled_schemas +) + install_data(['mutter-schemas.convert'], install_dir: datadir / 'GConf/gsettings', ) diff --git a/src/tests/clutter/conform/meson.build b/src/tests/clutter/conform/meson.build index 92430c135..5263c912e 100644 --- a/src/tests/clutter/conform/meson.build +++ b/src/tests/clutter/conform/meson.build @@ -56,6 +56,7 @@ test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) test_env.set('G_ENABLE_DIAGNOSTIC', '0') test_env.set('CLUTTER_ENABLE_DIAGNOSTIC', '0') +test_env.set('GSETTINGS_SCHEMA_DIR', locally_compiled_schemas_dir) foreach test : clutter_conform_tests test_executable = executable('@0@'.format(test), diff --git a/src/tests/cogl/conform/meson.build b/src/tests/cogl/conform/meson.build index 2614be56e..f60fbf16a 100644 --- a/src/tests/cogl/conform/meson.build +++ b/src/tests/cogl/conform/meson.build @@ -66,6 +66,7 @@ test_env = environment() test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) test_env.set('G_ENABLE_DIAGNOSTIC', '0') +test_env.set('GSETTINGS_SCHEMA_DIR', locally_compiled_schemas_dir) cogl_test_variants = [ 'gl3', 'gles2' ] diff --git a/src/tests/cogl/unit/meson.build b/src/tests/cogl/unit/meson.build index f46a3df42..ff763cbab 100644 --- a/src/tests/cogl/unit/meson.build +++ b/src/tests/cogl/unit/meson.build @@ -14,6 +14,7 @@ test_env = environment() test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) test_env.set('G_ENABLE_DIAGNOSTIC', '0') +test_env.set('GSETTINGS_SCHEMA_DIR', locally_compiled_schemas_dir) foreach unit_test: cogl_unit_tests test_name = 'cogl-' + unit_test[0] diff --git a/src/tests/meson.build b/src/tests/meson.build index 18314c937..b98cfd49c 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -42,6 +42,7 @@ tests_deps = [ libmutter_clutter_dep, libmutter_dep, mutter_deps, + locally_compiled_schemas_dep, ] libmutter_test = shared_library(libmutter_test_name, @@ -144,7 +145,8 @@ test_env_variables = { 'G_TEST_BUILDDIR': mutter_builddir, 'XDG_CONFIG_HOME': mutter_builddir / '.config', 'MUTTER_TEST_PLUGIN_PATH': '@0@'.format(default_plugin.full_path()), - 'GSETTINGS_SCHEMA_DIR': mutter_builddir / 'src' / 'tests', + 'GSETTINGS_SCHEMA_DIR': ':'.join([mutter_builddir / 'src' / 'tests', + locally_compiled_schemas_dir]), } foreach name, value: test_env_variables