[glib] Add --uninstall option to glib-compile-schemas



commit caae8ac57a2d24a5de21d1ac6d6122897a418e72
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed May 19 16:02:05 2010 -0400

    Add --uninstall option to glib-compile-schemas
    
    If --uninstall is given then don't give an error if the schema directory
    is empty.  Instead, erase the gschemas.compiled file, if it exists.
    This is the right thing to do in the 'make uninstall' rule, where the
    schema directory could very well be left empty as a result.
    
    Modify gsettings.m4 to use this option.

 gio/gschema-compile.c |   15 +++++++++++++--
 m4macros/gsettings.m4 |    2 +-
 2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gio/gschema-compile.c b/gio/gschema-compile.c
index ee77268..42d056b 100644
--- a/gio/gschema-compile.c
+++ b/gio/gschema-compile.c
@@ -21,6 +21,7 @@
 
 #include "config.h"
 
+#include <gstdio.h>
 #include <locale.h>
 #include <string.h>
 #include <unistd.h>
@@ -638,12 +639,14 @@ main (int argc, char **argv)
   gchar *srcdir;
   gchar *targetdir = NULL;
   gchar *target;
+  gboolean uninstall = FALSE;
   gboolean dry_run = FALSE;
   gchar **schema_files = NULL;
   GOptionContext *context;
   GOptionEntry entries[] = {
     { "targetdir", 0, 0, G_OPTION_ARG_FILENAME, &targetdir, N_("where to store the gschemas.compiled file"), N_("DIRECTORY") },
     { "dry-run", 0, 0, G_OPTION_ARG_NONE, &dry_run, N_("Do not write the gschema.compiled file"), NULL },
+    { "uninstall", 0, 0, G_OPTION_ARG_NONE, &uninstall, N_("Do not give error for empty directory"), NULL },
     { "allow-any-name", 0, 0, G_OPTION_ARG_NONE, &allow_any_name, N_("Do not enforce key name restrictions") },
 
     /* These options are only for use in the gschema-compile tests */
@@ -704,8 +707,16 @@ main (int argc, char **argv)
 
       if (files->len == 0)
         {
-          fprintf (stderr, _("No schema files found\n"));
-          return 1;
+          if (uninstall)
+            {
+              g_unlink (target);
+              return 0;
+            }
+          else
+            {
+              fprintf (stderr, _("No schema files found\n"));
+              return 1;
+            }
         }
       g_ptr_array_add (files, NULL);
 
diff --git a/m4macros/gsettings.m4 b/m4macros/gsettings.m4
index 35cade8..73a7e15 100644
--- a/m4macros/gsettings.m4
+++ b/m4macros/gsettings.m4
@@ -59,7 +59,7 @@ uninstall-gsettings-schemas:
 	test -n "$$files" || exit 0; \
 	echo " ( cd '\''$(DESTDIR)$(gsettingsschemadir)'\'' && rm -f" $$files ")"; \
 	cd "$(DESTDIR)$(gsettingsschemadir)" && rm -f $$files
-	test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir)
+	test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) --uninstall $(gsettingsschemadir)
 
 clean-gsettings-schemas:
 	rm -f $(gsettings_SCHEMAS:.xml=.valid)



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