2004-10-16 04:34:09 -07:00
|
|
|
/*
|
2004-10-19 09:50:27 -07:00
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
2004-10-16 04:34:09 -07:00
|
|
|
*/
|
|
|
|
|
2003-06-11 06:20:48 -07:00
|
|
|
#include "edje_cc.h"
|
2003-06-09 04:31:33 -07:00
|
|
|
|
2003-06-11 06:20:48 -07:00
|
|
|
static void main_help(void);
|
2003-06-09 04:31:33 -07:00
|
|
|
|
|
|
|
Evas_List *img_dirs = NULL;
|
2004-01-22 18:13:42 -08:00
|
|
|
Evas_List *fnt_dirs = NULL;
|
2004-10-24 06:47:55 -07:00
|
|
|
Evas_List *defines = NULL;
|
2003-06-09 04:31:33 -07:00
|
|
|
char *file_in = NULL;
|
|
|
|
char *file_out = NULL;
|
|
|
|
char *progname = NULL;
|
2003-06-16 06:55:13 -07:00
|
|
|
int verbose = 0;
|
2003-06-09 04:31:33 -07:00
|
|
|
|
2004-08-31 22:41:26 -07:00
|
|
|
int no_lossy = 0;
|
|
|
|
int no_comp = 0;
|
|
|
|
int no_raw = 0;
|
|
|
|
int min_quality = 0;
|
|
|
|
int max_quality = 100;
|
|
|
|
|
2003-06-11 06:20:48 -07:00
|
|
|
static void
|
2003-06-09 04:31:33 -07:00
|
|
|
main_help(void)
|
|
|
|
{
|
|
|
|
printf
|
|
|
|
("Usage:\n"
|
2005-03-22 11:29:06 -08:00
|
|
|
"\t%s [OPTIONS] input_file.edc [output_file.edj]\n"
|
2003-06-09 04:31:33 -07:00
|
|
|
"\n"
|
|
|
|
"Where OPTIONS is one or more of:\n"
|
|
|
|
"\n"
|
|
|
|
"-id image/directory Add a directory to look in for relative path images\n"
|
2004-01-22 18:13:42 -08:00
|
|
|
"-fd font/directory Add a directory to look in for relative path fonts\n"
|
2003-06-16 06:55:13 -07:00
|
|
|
"-v Verbose output\n"
|
2004-08-31 22:41:26 -07:00
|
|
|
"-no-lossy Do NOT allow images to be lossy\n"
|
2004-10-10 04:58:43 -07:00
|
|
|
"-no-comp Do NOT allow images to be stored with lossless compression\n"
|
|
|
|
"-no-raw Do NOT allow images to be stored with zero compression (raw)\n"
|
2004-09-01 18:10:38 -07:00
|
|
|
"-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n"
|
|
|
|
"-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n"
|
2004-10-24 06:47:55 -07:00
|
|
|
"-Ddefine_val=to CPP style define to define input macro definitions to the .edc source\n"
|
2003-06-09 04:31:33 -07:00
|
|
|
,progname);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i;
|
2004-10-16 04:34:09 -07:00
|
|
|
struct stat st;
|
|
|
|
char rpath[PATH_MAX], rpath2[PATH_MAX];
|
2003-06-09 04:31:33 -07:00
|
|
|
|
2003-06-16 06:55:13 -07:00
|
|
|
setlocale(LC_NUMERIC, "C");
|
2007-08-27 02:32:17 -07:00
|
|
|
|
2008-10-15 07:11:11 -07:00
|
|
|
eina_init();
|
|
|
|
|
2003-06-09 04:31:33 -07:00
|
|
|
progname = argv[0];
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(argv[i], "-h"))
|
|
|
|
{
|
|
|
|
main_help();
|
|
|
|
exit(0);
|
|
|
|
}
|
2003-06-16 06:55:13 -07:00
|
|
|
else if (!strcmp(argv[i], "-v"))
|
|
|
|
{
|
|
|
|
verbose = 1;
|
|
|
|
}
|
2004-08-31 22:41:26 -07:00
|
|
|
else if (!strcmp(argv[i], "-no-lossy"))
|
|
|
|
{
|
|
|
|
no_lossy = 1;
|
|
|
|
}
|
|
|
|
else if (!strcmp(argv[i], "-no-comp"))
|
|
|
|
{
|
|
|
|
no_comp = 1;
|
|
|
|
}
|
|
|
|
else if (!strcmp(argv[i], "-no-raw"))
|
|
|
|
{
|
|
|
|
no_raw = 1;
|
|
|
|
}
|
2005-03-16 11:44:53 -08:00
|
|
|
else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1)))
|
2003-06-09 04:31:33 -07:00
|
|
|
{
|
2004-10-10 04:58:43 -07:00
|
|
|
i++;
|
2003-06-09 04:31:33 -07:00
|
|
|
img_dirs = evas_list_append(img_dirs, argv[i]);
|
|
|
|
}
|
2005-03-16 11:44:53 -08:00
|
|
|
else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1)))
|
2004-01-22 18:13:42 -08:00
|
|
|
{
|
2004-10-10 04:58:43 -07:00
|
|
|
i++;
|
2004-01-22 18:13:42 -08:00
|
|
|
fnt_dirs = evas_list_append(fnt_dirs, argv[i]);
|
|
|
|
}
|
2004-08-31 22:41:26 -07:00
|
|
|
else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
|
|
|
|
{
|
2004-10-10 04:58:43 -07:00
|
|
|
i++;
|
2004-08-31 22:41:26 -07:00
|
|
|
min_quality = atoi(argv[i]);
|
|
|
|
if (min_quality < 0) min_quality = 0;
|
|
|
|
if (min_quality > 100) min_quality = 100;
|
|
|
|
}
|
|
|
|
else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1)))
|
|
|
|
{
|
2004-10-10 04:58:43 -07:00
|
|
|
i++;
|
2004-08-31 22:41:26 -07:00
|
|
|
max_quality = atoi(argv[i]);
|
|
|
|
if (max_quality < 0) max_quality = 0;
|
|
|
|
if (max_quality > 100) max_quality = 100;
|
|
|
|
}
|
2004-10-24 06:47:55 -07:00
|
|
|
else if (!strncmp(argv[i], "-D", 2))
|
|
|
|
{
|
|
|
|
defines = evas_list_append(defines, mem_strdup(argv[i]));
|
|
|
|
}
|
2005-03-16 09:51:52 -08:00
|
|
|
else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1)))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
file_out = argv[i];
|
|
|
|
}
|
2003-06-09 04:31:33 -07:00
|
|
|
else if (!file_in)
|
|
|
|
file_in = argv[i];
|
|
|
|
else if (!file_out)
|
|
|
|
file_out = argv[i];
|
|
|
|
}
|
|
|
|
if (!file_in)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s: Error: no input file specified.\n", progname);
|
|
|
|
main_help();
|
|
|
|
exit(-1);
|
|
|
|
}
|
2004-10-16 04:34:09 -07:00
|
|
|
|
2006-07-10 11:55:23 -07:00
|
|
|
e_prefix_determine(argv[0]);
|
2007-08-27 02:32:17 -07:00
|
|
|
|
2004-10-16 04:34:09 -07:00
|
|
|
/* check whether file_in exists */
|
2004-10-20 09:48:58 -07:00
|
|
|
#ifdef HAVE_REALPATH
|
2004-10-16 04:34:09 -07:00
|
|
|
if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
|
2004-10-20 09:48:58 -07:00
|
|
|
#else
|
|
|
|
if (stat(file_in, &st) || !S_ISREG(st.st_mode))
|
|
|
|
#endif
|
2004-10-16 04:34:09 -07:00
|
|
|
{
|
|
|
|
fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in);
|
|
|
|
main_help();
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2003-08-05 18:29:12 -07:00
|
|
|
if (!file_out)
|
|
|
|
{
|
|
|
|
char *suffix;
|
2007-08-27 02:32:17 -07:00
|
|
|
|
2003-08-05 18:29:12 -07:00
|
|
|
if ((suffix = strstr(file_in,".edc")) && (suffix[4] == 0))
|
|
|
|
{
|
|
|
|
file_out = strdup(file_in);
|
|
|
|
if (file_out)
|
|
|
|
{
|
|
|
|
suffix = strstr(file_out,".edc");
|
2005-03-22 11:29:06 -08:00
|
|
|
strcpy(suffix,".edj");
|
2003-08-05 18:29:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-06-09 04:31:33 -07:00
|
|
|
if (!file_out)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s: Error: no output file specified.\n", progname);
|
|
|
|
main_help();
|
|
|
|
exit(-1);
|
|
|
|
}
|
2003-06-17 01:15:06 -07:00
|
|
|
|
2004-10-20 09:48:58 -07:00
|
|
|
#ifdef HAVE_REALPATH
|
2004-10-16 04:34:09 -07:00
|
|
|
if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
|
2004-10-20 09:48:58 -07:00
|
|
|
#else
|
|
|
|
if (!strcmp (file_in, file_out))
|
|
|
|
#endif
|
2004-10-16 04:34:09 -07:00
|
|
|
{
|
|
|
|
fprintf(stderr, "%s: Error: input file equals output file.\n", progname);
|
|
|
|
main_help();
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2003-06-17 01:15:06 -07:00
|
|
|
edje_init();
|
|
|
|
|
2003-06-12 15:34:51 -07:00
|
|
|
edje_file = mem_alloc(SZ(Edje_File));
|
2005-03-16 10:39:39 -08:00
|
|
|
edje_file->compiler = strdup("edje_cc");
|
2004-03-07 18:43:48 -08:00
|
|
|
edje_file->version = EDJE_FILE_VERSION;
|
2004-10-12 20:43:42 -07:00
|
|
|
edje_file->feature_ver = 1; /* increment this every time we add a field
|
|
|
|
* or feature to the edje file format that
|
|
|
|
* does not load nicely as a NULL or 0 value
|
|
|
|
* and needs a special fallback initialization
|
|
|
|
*/
|
2007-08-27 02:32:17 -07:00
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
source_edd();
|
|
|
|
source_fetch();
|
2007-08-27 02:32:17 -07:00
|
|
|
|
|
|
|
data_setup();
|
2003-06-09 04:31:33 -07:00
|
|
|
compile();
|
2004-04-01 01:30:45 -08:00
|
|
|
data_process_scripts();
|
2003-06-13 20:06:36 -07:00
|
|
|
data_process_lookups();
|
2004-04-01 01:30:45 -08:00
|
|
|
data_process_script_lookups();
|
2003-06-09 06:51:40 -07:00
|
|
|
data_write();
|
2004-01-17 07:37:48 -08:00
|
|
|
|
|
|
|
edje_shutdown();
|
2007-08-27 02:32:17 -07:00
|
|
|
|
2008-10-15 07:11:11 -07:00
|
|
|
eina_shutdown();
|
|
|
|
|
2003-06-09 04:31:33 -07:00
|
|
|
return 0;
|
|
|
|
}
|