minor cleanup, hopefully not breaking anything.
2007-11-17 Sven Neumann <sven@gimp.org> * tools/gimptool.c: minor cleanup, hopefully not breaking anything. svn path=/trunk/; revision=24181
This commit is contained in:

committed by
Sven Neumann

parent
287cc39898
commit
bbef0f35e8
@ -1,3 +1,7 @@
|
|||||||
|
2007-11-17 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* tools/gimptool.c: minor cleanup, hopefully not breaking anything.
|
||||||
|
|
||||||
2007-11-17 Sven Neumann <sven@gimp.org>
|
2007-11-17 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/base/base-utils.[ch]: changed to get_physical_memory_size()
|
* app/base/base-utils.[ch]: changed to get_physical_memory_size()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* gimptool in C
|
/* gimptool in C
|
||||||
* Copyright (C) 2001--2007 Tor Lillqvist
|
* Copyright (C) 2001-2007 Tor Lillqvist
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "libgimpbase/gimpversion.h"
|
#include "libgimpbase/gimpversion.h"
|
||||||
|
|
||||||
|
|
||||||
static gboolean silent = FALSE;
|
static gboolean silent = FALSE;
|
||||||
static gboolean dry_run = FALSE;
|
static gboolean dry_run = FALSE;
|
||||||
static gchar *prefix;
|
static gchar *prefix;
|
||||||
@ -46,6 +47,7 @@ static gchar *env_cflags;
|
|||||||
static gchar *env_ldflags;
|
static gchar *env_ldflags;
|
||||||
static gchar *env_libs;
|
static gchar *env_libs;
|
||||||
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
#define EXEEXT ".exe"
|
#define EXEEXT ".exe"
|
||||||
#else
|
#else
|
||||||
@ -61,7 +63,7 @@ static gchar *env_libs;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
gchar *option;
|
const gchar *option;
|
||||||
gchar *value;
|
gchar *value;
|
||||||
} dirs[] = {
|
} dirs[] = {
|
||||||
{ "prefix", PREFIX },
|
{ "prefix", PREFIX },
|
||||||
@ -116,12 +118,12 @@ one_line_output (gchar *program,
|
|||||||
{
|
{
|
||||||
gchar *command = g_strconcat (program, " ", args, NULL);
|
gchar *command = g_strconcat (program, " ", args, NULL);
|
||||||
FILE *pipe = popen (command, "r");
|
FILE *pipe = popen (command, "r");
|
||||||
char line[1000];
|
gchar line[1000];
|
||||||
|
|
||||||
if (pipe == NULL)
|
if (pipe == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Cannot run '%s'\n", command);
|
g_printerr ("Cannot run '%s'\n", command);
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fgets (line, sizeof (line), pipe) == NULL)
|
if (fgets (line, sizeof (line), pipe) == NULL)
|
||||||
@ -136,8 +138,8 @@ one_line_output (gchar *program,
|
|||||||
|
|
||||||
if (strlen (line) == 0)
|
if (strlen (line) == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "No output from '%s'\n", command);
|
g_printerr ("No output from '%s'\n", command);
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_strdup (line);
|
return g_strdup (line);
|
||||||
@ -164,7 +166,7 @@ get_runtime_prefix (gchar slash)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
gchar *path;
|
gchar *path;
|
||||||
char *p, *r;
|
gchar *p, *r;
|
||||||
|
|
||||||
path = g_find_program_in_path ("gimp-" GIMP_APP_VERSION ".exe");
|
path = g_find_program_in_path ("gimp-" GIMP_APP_VERSION ".exe");
|
||||||
|
|
||||||
@ -193,8 +195,9 @@ get_runtime_prefix (gchar slash)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "Cannot determine GIMP " GIMP_APP_VERSION " installation location\n");
|
g_printerr ("Cannot determine GIMP " GIMP_APP_VERSION " installation location\n");
|
||||||
exit (1);
|
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
#else
|
#else
|
||||||
/* On Unix assume the executable package is in the same prefix as the developer stuff */
|
/* On Unix assume the executable package is in the same prefix as the developer stuff */
|
||||||
return pkg_config ("--variable=prefix gimp-2.0");
|
return pkg_config ("--variable=prefix gimp-2.0");
|
||||||
@ -268,7 +271,7 @@ find_out_env_flags (void)
|
|||||||
static void
|
static void
|
||||||
usage (int exit_status)
|
usage (int exit_status)
|
||||||
{
|
{
|
||||||
printf ("\
|
g_print ("\
|
||||||
Usage: gimptool-2.0 [OPTION]...\n\
|
Usage: gimptool-2.0 [OPTION]...\n\
|
||||||
\n\
|
\n\
|
||||||
General options:\n\
|
General options:\n\
|
||||||
@ -328,7 +331,7 @@ get_includedir (void)
|
|||||||
static void
|
static void
|
||||||
do_includedir (void)
|
do_includedir (void)
|
||||||
{
|
{
|
||||||
printf ("%s\n", get_includedir ());
|
g_print ("%s\n", get_includedir ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
@ -340,7 +343,7 @@ get_cflags (void)
|
|||||||
static void
|
static void
|
||||||
do_cflags (void)
|
do_cflags (void)
|
||||||
{
|
{
|
||||||
printf ("%s\n", get_cflags ());
|
g_print ("%s\n", get_cflags ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
@ -352,7 +355,7 @@ get_cflags_noui (void)
|
|||||||
static void
|
static void
|
||||||
do_cflags_noui (void)
|
do_cflags_noui (void)
|
||||||
{
|
{
|
||||||
printf ("%s\n", get_cflags_noui ());
|
g_print ("%s\n", get_cflags_noui ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
@ -364,7 +367,7 @@ get_cflags_nogimpui (void)
|
|||||||
static void
|
static void
|
||||||
do_cflags_nogimpui (void)
|
do_cflags_nogimpui (void)
|
||||||
{
|
{
|
||||||
printf ("%s\n", get_cflags_nogimpui ());
|
g_print ("%s\n", get_cflags_nogimpui ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
@ -376,7 +379,7 @@ get_libs (void)
|
|||||||
static void
|
static void
|
||||||
do_libs (void)
|
do_libs (void)
|
||||||
{
|
{
|
||||||
printf ("%s\n", get_libs ());
|
g_print ("%s\n", get_libs ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
@ -388,7 +391,7 @@ get_libs_noui (void)
|
|||||||
static void
|
static void
|
||||||
do_libs_noui (void)
|
do_libs_noui (void)
|
||||||
{
|
{
|
||||||
printf ("%s\n", get_libs_noui ());
|
g_print ("%s\n", get_libs_noui ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
@ -400,14 +403,14 @@ get_libs_nogimpui (void)
|
|||||||
static void
|
static void
|
||||||
do_libs_nogimpui (void)
|
do_libs_nogimpui (void)
|
||||||
{
|
{
|
||||||
printf ("%s\n", get_libs_nogimpui ());
|
g_print ("%s\n", get_libs_nogimpui ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
maybe_run (gchar *cmd)
|
maybe_run (gchar *cmd)
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printf ("%s\n", cmd);
|
g_print ("%s\n", cmd);
|
||||||
|
|
||||||
if (!dry_run)
|
if (!dry_run)
|
||||||
system (cmd);
|
system (cmd);
|
||||||
@ -425,7 +428,7 @@ do_build_2 (gchar *cflags,
|
|||||||
gchar *dest_exe;
|
gchar *dest_exe;
|
||||||
gchar *here_comes_linker_flags = "";
|
gchar *here_comes_linker_flags = "";
|
||||||
gchar *windows_subsystem_flag = "";
|
gchar *windows_subsystem_flag = "";
|
||||||
gchar *p, *q, *r;
|
gchar *p, *q;
|
||||||
|
|
||||||
if (install_dir != NULL)
|
if (install_dir != NULL)
|
||||||
dest_dir = g_strconcat (install_dir, "/", NULL);
|
dest_dir = g_strconcat (install_dir, "/", NULL);
|
||||||
@ -435,18 +438,23 @@ do_build_2 (gchar *cflags,
|
|||||||
dest_exe = g_strdup (what);
|
dest_exe = g_strdup (what);
|
||||||
|
|
||||||
p = strrchr (dest_exe, '.');
|
p = strrchr (dest_exe, '.');
|
||||||
if (p == NULL || !(strcmp (p, ".c") == 0 || strcmp (p, ".cc") == 0 || strcmp (p, ".cpp") == 0))
|
if (p == NULL ||
|
||||||
|
!(strcmp (p, ".c") == 0 ||
|
||||||
|
strcmp (p, ".cc") == 0 ||
|
||||||
|
strcmp (p, ".cpp") == 0))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "plug-in source %s is not a C or C++ file?\n", what);
|
g_printerr ("plug-in source %s is not a C or C++ file?\n", what);
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
q = strrchr (dest_exe, G_DIR_SEPARATOR);
|
q = strrchr (dest_exe, G_DIR_SEPARATOR);
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
r = strrchr (dest_exe, '/');
|
{
|
||||||
|
gchar *r = strrchr (dest_exe, '/');
|
||||||
if (r != NULL && (q == NULL || r > q))
|
if (r != NULL && (q == NULL || r > q))
|
||||||
q = r;
|
q = r;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (q == NULL)
|
if (q == NULL)
|
||||||
q = dest_exe;
|
q = dest_exe;
|
||||||
@ -683,7 +691,7 @@ main (int argc,
|
|||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
usage (0);
|
usage (EXIT_SUCCESS);
|
||||||
|
|
||||||
/* First scan for flags that affect our behaviour globally, but
|
/* First scan for flags that affect our behaviour globally, but
|
||||||
* are still allowed late on the command line.
|
* are still allowed late on the command line.
|
||||||
@ -695,21 +703,31 @@ main (int argc,
|
|||||||
strcmp (argv[argi], "--just-print") == 0 ||
|
strcmp (argv[argi], "--just-print") == 0 ||
|
||||||
strcmp (argv[argi], "--dry-run") == 0 ||
|
strcmp (argv[argi], "--dry-run") == 0 ||
|
||||||
strcmp (argv[argi], "--recon") == 0)
|
strcmp (argv[argi], "--recon") == 0)
|
||||||
|
{
|
||||||
dry_run = TRUE;
|
dry_run = TRUE;
|
||||||
|
}
|
||||||
else if (strcmp (argv[argi], "--help") == 0)
|
else if (strcmp (argv[argi], "--help") == 0)
|
||||||
usage (0);
|
{
|
||||||
|
usage (EXIT_SUCCESS);
|
||||||
|
}
|
||||||
else if (g_str_has_prefix (argv[argi], "--prefix="))
|
else if (g_str_has_prefix (argv[argi], "--prefix="))
|
||||||
|
{
|
||||||
prefix = argv[argi] + strlen ("--prefix=");
|
prefix = argv[argi] + strlen ("--prefix=");
|
||||||
|
}
|
||||||
else if (g_str_has_prefix (argv[argi], "--exec-prefix="))
|
else if (g_str_has_prefix (argv[argi], "--exec-prefix="))
|
||||||
|
{
|
||||||
exec_prefix = argv[argi] + strlen ("--exec_prefix=");
|
exec_prefix = argv[argi] + strlen ("--exec_prefix=");
|
||||||
|
}
|
||||||
else if (strcmp (argv[argi], "--msvc-syntax") == 0)
|
else if (strcmp (argv[argi], "--msvc-syntax") == 0)
|
||||||
|
{
|
||||||
msvc_syntax = TRUE;
|
msvc_syntax = TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
if (msvc_syntax)
|
if (msvc_syntax)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Ignoring --msvc-syntax\n");
|
g_printerr ("Ignoring --msvc-syntax\n");
|
||||||
msvc_syntax = FALSE;
|
msvc_syntax = FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -721,17 +739,26 @@ main (int argc,
|
|||||||
while (++argi < argc)
|
while (++argi < argc)
|
||||||
{
|
{
|
||||||
for (i = 0; i < G_N_ELEMENTS (dirs); i++)
|
for (i = 0; i < G_N_ELEMENTS (dirs); i++)
|
||||||
if (strcmp (argv[argi], g_strconcat ("--", dirs[i].option, NULL)) == 0)
|
{
|
||||||
|
if (strcmp (argv[argi],
|
||||||
|
g_strconcat ("--", dirs[i].option, NULL)) == 0)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (i < G_N_ELEMENTS (dirs))
|
if (i < G_N_ELEMENTS (dirs))
|
||||||
printf ("%s\n", expand_and_munge (dirs[i].value));
|
{
|
||||||
|
g_print ("%s\n", expand_and_munge (dirs[i].value));
|
||||||
|
}
|
||||||
else if (strcmp (argv[argi], "--quiet") == 0 ||
|
else if (strcmp (argv[argi], "--quiet") == 0 ||
|
||||||
strcmp (argv[argi], "--silent") == 0)
|
strcmp (argv[argi], "--silent") == 0)
|
||||||
|
{
|
||||||
silent = TRUE;
|
silent = TRUE;
|
||||||
|
}
|
||||||
else if (strcmp (argv[argi], "--version") == 0)
|
else if (strcmp (argv[argi], "--version") == 0)
|
||||||
{
|
{
|
||||||
printf ("%d.%d.%d\n", GIMP_MAJOR_VERSION, GIMP_MINOR_VERSION, GIMP_MICRO_VERSION);
|
g_print ("%d.%d.%d\n",
|
||||||
exit (0);
|
GIMP_MAJOR_VERSION, GIMP_MINOR_VERSION, GIMP_MICRO_VERSION);
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
else if (strcmp (argv[argi], "-n") == 0 ||
|
else if (strcmp (argv[argi], "-n") == 0 ||
|
||||||
strcmp (argv[argi], "--just-print") == 0 ||
|
strcmp (argv[argi], "--just-print") == 0 ||
|
||||||
@ -794,11 +821,12 @@ main (int argc,
|
|||||||
do_uninstall_admin_script (argv[++argi]);
|
do_uninstall_admin_script (argv[++argi]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Unrecognized switch %s\n", argv[argi]);
|
g_printerr ("Unrecognized switch %s\n", argv[argi]);
|
||||||
usage (1);
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit (0);
|
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
|
Reference in New Issue
Block a user