11 int _edje_cc_log_dom = -1;
12 static void main_help(void);
14 Eina_Prefix *pfx = NULL;
15 Eina_List *snd_dirs = NULL;
16 Eina_List *img_dirs = NULL;
17 Eina_List *fnt_dirs = NULL;
18 Eina_List *defines = NULL;
21 char *file_out = NULL;
22 char *watchfile = NULL;
24 static const char *progname = NULL;
31 int max_quality = 100;
32 int compress_mode = EET_COMPRESSION_DEFAULT;
36 _edje_cc_log_cb(const Eina_Log_Domain *d,
42 __UNUSED__ void *data,
45 if ((d->name) && (d->namelen == sizeof("edje_cc") - 1) &&
46 (memcmp(d->name, "edje_cc", sizeof("edje_cc") - 1) == 0))
50 eina_log_console_color_set(stderr, eina_log_level_color_get(level));
53 case EINA_LOG_LEVEL_CRITICAL:
54 prefix = "Critical. ";
56 case EINA_LOG_LEVEL_ERR:
59 case EINA_LOG_LEVEL_WARN:
65 fprintf(stderr, "%s: %s", progname, prefix);
66 eina_log_console_color_set(stderr, EINA_COLOR_RESET);
68 vfprintf(stderr, fmt, args);
72 eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
80 "\t%s [OPTIONS] input_file.edc [output_file.edj]\n"
82 "Where OPTIONS is one or more of:\n"
84 "-w files.txt Dump all sources files path into files.txt\n"
85 "-id image/directory Add a directory to look in for relative path images\n"
86 "-fd font/directory Add a directory to look in for relative path fonts\n"
87 "-sd sound/directory Add a directory to look in for relative path sounds samples\n"
88 "-td temp/directory Directory to store temporary files\n"
90 "-no-lossy Do NOT allow images to be lossy\n"
91 "-no-comp Do NOT allow images to be stored with lossless compression\n"
92 "-no-raw Do NOT allow images to be stored with zero compression (raw)\n"
93 "-no-save Do NOT store the input EDC file in the EDJ file\n"
94 "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n"
95 "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n"
96 "-Ddefine_val=to CPP style define to define input macro definitions to the .edc source\n"
97 "-fastcomp Use a faster compression algorithm (LZ4) (mutually exclusive with -fastdecomp)\n"
98 "-fastdecomp Use a faster decompression algorithm (LZ4HC) (mutually exclusive with -fastcomp)\n"
99 "-threads Compile the edje file using multiple parallel threads (by default)\n"
100 "-nothreads Compile the edje file using only the main loop\n"
105 main(int argc, char **argv)
109 char rpath[PATH_MAX], rpath2[PATH_MAX];
111 setlocale(LC_NUMERIC, "C");
116 _edje_cc_log_dom = eina_log_domain_register
117 ("edje_cc", EDJE_CC_DEFAULT_LOG_COLOR);
118 if (_edje_cc_log_dom < 0)
120 EINA_LOG_ERR("Enable to create a log domain.");
123 if (!eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_WARN))
124 eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_WARN);
126 progname = ecore_file_file_get(argv[0]);
127 eina_log_print_cb_set(_edje_cc_log_cb, NULL);
129 tmp_dir = getenv("TMPDIR");
131 img_dirs = eina_list_append(img_dirs, ".");
133 /* add defines to epp so edc files can detect edje_cc version */
134 defines = eina_list_append(defines, mem_strdup("-DEDJE_VERSION_12=12"));
136 for (i = 1; i < argc; i++)
138 if (!strcmp(argv[i], "-h"))
143 else if (!strcmp(argv[i], "-v"))
145 eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_INFO);
147 else if (!strcmp(argv[i], "-no-lossy"))
151 else if (!strcmp(argv[i], "-no-comp"))
155 else if (!strcmp(argv[i], "-no-raw"))
159 else if (!strcmp(argv[i], "-no-save"))
163 else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1)))
166 img_dirs = eina_list_append(img_dirs, argv[i]);
168 else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1)))
171 fnt_dirs = eina_list_append(fnt_dirs, argv[i]);
173 else if ((!strcmp(argv[i], "-sd") || !strcmp(argv[i], "--sound_dir")) && (i < (argc - 1)))
176 snd_dirs = eina_list_append(snd_dirs, argv[i]);
178 else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1)))
184 else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
187 min_quality = atoi(argv[i]);
188 if (min_quality < 0) min_quality = 0;
189 if (min_quality > 100) min_quality = 100;
191 else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1)))
194 max_quality = atoi(argv[i]);
195 if (max_quality < 0) max_quality = 0;
196 if (max_quality > 100) max_quality = 100;
198 else if (!strcmp(argv[i], "-fastcomp"))
200 compress_mode = EET_COMPRESSION_SUPERFAST;
202 else if (!strcmp(argv[i], "-fastdecomp"))
204 compress_mode = EET_COMPRESSION_VERYFAST;
206 else if (!strcmp(argv[i], "-threads"))
210 else if (!strcmp(argv[i], "-nothreads"))
214 else if (!strncmp(argv[i], "-D", 2))
216 defines = eina_list_append(defines, mem_strdup(argv[i]));
218 else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1)))
223 else if ((!strcmp(argv[i], "-w")) && (i < (argc - 1)))
237 ERR("no input file specified.");
244 pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */
245 main, /* an optional symbol to check path of */
246 "EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */
247 "edje", /* dir to add after "share" (PREFIX/share/DIRNAME) */
248 "include/edje.inc", /* a magic file to check for in PREFIX/share/DIRNAME for success */
249 PACKAGE_BIN_DIR, /* package bin dir @ compile time */
250 PACKAGE_LIB_DIR, /* package lib dir @ compile time */
251 PACKAGE_DATA_DIR, /* package data dir @ compile time */
252 PACKAGE_DATA_DIR /* if locale needed use LOCALE_DIR */
255 /* check whether file_in exists */
257 if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
259 if (stat(file_in, &st) || !S_ISREG(st.st_mode))
262 ERR("file not found: %s.", file_in);
271 if ((suffix = strstr(file_in,".edc")) && (suffix[4] == 0))
273 file_out = strdup(file_in);
276 suffix = strstr(file_out,".edc");
277 strcpy(suffix,".edj");
283 ERR("no output file specified.");
289 if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
291 if (!strcmp (file_in, file_out))
294 ERR("input file equals output file.");
304 edje_file = mem_alloc(SZ(Edje_File));
305 edje_file->compiler = strdup("edje_cc");
306 edje_file->version = EDJE_FILE_VERSION;
307 edje_file->minor = EDJE_FILE_MINOR;
308 edje_file->feature_ver = 1; /* increment this every time we add a field
309 * or feature to the edje file format that
310 * does not load nicely as a NULL or 0 value
311 * and needs a special fallback initialization
320 data_process_scripts();
321 data_process_lookups();
322 data_process_script_lookups();
325 eina_prefix_free(pfx);
329 eina_log_domain_unregister(_edje_cc_log_dom);