[gedit/tchaik/174-validate-gschema: 35/35] build: Validate gschema files



commit 2bd55e4851b81b45e15956a331679bbcbd389af2
Author: Martin Blanchard <tchaik gmx com>
Date:   Mon Sep 16 23:28:58 2019 +0200

    build: Validate gschema files
    
    https://gitlab.gnome.org/GNOME/gedit/issues/174

 data/meson.build                  | 45 ++++++++++++++++++++++++++++-----------
 plugins/externaltools/meson.build | 16 ++++++++++++--
 plugins/filebrowser/meson.build   | 16 ++++++++++++--
 plugins/pythonconsole/meson.build | 16 ++++++++++++--
 plugins/spell/meson.build         | 16 ++++++++++++--
 plugins/time/meson.build          | 16 ++++++++++++--
 6 files changed, 103 insertions(+), 22 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index ecf473a29..bef694c4f 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -23,12 +23,15 @@ appdata_file = i18n.merge_file(
 
 appstream_util = find_program('appstream-util', required: false)
 if appstream_util.found()
-test(
-    'validate-appdata', appstream_util,
+  test(
+    'validate-appdata',
+    appstream_util,
     args: [
-        'validate-relax', '--nonet', appdata_file.full_path()
+      'validate-relax',
+      '--nonet',
+      appdata_file.full_path()
     ]
-)
+  )
 endif
 
 
@@ -57,13 +60,13 @@ desktop_file = i18n.merge_file(
 
 desktop_file_validate = find_program('desktop-file-validate', required: false)
 if desktop_file_validate.found()
-test(
+  test(
     'validate-desktop',
     desktop_file_validate,
     args: [
-        desktop_file.full_path()
+      desktop_file.full_path(),
     ]
-)
+  )
 endif
 
 quoted_plugins = []
@@ -73,20 +76,38 @@ foreach plugin_name:active_plugins
   ]
 endforeach
 
-gschema_xml = configuration_data()
-gschema_xml.set('GETTEXT_PACKAGE', package_name)
-gschema_xml.set('ACTIVE_PLUGINS', ', '.join(quoted_plugins))
+gschema_in = configuration_data()
+gschema_in.set('GETTEXT_PACKAGE', package_name)
+gschema_in.set('ACTIVE_PLUGINS', ', '.join(quoted_plugins))
 
-configure_file(
+gschema_file = configure_file(
   input: 'org.gnome.gedit.gschema.xml.in',
   output: 'org.gnome.gedit.gschema.xml',
-  configuration: gschema_xml,
+  configuration: gschema_in,
   install_dir: join_paths(
     glibdir,
     'schemas',
   )
 )
 
+gschema_dtd = join_paths(
+  gio_dep.get_pkgconfig_variable('schemasdir'),
+  'gschema.dtd',
+)
+
+xmllint = find_program('xmllint', required: false)
+if xmllint.found()
+  test(
+    'validate-gschema',
+    xmllint,
+    args: [
+      '--noout',
+      '--dtdvalid', gschema_dtd,
+      gschema_file,
+    ]
+  )
+endif
+
 service_in = configuration_data()
 service_in.set('bindir', bindir)
 
diff --git a/plugins/externaltools/meson.build b/plugins/externaltools/meson.build
index 75a23a144..9718b9188 100644
--- a/plugins/externaltools/meson.build
+++ b/plugins/externaltools/meson.build
@@ -2,16 +2,28 @@ subdir('scripts')
 subdir('tools')
 subdir('data')
 
-configure_file(
+externaltools_gschema_file = configure_file(
   input: 'org.gnome.gedit.plugins.externaltools.gschema.xml.in',
   output: 'org.gnome.gedit.plugins.externaltools.gschema.xml',
-  configuration: gschema_xml,
+  configuration: gschema_in,
   install_dir: join_paths(
     glibdir,
     'schemas',
   )
 )
 
+if xmllint.found()
+  test(
+    'validate-externaltools-gschema',
+    xmllint,
+    args: [
+      '--noout',
+      '--dtdvalid', gschema_dtd,
+      externaltools_gschema_file,
+    ]
+  )
+endif
+
 custom_target(
   'externaltools.plugin',
   input: 'externaltools.plugin.desktop.in',
diff --git a/plugins/filebrowser/meson.build b/plugins/filebrowser/meson.build
index 7bae8f4ac..fe5a5767e 100644
--- a/plugins/filebrowser/meson.build
+++ b/plugins/filebrowser/meson.build
@@ -101,16 +101,28 @@ custom_target(
   )
 )
 
-configure_file(
+filebrowser_gschema_file = configure_file(
   input: 'org.gnome.gedit.plugins.filebrowser.gschema.xml.in',
   output: 'org.gnome.gedit.plugins.filebrowser.gschema.xml',
-  configuration: gschema_xml,
+  configuration: gschema_in,
   install_dir: join_paths(
     glibdir,
     'schemas',
   )
 )
 
+if xmllint.found()
+  test(
+    'validate-filebrowser-gschema',
+    xmllint,
+    args: [
+      '--noout',
+      '--dtdvalid', gschema_dtd,
+      filebrowser_gschema_file,
+    ]
+  )
+endif
+
 custom_target(
   'filebrowser.plugin',
   input: 'filebrowser.plugin.desktop.in',
diff --git a/plugins/pythonconsole/meson.build b/plugins/pythonconsole/meson.build
index 55b0af282..786167537 100644
--- a/plugins/pythonconsole/meson.build
+++ b/plugins/pythonconsole/meson.build
@@ -1,15 +1,27 @@
 subdir('pythonconsole')
 
-configure_file(
+pythonconsole_gschema_file = configure_file(
   input: 'org.gnome.gedit.plugins.pythonconsole.gschema.xml.in',
   output: 'org.gnome.gedit.plugins.pythonconsole.gschema.xml',
-  configuration: gschema_xml,
+  configuration: gschema_in,
   install_dir: join_paths(
     glibdir,
     'schemas',
   )
 )
 
+if xmllint.found()
+  test(
+    'validate-pythonconsole-gschema',
+    xmllint,
+    args: [
+      '--noout',
+      '--dtdvalid', gschema_dtd,
+      pythonconsole_gschema_file,
+    ]
+  )
+endif
+
 custom_target(
   'pythonconsole.plugin',
   input: 'pythonconsole.plugin.desktop.in',
diff --git a/plugins/spell/meson.build b/plugins/spell/meson.build
index 4832da8e0..f6fe6255b 100644
--- a/plugins/spell/meson.build
+++ b/plugins/spell/meson.build
@@ -28,16 +28,28 @@ libspell_sha = shared_module(
   name_suffix: module_suffix,
 )
 
-configure_file(
+spell_gschema_file = configure_file(
   input: 'org.gnome.gedit.plugins.spell.gschema.xml.in',
   output: 'org.gnome.gedit.plugins.spell.gschema.xml',
-  configuration: gschema_xml,
+  configuration: gschema_in,
   install_dir: join_paths(
     glibdir,
     'schemas',
   )
 )
 
+if xmllint.found()
+  test(
+    'validate-spell-gschema',
+    xmllint,
+    args: [
+      '--noout',
+      '--dtdvalid', gschema_dtd,
+      spell_gschema_file,
+    ]
+  )
+endif
+
 custom_target(
   'spell.plugin',
   input: 'spell.plugin.desktop.in',
diff --git a/plugins/time/meson.build b/plugins/time/meson.build
index 25e80e580..657ac694c 100644
--- a/plugins/time/meson.build
+++ b/plugins/time/meson.build
@@ -42,16 +42,28 @@ libtime_sha = shared_module(
   name_suffix: module_suffix,
 )
 
-configure_file(
+time_gschema_file = configure_file(
   input: 'org.gnome.gedit.plugins.time.gschema.xml.in',
   output: 'org.gnome.gedit.plugins.time.gschema.xml',
-  configuration: gschema_xml,
+  configuration: gschema_in,
   install_dir: join_paths(
     glibdir,
     'schemas',
   )
 )
 
+if xmllint.found()
+  test(
+    'validate-time-gschema',
+    xmllint,
+    args: [
+      '--noout',
+      '--dtdvalid', gschema_dtd,
+      time_gschema_file,
+    ]
+  )
+endif
+
 custom_target(
   'time.plugin',
   input: 'time.plugin.desktop.in',


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