From b684b5cf0563e29ade366fc2f1a5ad72368d58d7 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 Part-of: --- 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 91ea29c84..019c1f223 100644 --- a/src/tests/clutter/conform/meson.build +++ b/src/tests/clutter/conform/meson.build @@ -55,6 +55,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 030715017..1e1956a4b 100644 --- a/src/tests/cogl/conform/meson.build +++ b/src/tests/cogl/conform/meson.build @@ -65,6 +65,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 937335d90..7e224e817 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 7388943c5..09f6e8a05 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