mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-14 04:57:46 +02:00
Add a --targetdir option to gschema-compile
Also port gschema-compile to GOption, so that we get --help.
This commit is contained in:
@@ -317,6 +317,29 @@ main (int argc, char **argv)
|
|||||||
GHashTable *table;
|
GHashTable *table;
|
||||||
glob_t matched;
|
glob_t matched;
|
||||||
gint status;
|
gint status;
|
||||||
|
gchar *srcdir;
|
||||||
|
gchar *targetdir = NULL;
|
||||||
|
gchar *target;
|
||||||
|
GOptionContext *context;
|
||||||
|
GOptionEntry entries[] = {
|
||||||
|
{ "targetdir", 0, 0, G_OPTION_ARG_FILENAME, &targetdir, "where to store the gschemas.compiled file", "DIRECTORY" },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
context = g_option_context_new ("DIRECTORY");
|
||||||
|
|
||||||
|
g_option_context_set_summary (context,
|
||||||
|
"Compile all GSettings schema files into a schema cache.\n"
|
||||||
|
"Schema files are required to have the extension .gschema,\n"
|
||||||
|
"and the cache file is called gschemas.compiled.");
|
||||||
|
|
||||||
|
g_option_context_add_main_entries (context, entries, NULL);
|
||||||
|
|
||||||
|
if (!g_option_context_parse (context, &argc, &argv, &error))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", error->message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
@@ -324,7 +347,13 @@ main (int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chdir (argv[1]))
|
srcdir = argv[1];
|
||||||
|
if (targetdir)
|
||||||
|
target = g_build_filename (targetdir, "gschemas.compiled", NULL);
|
||||||
|
else
|
||||||
|
target = "gschemas.compiled";
|
||||||
|
|
||||||
|
if (chdir (srcdir))
|
||||||
{
|
{
|
||||||
perror ("chdir");
|
perror ("chdir");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -350,7 +379,7 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
/* FIXME: need a way to specify the output location, for !srcdir builds */
|
/* FIXME: need a way to specify the output location, for !srcdir builds */
|
||||||
if (!(table = parse_gschema_files (matched.gl_pathv, &error)) ||
|
if (!(table = parse_gschema_files (matched.gl_pathv, &error)) ||
|
||||||
!gvdb_table_write_contents (table, "gschemas.compiled", &error))
|
!gvdb_table_write_contents (table, target, &error))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s\n", error->message);
|
fprintf (stderr, "%s\n", error->message);
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user