X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fglib-compile-resources.c;h=6bad64fc49d2a7eb23461a6d5e06f4a5663cbfa1;hb=a3d86afa81ff34ce797a3928fd619ead219a37af;hp=fbe2c73c1da85c5307630727abb4561204809565;hpb=f7abd3ce130ae3a6da8502c2dce8d773d7514464;p=platform%2Fupstream%2Fglib.git diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c index fbe2c73..6bad64f 100644 --- a/gio/glib-compile-resources.c +++ b/gio/glib-compile-resources.c @@ -12,9 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library; if not, see . * * Author: Alexander Larsson */ @@ -30,6 +28,9 @@ #include #include #include +#ifdef G_OS_UNIX +#include +#endif #ifdef G_OS_WIN32 #include #endif @@ -38,15 +39,15 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif - #include #include "gvdb/gvdb-builder.h" #include "gconstructor_as_data.h" +#ifdef G_OS_WIN32 +#include "glib/glib-private.h" +#endif + typedef struct { char *filename; @@ -187,7 +188,7 @@ find_file (const gchar *filename) /* search all the sourcedirs for the correct files in order */ for (i = 0; sourcedirs[i] != NULL; i++) { - real_file = g_build_filename (sourcedirs[i], filename, NULL); + real_file = g_build_path ("/", sourcedirs[i], filename, NULL); exists = g_file_test (real_file, G_FILE_TEST_EXISTS); if (exists) return real_file; @@ -269,7 +270,6 @@ end_element (GMarkupParseContext *context, if (state->preproc_options) { gchar **options; - gchar *stderr_child = NULL; guint i; gboolean xml_stripblanks = FALSE; gboolean to_pixdata = FALSE; @@ -294,8 +294,8 @@ end_element (GMarkupParseContext *context, if (xml_stripblanks && xmllint != NULL) { - gchar *argv[8]; - int status, fd, argc; + int fd; + GSubprocess *proc; tmp_file = g_strdup ("resource-XXXXXXXX"); if ((fd = g_mkstemp (tmp_file)) == -1) @@ -311,42 +311,29 @@ end_element (GMarkupParseContext *context, } close (fd); - argc = 0; - argv[argc++] = (gchar *) xmllint; - argv[argc++] = "--nonet"; - argv[argc++] = "--noblanks"; - argv[argc++] = "--output"; - argv[argc++] = tmp_file; - argv[argc++] = real_file; - argv[argc++] = NULL; - g_assert (argc <= G_N_ELEMENTS (argv)); - - if (!g_spawn_sync (NULL /* cwd */, argv, NULL /* envv */, - G_SPAWN_STDOUT_TO_DEV_NULL, - NULL, NULL, NULL, &stderr_child, &status, &my_error)) - { - g_propagate_error (error, my_error); - goto cleanup; - } - - /* Ugly...we shoud probably just let stderr be inherited */ - if (!g_spawn_check_exit_status (status, NULL)) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - _("Error processing input file with xmllint:\n%s"), stderr_child); + proc = g_subprocess_new (G_SUBPROCESS_FLAGS_STDOUT_SILENCE, error, + xmllint, "--nonet", "--noblanks", "--output", tmp_file, real_file, NULL); + g_free (real_file); + real_file = NULL; + + if (!proc) + goto cleanup; + + if (!g_subprocess_wait_check (proc, NULL, error)) + { + g_object_unref (proc); goto cleanup; } - g_free (stderr_child); - g_free (real_file); + g_object_unref (proc); + real_file = g_strdup (tmp_file); } if (to_pixdata) { - gchar *argv[4]; - gchar *stderr_child = NULL; - int status, fd, argc; + int fd; + GSubprocess *proc; if (gdk_pixbuf_pixdata == NULL) { @@ -370,30 +357,19 @@ end_element (GMarkupParseContext *context, } close (fd); - argc = 0; - argv[argc++] = (gchar *) gdk_pixbuf_pixdata; - argv[argc++] = real_file; - argv[argc++] = tmp_file2; - argv[argc++] = NULL; - g_assert (argc <= G_N_ELEMENTS (argv)); + proc = g_subprocess_new (G_SUBPROCESS_FLAGS_STDOUT_SILENCE, error, + gdk_pixbuf_pixdata, real_file, tmp_file2, NULL); + g_free (real_file); + real_file = NULL; - if (!g_spawn_sync (NULL /* cwd */, argv, NULL /* envv */, - G_SPAWN_STDOUT_TO_DEV_NULL, - NULL, NULL, NULL, &stderr_child, &status, &my_error)) - { - g_propagate_error (error, my_error); + if (!g_subprocess_wait_check (proc, NULL, error)) + { + g_object_unref (proc); goto cleanup; - } - - if (!g_spawn_check_exit_status (status, NULL)) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - _("Error processing input file with to-pixdata:\n%s"), stderr_child); - goto cleanup; - } + } + + g_object_unref (proc); - g_free (stderr_child); - g_free (real_file); real_file = g_strdup (tmp_file2); } } @@ -603,9 +579,11 @@ main (int argc, char **argv) gboolean generate_source = FALSE; gboolean generate_header = FALSE; gboolean manual_register = FALSE; + gboolean internal = FALSE; gboolean generate_dependencies = FALSE; char *c_name = NULL; char *c_name_no_underscores; + const char *linkage = "extern"; GOptionContext *context; GOptionEntry entries[] = { { "target", 0, 0, G_OPTION_ARG_FILENAME, &target, N_("name of the output file"), N_("FILE") }, @@ -615,12 +593,12 @@ main (int argc, char **argv) { "generate-source", 0, 0, G_OPTION_ARG_NONE, &generate_source, N_("Generate sourcecode used to link in the resource file into your code"), NULL }, { "generate-dependencies", 0, 0, G_OPTION_ARG_NONE, &generate_dependencies, N_("Generate dependency list"), NULL }, { "manual-register", 0, 0, G_OPTION_ARG_NONE, &manual_register, N_("Don't automatically create and register resource"), NULL }, + { "internal", 0, 0, G_OPTION_ARG_NONE, &internal, N_("Don't export functions; declare them G_GNUC_INTERNAL"), NULL }, { "c-name", 0, 0, G_OPTION_ARG_STRING, &c_name, N_("C identifier name used for the generated source code"), NULL }, { NULL } }; #ifdef G_OS_WIN32 - extern gchar *_glib_get_locale_dir (void); gchar *tmp; #endif @@ -639,8 +617,6 @@ main (int argc, char **argv) bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif - g_type_init (); - context = g_option_context_new (N_("FILE")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_set_summary (context, @@ -664,6 +640,9 @@ main (int argc, char **argv) return 1; } + if (internal) + linkage = "G_GNUC_INTERNAL"; + srcfile = argv[1]; xmllint = g_strdup (g_getenv ("XMLLINT")); @@ -805,16 +784,16 @@ main (int argc, char **argv) "\n" "#include \n" "\n" - "extern GResource *%s_get_resource (void);\n", - c_name, c_name, c_name); + "%s GResource *%s_get_resource (void);\n", + c_name, c_name, linkage, c_name); if (manual_register) fprintf (file, "\n" - "extern void %s_register_resource (void);\n" - "extern void %s_unregister_resource (void);\n" + "%s void %s_register_resource (void);\n" + "%s void %s_unregister_resource (void);\n" "\n", - c_name, c_name); + linkage, c_name, linkage, c_name); fprintf (file, "#endif\n"); @@ -869,31 +848,31 @@ main (int argc, char **argv) fprintf (file, "\n" - "static GStaticResource static_resource = { %s_resource_data.data, sizeof (%s_resource_data.data) };\n" - "extern GResource *%s_get_resource (void);\n" + "static GStaticResource static_resource = { %s_resource_data.data, sizeof (%s_resource_data.data), NULL, NULL, NULL };\n" + "%s GResource *%s_get_resource (void);\n" "GResource *%s_get_resource (void)\n" "{\n" " return g_static_resource_get_resource (&static_resource);\n" "}\n", - c_name, c_name, c_name, c_name); + c_name, c_name, linkage, c_name, c_name); if (manual_register) { fprintf (file, "\n" - "extern void %s_unregister_resource (void);\n" + "%s void %s_unregister_resource (void);\n" "void %s_unregister_resource (void)\n" "{\n" " g_static_resource_fini (&static_resource);\n" "}\n" "\n" - "extern void %s_register_resource (void);\n" + "%s void %s_register_resource (void);\n" "void %s_register_resource (void)\n" "{\n" " g_static_resource_init (&static_resource);\n" "}\n", - c_name, c_name, c_name, c_name); + linkage, c_name, c_name, linkage, c_name, c_name); } else {