diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/edje/src/bin/edje_cc.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/bin/edje_cc.c | 250 |
1 files changed, 250 insertions, 0 deletions
diff --git a/libraries/edje/src/bin/edje_cc.c b/libraries/edje/src/bin/edje_cc.c new file mode 100644 index 0000000..adcbbb6 --- /dev/null +++ b/libraries/edje/src/bin/edje_cc.c | |||
@@ -0,0 +1,250 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <string.h> | ||
6 | #include <locale.h> | ||
7 | #include <limits.h> | ||
8 | #include <sys/stat.h> | ||
9 | |||
10 | #include "edje_cc.h" | ||
11 | int _edje_cc_log_dom = -1; | ||
12 | static void main_help(void); | ||
13 | |||
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; | ||
19 | char *file_in = NULL; | ||
20 | char *tmp_dir = NULL; | ||
21 | char *file_out = NULL; | ||
22 | char *progname = NULL; | ||
23 | int verbose = 0; | ||
24 | |||
25 | int no_lossy = 0; | ||
26 | int no_comp = 0; | ||
27 | int no_raw = 0; | ||
28 | int no_save = 0; | ||
29 | int min_quality = 0; | ||
30 | int max_quality = 100; | ||
31 | |||
32 | static void | ||
33 | main_help(void) | ||
34 | { | ||
35 | printf | ||
36 | ("Usage:\n" | ||
37 | "\t%s [OPTIONS] input_file.edc [output_file.edj]\n" | ||
38 | "\n" | ||
39 | "Where OPTIONS is one or more of:\n" | ||
40 | "\n" | ||
41 | "-id image/directory Add a directory to look in for relative path images\n" | ||
42 | "-fd font/directory Add a directory to look in for relative path fonts\n" | ||
43 | "-sd sound/directory Add a directory to look in for relative path sounds samples\n" | ||
44 | "-td temp/directory Directory to store temporary files\n" | ||
45 | "-v Verbose output\n" | ||
46 | "-no-lossy Do NOT allow images to be lossy\n" | ||
47 | "-no-comp Do NOT allow images to be stored with lossless compression\n" | ||
48 | "-no-raw Do NOT allow images to be stored with zero compression (raw)\n" | ||
49 | "-no-save Do NOT store the input EDC file in the EDJ file\n" | ||
50 | "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n" | ||
51 | "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n" | ||
52 | "-Ddefine_val=to CPP style define to define input macro definitions to the .edc source\n" | ||
53 | ,progname); | ||
54 | } | ||
55 | |||
56 | int | ||
57 | main(int argc, char **argv) | ||
58 | { | ||
59 | int i; | ||
60 | struct stat st; | ||
61 | char rpath[PATH_MAX], rpath2[PATH_MAX]; | ||
62 | |||
63 | setlocale(LC_NUMERIC, "C"); | ||
64 | |||
65 | if (!eina_init()) | ||
66 | return -1; | ||
67 | |||
68 | _edje_cc_log_dom = eina_log_domain_register | ||
69 | ("edje_cc", EDJE_CC_DEFAULT_LOG_COLOR); | ||
70 | if (_edje_cc_log_dom < 0) | ||
71 | { | ||
72 | EINA_LOG_ERR("Enable to create a log domain."); | ||
73 | exit(-1); | ||
74 | } | ||
75 | tmp_dir = getenv("TMPDIR"); | ||
76 | |||
77 | img_dirs = eina_list_append(img_dirs, "."); | ||
78 | |||
79 | progname = argv[0]; | ||
80 | for (i = 1; i < argc; i++) | ||
81 | { | ||
82 | if (!strcmp(argv[i], "-h")) | ||
83 | { | ||
84 | main_help(); | ||
85 | exit(0); | ||
86 | } | ||
87 | else if (!strcmp(argv[i], "-v")) | ||
88 | { | ||
89 | verbose = 1; | ||
90 | } | ||
91 | else if (!strcmp(argv[i], "-no-lossy")) | ||
92 | { | ||
93 | no_lossy = 1; | ||
94 | } | ||
95 | else if (!strcmp(argv[i], "-no-comp")) | ||
96 | { | ||
97 | no_comp = 1; | ||
98 | } | ||
99 | else if (!strcmp(argv[i], "-no-raw")) | ||
100 | { | ||
101 | no_raw = 1; | ||
102 | } | ||
103 | else if (!strcmp(argv[i], "-no-save")) | ||
104 | { | ||
105 | no_save = 1; | ||
106 | } | ||
107 | else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1))) | ||
108 | { | ||
109 | i++; | ||
110 | img_dirs = eina_list_append(img_dirs, argv[i]); | ||
111 | } | ||
112 | else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1))) | ||
113 | { | ||
114 | i++; | ||
115 | fnt_dirs = eina_list_append(fnt_dirs, argv[i]); | ||
116 | } | ||
117 | else if ((!strcmp(argv[i], "-sd") || !strcmp(argv[i], "--sound_dir")) && (i < (argc - 1))) | ||
118 | { | ||
119 | i++; | ||
120 | snd_dirs = eina_list_append(snd_dirs, argv[i]); | ||
121 | } | ||
122 | else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1))) | ||
123 | { | ||
124 | i++; | ||
125 | if (!tmp_dir) | ||
126 | tmp_dir = argv[i]; | ||
127 | } | ||
128 | else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1))) | ||
129 | { | ||
130 | i++; | ||
131 | min_quality = atoi(argv[i]); | ||
132 | if (min_quality < 0) min_quality = 0; | ||
133 | if (min_quality > 100) min_quality = 100; | ||
134 | } | ||
135 | else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1))) | ||
136 | { | ||
137 | i++; | ||
138 | max_quality = atoi(argv[i]); | ||
139 | if (max_quality < 0) max_quality = 0; | ||
140 | if (max_quality > 100) max_quality = 100; | ||
141 | } | ||
142 | else if (!strncmp(argv[i], "-D", 2)) | ||
143 | { | ||
144 | defines = eina_list_append(defines, mem_strdup(argv[i])); | ||
145 | } | ||
146 | else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1))) | ||
147 | { | ||
148 | i++; | ||
149 | file_out = argv[i]; | ||
150 | } | ||
151 | else if (!file_in) | ||
152 | file_in = argv[i]; | ||
153 | else if (!file_out) | ||
154 | file_out = argv[i]; | ||
155 | } | ||
156 | if (!file_in) | ||
157 | { | ||
158 | fprintf(stderr, "%s: Error: no input file specified.\n", progname); | ||
159 | main_help(); | ||
160 | exit(-1); | ||
161 | } | ||
162 | |||
163 | pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */ | ||
164 | main, /* an optional symbol to check path of */ | ||
165 | "EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */ | ||
166 | "edje", /* dir to add after "share" (PREFIX/share/DIRNAME) */ | ||
167 | "include/edje.inc", /* a magic file to check for in PREFIX/share/DIRNAME for success */ | ||
168 | PACKAGE_BIN_DIR, /* package bin dir @ compile time */ | ||
169 | PACKAGE_LIB_DIR, /* package lib dir @ compile time */ | ||
170 | PACKAGE_DATA_DIR, /* package data dir @ compile time */ | ||
171 | PACKAGE_DATA_DIR /* if locale needed use LOCALE_DIR */ | ||
172 | ); | ||
173 | |||
174 | /* check whether file_in exists */ | ||
175 | #ifdef HAVE_REALPATH | ||
176 | if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode)) | ||
177 | #else | ||
178 | if (stat(file_in, &st) || !S_ISREG(st.st_mode)) | ||
179 | #endif | ||
180 | { | ||
181 | fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in); | ||
182 | main_help(); | ||
183 | exit(-1); | ||
184 | } | ||
185 | |||
186 | if (!file_out) | ||
187 | { | ||
188 | char *suffix; | ||
189 | |||
190 | if ((suffix = strstr(file_in,".edc")) && (suffix[4] == 0)) | ||
191 | { | ||
192 | file_out = strdup(file_in); | ||
193 | if (file_out) | ||
194 | { | ||
195 | suffix = strstr(file_out,".edc"); | ||
196 | strcpy(suffix,".edj"); | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | if (!file_out) | ||
201 | { | ||
202 | fprintf(stderr, "%s: Error: no output file specified.\n", progname); | ||
203 | main_help(); | ||
204 | exit(-1); | ||
205 | } | ||
206 | |||
207 | #ifdef HAVE_REALPATH | ||
208 | if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2)) | ||
209 | #else | ||
210 | if (!strcmp (file_in, file_out)) | ||
211 | #endif | ||
212 | { | ||
213 | fprintf(stderr, "%s: Error: input file equals output file.\n", progname); | ||
214 | main_help(); | ||
215 | exit(-1); | ||
216 | } | ||
217 | |||
218 | if (!edje_init()) | ||
219 | exit(-1); | ||
220 | |||
221 | edje_file = mem_alloc(SZ(Edje_File)); | ||
222 | edje_file->compiler = strdup("edje_cc"); | ||
223 | edje_file->version = EDJE_FILE_VERSION; | ||
224 | edje_file->minor = EDJE_FILE_MINOR; | ||
225 | edje_file->feature_ver = 1; /* increment this every time we add a field | ||
226 | * or feature to the edje file format that | ||
227 | * does not load nicely as a NULL or 0 value | ||
228 | * and needs a special fallback initialization | ||
229 | */ | ||
230 | |||
231 | source_edd(); | ||
232 | source_fetch(); | ||
233 | |||
234 | data_setup(); | ||
235 | compile(); | ||
236 | reorder_parts(); | ||
237 | data_process_scripts(); | ||
238 | data_process_lookups(); | ||
239 | data_process_script_lookups(); | ||
240 | data_write(); | ||
241 | |||
242 | eina_prefix_free(pfx); | ||
243 | pfx = NULL; | ||
244 | |||
245 | edje_shutdown(); | ||
246 | eina_log_domain_unregister(_edje_cc_log_dom); | ||
247 | eina_shutdown(); | ||
248 | |||
249 | return 0; | ||
250 | } | ||