diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-03-14 17:23:55 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-03-14 17:23:55 +0200 |
commit | 8ae740bb83da856da2a1fa1dd150eaec2dca62d2 (patch) | |
tree | 1fa3953b7a8d218b72693124bbfd973c299520ac | |
parent | d2cb344c91627aeec6b27b6bea0dfdc3832f3ee9 (diff) | |
download | meson-8ae740bb83da856da2a1fa1dd150eaec2dca62d2.zip meson-8ae740bb83da856da2a1fa1dd150eaec2dca62d2.tar.gz meson-8ae740bb83da856da2a1fa1dd150eaec2dca62d2.tar.bz2 |
Added simple gsettings schema compiler to gnome module.
-rw-r--r-- | modules/gnome.py | 19 | ||||
-rw-r--r-- | test cases/frameworks/7 gnome/com.github.meson.gschema.xml | 12 | ||||
-rw-r--r-- | test cases/frameworks/7 gnome/installed_files.txt | 3 | ||||
-rw-r--r-- | test cases/frameworks/7 gnome/meson.build | 8 | ||||
-rw-r--r-- | test cases/frameworks/7 gnome/schemaprog.c | 47 |
5 files changed, 88 insertions, 1 deletions
diff --git a/modules/gnome.py b/modules/gnome.py index c160f58..a1c5025 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -19,6 +19,7 @@ import build import os import subprocess from coredata import MesonException +import mlog class GnomeModule: @@ -72,5 +73,23 @@ class GnomeModule: typelib_target = build.CustomTarget(typelib_name, state.subdir, kwargs) return [scan_target, typelib_target] + def compile_schemas(self, state, args, kwargs): + if len(args) != 0: + raise MesonException('Compile_schemas does not take positional arguments.') + srcdir = os.path.join(state.build_to_src, state.subdir) + outdir = state.subdir + cmd = ['glib-compile-schemas', '--targetdir', outdir, srcdir] + kwargs['command'] = cmd + kwargs['input'] = [] + kwargs['output'] = 'gschemas.compiled' + if state.subdir == '': + targetname = 'gsettings-compile' + else: + targetname = 'gsettings-compile-' + state.subdir + target_g = build.CustomTarget(targetname, state.subdir, kwargs) + return target_g + def initialize(): + mlog.log('Warning, glib compiled dependencies will not work until this upstream issue is fixed:', + mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=745754')) return GnomeModule() diff --git a/test cases/frameworks/7 gnome/com.github.meson.gschema.xml b/test cases/frameworks/7 gnome/com.github.meson.gschema.xml new file mode 100644 index 0000000..741518d --- /dev/null +++ b/test cases/frameworks/7 gnome/com.github.meson.gschema.xml @@ -0,0 +1,12 @@ +<schemalist> + <schema id="com.github.meson" path="/com/github/meson/" gettext-domain="test"> + + <key name="greeting" type="s"> + <default l10n="messages">"Hello"</default> + <summary>A greeting</summary> + <description> + Sample text to test schema compilation + </description> + </key> + </schema> +</schemalist>
\ No newline at end of file diff --git a/test cases/frameworks/7 gnome/installed_files.txt b/test cases/frameworks/7 gnome/installed_files.txt index beb8cba..019b81a 100644 --- a/test cases/frameworks/7 gnome/installed_files.txt +++ b/test cases/frameworks/7 gnome/installed_files.txt @@ -1 +1,2 @@ -usr/typelibdir/Meson-1.0.typelib
\ No newline at end of file +usr/typelibdir/Meson-1.0.typelib +usr/share/glib-2.0/schemas/com.github.meson.gschema.xml diff --git a/test cases/frameworks/7 gnome/meson.build b/test cases/frameworks/7 gnome/meson.build index 4341b78..957e8ab 100644 --- a/test cases/frameworks/7 gnome/meson.build +++ b/test cases/frameworks/7 gnome/meson.build @@ -29,3 +29,11 @@ install_dir : 'typelibdir', ) test('gobject introspection', girexe) + +gnome.compile_schemas() +install_data('com.github.meson.gschema.xml', +install_dir : 'share/glib-2.0/schemas') + +schemaexe = executable('schemaprog', 'schemaprog.c', +dependencies : gio) +test('schema test', schemaexe) diff --git a/test cases/frameworks/7 gnome/schemaprog.c b/test cases/frameworks/7 gnome/schemaprog.c new file mode 100644 index 0000000..51bfbd9 --- /dev/null +++ b/test cases/frameworks/7 gnome/schemaprog.c @@ -0,0 +1,47 @@ +#include<gio/gio.h> +#include<stdio.h> +#include<string.h> + +int main(int argc, char **argv) { + GSettingsSchemaSource *src; + GSettingsSchema *schema; + GSettings *settings; + GVariant *value; + + GError *error = NULL; + src = g_settings_schema_source_new_from_directory(".", + g_settings_schema_source_get_default(), TRUE, &error); + if(error) { + fprintf(stderr, "Fail: %s\n", error->message); + g_error_free(error); + return 1; + } + + schema = g_settings_schema_source_lookup(src, "com.github.meson", FALSE); + if(!schema) { + fprintf(stderr, "Could not get schema from source.\n"); + return 2; + } + + settings = g_settings_new_full(schema, NULL, NULL); + if(!settings) { + fprintf(stderr, "Could not get settings object.\n"); + return 3; + } + + value = g_settings_get_value(settings, "greeting"); + if(!value) { + fprintf(stderr, "Could not get value from settings.\n"); + return 4; + } + + if(strcmp("Hello", g_variant_get_string(value, NULL)) != 0) { + fprintf(stderr, "Value of setting is incorrect.\n"); + return 5; + } + g_variant_unref(value); + g_object_unref(settings); + g_settings_schema_unref(schema); + g_settings_schema_source_unref(src); + return 0; +} |