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 *data_dirs = NULL;
19 Eina_List *defines = NULL;
22 char *file_out = NULL;
23 char *watchfile = NULL;
25 static const char *progname = NULL;
32 int max_quality = 100;
33 int compress_mode = EET_COMPRESSION_HI;
37 _edje_cc_log_cb(const Eina_Log_Domain *d,
43 __UNUSED__ void *data,
46 if ((d->name) && (d->namelen == sizeof("edje_cc") - 1) &&
47 (memcmp(d->name, "edje_cc", sizeof("edje_cc") - 1) == 0))
51 eina_log_console_color_set(stderr, eina_log_level_color_get(level));
54 case EINA_LOG_LEVEL_CRITICAL:
55 prefix = "Critical. ";
57 case EINA_LOG_LEVEL_ERR:
60 case EINA_LOG_LEVEL_WARN:
66 fprintf(stderr, "%s: %s", progname, prefix);
67 eina_log_console_color_set(stderr, EINA_COLOR_RESET);
69 vfprintf(stderr, fmt, args);
73 eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
81 "\t%s [OPTIONS] input_file.edc [output_file.edj]\n"
83 "Where OPTIONS is one or more of:\n"
85 "-w files.txt Dump all sources files path into files.txt\n"
86 "-id image/directory Add a directory to look in for relative path images\n"
87 "-fd font/directory Add a directory to look in for relative path fonts\n"
88 "-sd sound/directory Add a directory to look in for relative path sounds samples\n"
89 "-dd data/directory Add a directory to look in for relative path data.file entries\n"
90 "-td temp/directory Directory to store temporary files\n"
92 "-no-lossy Do NOT allow images to be lossy\n"
93 "-no-comp Do NOT allow images to be stored with lossless compression\n"
94 "-no-raw Do NOT allow images to be stored with zero compression (raw)\n"
95 "-no-save Do NOT store the input EDC file in the EDJ file\n"
96 "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n"
97 "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n"
98 "-Ddefine_val=to CPP style define to define input macro definitions to the .edc source\n"
99 "-fastcomp Use a faster compression algorithm (LZ4) (mutually exclusive with -fastdecomp)\n"
100 "-fastdecomp Use a faster decompression algorithm (LZ4HC) (mutually exclusive with -fastcomp)\n"
101 "-threads Compile the edje file using multiple parallel threads (by default)\n"
102 "-nothreads Compile the edje file using only the main loop\n"
107 main(int argc, char **argv)
111 char rpath[PATH_MAX], rpath2[PATH_MAX];
113 setlocale(LC_NUMERIC, "C");
118 _edje_cc_log_dom = eina_log_domain_register
119 ("edje_cc", EDJE_CC_DEFAULT_LOG_COLOR);
120 if (_edje_cc_log_dom < 0)
122 EINA_LOG_ERR("Enable to create a log domain.");
125 if (!eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_WARN))
126 eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_WARN);
128 progname = ecore_file_file_get(argv[0]);
129 eina_log_print_cb_set(_edje_cc_log_cb, NULL);
131 tmp_dir = getenv("TMPDIR");
133 img_dirs = eina_list_append(img_dirs, ".");
135 /* add defines to epp so edc files can detect edje_cc version */
136 defines = eina_list_append(defines, mem_strdup("-DEDJE_VERSION_12=12"));
138 for (i = 1; i < argc; i++)
140 if (!strcmp(argv[i], "-h"))
145 else if (!strcmp(argv[i], "-v"))
147 eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_INFO);
149 else if (!strcmp(argv[i], "-no-lossy"))
153 else if (!strcmp(argv[i], "-no-comp"))
157 else if (!strcmp(argv[i], "-no-raw"))
161 else if (!strcmp(argv[i], "-no-save"))
165 else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1)))
168 img_dirs = eina_list_append(img_dirs, argv[i]);
170 else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1)))
173 fnt_dirs = eina_list_append(fnt_dirs, argv[i]);
175 else if ((!strcmp(argv[i], "-sd") || !strcmp(argv[i], "--sound_dir")) && (i < (argc - 1)))
178 snd_dirs = eina_list_append(snd_dirs, argv[i]);
180 else if ((!strcmp(argv[i], "-dd") || !strcmp(argv[i], "--data_dir")) && (i < (argc - 1)))
183 data_dirs = eina_list_append(data_dirs, argv[i]);
185 else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1)))
191 else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
194 min_quality = atoi(argv[i]);
195 if (min_quality < 0) min_quality = 0;
196 if (min_quality > 100) min_quality = 100;
198 else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1)))
201 max_quality = atoi(argv[i]);
202 if (max_quality < 0) max_quality = 0;
203 if (max_quality > 100) max_quality = 100;
205 else if (!strcmp(argv[i], "-fastcomp"))
207 compress_mode = EET_COMPRESSION_SUPERFAST;
209 else if (!strcmp(argv[i], "-fastdecomp"))
211 compress_mode = EET_COMPRESSION_VERYFAST;
213 else if (!strcmp(argv[i], "-threads"))
217 else if (!strcmp(argv[i], "-nothreads"))
221 else if (!strncmp(argv[i], "-D", 2))
223 defines = eina_list_append(defines, mem_strdup(argv[i]));
225 else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1)))
230 else if ((!strcmp(argv[i], "-w")) && (i < (argc - 1)))
244 ERR("no input file specified.");
251 pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */
252 main, /* an optional symbol to check path of */
253 "EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */
254 "edje", /* dir to add after "share" (PREFIX/share/DIRNAME) */
255 "include/edje.inc", /* a magic file to check for in PREFIX/share/DIRNAME for success */
256 PACKAGE_BIN_DIR, /* package bin dir @ compile time */
257 PACKAGE_LIB_DIR, /* package lib dir @ compile time */
258 PACKAGE_DATA_DIR, /* package data dir @ compile time */
259 PACKAGE_DATA_DIR /* if locale needed use LOCALE_DIR */
262 /* check whether file_in exists */
264 if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
266 if (stat(file_in, &st) || !S_ISREG(st.st_mode))
269 ERR("file not found: %s.", file_in);
278 if ((suffix = strstr(file_in,".edc")) && (suffix[4] == 0))
280 file_out = strdup(file_in);
283 suffix = strstr(file_out,".edc");
284 strcpy(suffix,".edj");
290 ERR("no output file specified.");
296 if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
298 if (!strcmp (file_in, file_out))
301 ERR("input file equals output file.");
311 edje_file = mem_alloc(SZ(Edje_File));
312 edje_file->compiler = strdup("edje_cc");
313 edje_file->version = EDJE_FILE_VERSION;
314 edje_file->minor = EDJE_FILE_MINOR;
315 edje_file->feature_ver = 1; /* increment this every time we add a field
316 * or feature to the edje file format that
317 * does not load nicely as a NULL or 0 value
318 * and needs a special fallback initialization
327 data_process_scripts();
328 data_process_lookups();
329 data_process_script_lookups();
332 eina_prefix_free(pfx);
336 eina_log_domain_unregister(_edje_cc_log_dom);