summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-02-20 11:53:01 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-03 14:09:56 +0200
commit60919ecbe60de38f5d91167983feaffbfa99ff57 (patch)
tree0c47fe1bc640192c0b3b630dc336ee47e7586ef2 /src/bin
parent521701ff70f0d2ba8956c1e9045f0c4a2f6be8e4 (diff)
Eolian/Generator: improve command line arguments and logging.
Now --gh/--gc don't require an additional argument. If eolian_gen is called with --gc and some file.eo, the tool will generate file.eo.c. You can force another filename by using the -o with an argument. Moreover, logging has been added to the generator.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/common_funcs.c2
-rw-r--r--src/bin/eolian/common_funcs.h27
-rw-r--r--src/bin/eolian/eo1_generator.h1
-rw-r--r--src/bin/eolian/main.c128
4 files changed, 115 insertions, 43 deletions
diff --git a/src/bin/eolian/common_funcs.c b/src/bin/eolian/common_funcs.c
index 3962f272ee..5c9b9f0f3d 100644
--- a/src/bin/eolian/common_funcs.c
+++ b/src/bin/eolian/common_funcs.c
@@ -1,5 +1,7 @@
1#include "common_funcs.h" 1#include "common_funcs.h"
2 2
3int _eolian_gen_log_dom = -1;
4
3void 5void
4_template_fill(Eina_Strbuf *buf, const char* templ, const char* classname, const char *funcname, Eina_Bool reset) 6_template_fill(Eina_Strbuf *buf, const char* templ, const char* classname, const char *funcname, Eina_Bool reset)
5{ 7{
diff --git a/src/bin/eolian/common_funcs.h b/src/bin/eolian/common_funcs.h
index 5a777ea0ae..033e5a9aee 100644
--- a/src/bin/eolian/common_funcs.h
+++ b/src/bin/eolian/common_funcs.h
@@ -3,6 +3,33 @@
3 3
4#include <Eina.h> 4#include <Eina.h>
5 5
6extern int _eolian_gen_log_dom;
7
8#ifdef ERR
9# undef ERR
10#endif
11#define ERR(...) EINA_LOG_DOM_ERR(_eolian_gen_log_dom, __VA_ARGS__)
12
13#ifdef DBG
14# undef DBG
15#endif
16#define DBG(...) EINA_LOG_DOM_DBG(_eolian_gen_log_dom, __VA_ARGS__)
17
18#ifdef INF
19# undef INF
20#endif
21#define INF(...) EINA_LOG_DOM_INFO(_eolian_gen_log_dom, __VA_ARGS__)
22
23#ifdef WRN
24# undef WRN
25#endif
26#define WRN(...) EINA_LOG_DOM_WARN(_eolian_gen_log_dom, __VA_ARGS__)
27
28#ifdef CRIT
29# undef CRIT
30#endif
31#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_gen_log_dom, __VA_ARGS__)
32
6void _template_fill(Eina_Strbuf *buf, const char* templ, const char* classname, const char *funcname, Eina_Bool reset); 33void _template_fill(Eina_Strbuf *buf, const char* templ, const char* classname, const char *funcname, Eina_Bool reset);
7 34
8char *_nextline(char *str, unsigned int lines); 35char *_nextline(char *str, unsigned int lines);
diff --git a/src/bin/eolian/eo1_generator.h b/src/bin/eolian/eo1_generator.h
index 7a0309505b..8363529401 100644
--- a/src/bin/eolian/eo1_generator.h
+++ b/src/bin/eolian/eo1_generator.h
@@ -2,7 +2,6 @@
2#define EO1_GENERATOR_H 2#define EO1_GENERATOR_H
3 3
4#include<Eina.h> 4#include<Eina.h>
5#include "eolian_database.h"
6 5
7/* 6/*
8 * @brief Generate beginning of Eo1 source code for Eo class 7 * @brief Generate beginning of Eo1 source code for Eo class
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index 49e826e8b6..736d9924d2 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -6,6 +6,7 @@
6#include "Eolian.h" 6#include "Eolian.h"
7#include "legacy_generator.h" 7#include "legacy_generator.h"
8#include "eo1_generator.h" 8#include "eo1_generator.h"
9#include "common_funcs.h"
9 10
10#define EO_SUFFIX ".eo" 11#define EO_SUFFIX ".eo"
11 12
@@ -146,6 +147,17 @@ end:
146 return ret; 147 return ret;
147} 148}
148 149
150enum
151{
152 NO_WAY_GEN,
153 H_GEN,
154 C_GEN,
155 H_EO_APP,
156 H_LEG_APP,
157 H_LEG_EO_GEN
158};
159int gen_opt = NO_WAY_GEN;
160
149int main(int argc, char **argv) 161int main(int argc, char **argv)
150{ 162{
151 int ret = 1; 163 int ret = 1;
@@ -153,15 +165,23 @@ int main(int argc, char **argv)
153 Eina_List *included_files = NULL, *itr; 165 Eina_List *included_files = NULL, *itr;
154 Eina_List *files4gen = NULL; 166 Eina_List *files4gen = NULL;
155 const char *classname; 167 const char *classname;
156 char *h_filename = NULL, *c_filename = NULL, 168 char *output_filename = NULL; /* if NULL, have to generate, otherwise use the name stored there */
157 *leg_filename = NULL, *eoleg_filename = NULL;
158
159 Eina_Bool happend = EINA_FALSE;
160 Eina_Bool lappend = EINA_FALSE;
161 169
162 eina_init(); 170 eina_init();
163 eolian_init(); 171 eolian_init();
164 172
173 const char *log_dom = "eolian_gen";
174 _eolian_gen_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_GREEN);
175 if (_eolian_gen_log_dom < 0)
176 {
177 EINA_LOG_ERR("Could not register log domain: %s", log_dom);
178 goto end;
179 }
180
181 eina_log_timing(_eolian_gen_log_dom,
182 EINA_LOG_STATE_STOP,
183 EINA_LOG_STATE_INIT);
184
165 static struct option long_options[] = 185 static struct option long_options[] =
166 { 186 {
167 /* These options set a flag. */ 187 /* These options set a flag. */
@@ -169,12 +189,13 @@ int main(int argc, char **argv)
169 {"eo2", no_argument, &eo_version, 2}, 189 {"eo2", no_argument, &eo_version, 2},
170 {"verbose", no_argument, 0, 'v'}, 190 {"verbose", no_argument, 0, 'v'},
171 {"help", no_argument, 0, 'h'}, 191 {"help", no_argument, 0, 'h'},
172 {"gh", required_argument, 0, 1}, 192 {"gh", no_argument, &gen_opt, H_GEN},
173 {"gc", required_argument, 0, 2}, 193 {"gc", no_argument, &gen_opt, C_GEN},
174 {"ah", required_argument, 0, 3}, 194 {"ah", no_argument, &gen_opt, H_EO_APP},
175 {"al", required_argument, 0, 4}, 195 {"al", no_argument, &gen_opt, H_LEG_APP},
176 {"gle", required_argument, 0, 5}, 196 {"gle", no_argument, &gen_opt, H_LEG_EO_GEN},
177 {"legacy", no_argument, 0, 6}, 197 {"output", required_argument, 0, 'o'},
198 {"legacy", no_argument, (int *)&legacy_support, EINA_TRUE},
178 {"include", required_argument, 0, 'I'}, 199 {"include", required_argument, 0, 'I'},
179 {0, 0, 0, 0} 200 {0, 0, 0, 0}
180 }; 201 };
@@ -183,12 +204,11 @@ int main(int argc, char **argv)
183 { 204 {
184 switch (opt) { 205 switch (opt) {
185 case 0: break; 206 case 0: break;
186 case 1: h_filename = optarg; break; 207 case 'o':
187 case 2: c_filename = optarg; break; 208 {
188 case 3: h_filename = optarg; happend = EINA_TRUE; break; 209 output_filename = strdup(optarg);
189 case 4: leg_filename = optarg; lappend = EINA_TRUE; break; 210 break;
190 case 5: eoleg_filename = optarg; break; 211 }
191 case 6: legacy_support = EINA_TRUE; break;
192 case 'v': show = EINA_TRUE; break; 212 case 'v': show = EINA_TRUE; break;
193 case 'h': help = EINA_TRUE; break; 213 case 'h': help = EINA_TRUE; break;
194 case 'I': 214 case 'I':
@@ -223,7 +243,10 @@ int main(int argc, char **argv)
223 243
224 if (help) 244 if (help)
225 { 245 {
226 printf("Usage: %s [-h/--help] [-v/--verbose] [-I/--include input_dir] [--legacy] [--gh|--gc|--ah filename] eo_file... \n", argv[0]); 246 printf("Usage: %s [-h/--help] [-v/--verbose] [-I/--include input_dir] [--legacy] [--gh|--gc|--ah] [--output/-o outfile] file.eo ... \n", argv[0]);
247 printf(" --help/-h Print that help\n");
248 printf(" --include/-I Include 'input_dir' as directory to search .eo files into\n");
249 printf(" --output/-o Force output filename to 'outfile'\n");
227 printf(" --eo1/--eo2 Set generator to eo1/eo2 mode. Must be specified\n"); 250 printf(" --eo1/--eo2 Set generator to eo1/eo2 mode. Must be specified\n");
228 printf(" --gh Generate c header file [.h]\n"); 251 printf(" --gh Generate c header file [.h]\n");
229 printf(" --gc Generate c source file [.c]\n"); 252 printf(" --gc Generate c source file [.c]\n");
@@ -277,33 +300,47 @@ int main(int argc, char **argv)
277 300
278 classname = eolian_class_find_by_file(eina_list_data_get(files4gen)); 301 classname = eolian_class_find_by_file(eina_list_data_get(files4gen));
279 302
280 if (h_filename) 303 if (gen_opt)
281 {
282 printf("%s header file %s\n", (happend) ? "Appending" : "Generating", h_filename);
283 _generate_h_file(h_filename, classname, happend);
284 }
285
286 if (c_filename)
287 { 304 {
288 printf("Generating source file %s\n", c_filename); 305 if (!output_filename)
289 const char *cname;
290 EINA_LIST_FOREACH(files4gen, itr, filename)
291 { 306 {
292 cname = eolian_class_find_by_file(filename); 307 output_filename = malloc(strlen(eina_list_data_get(files4gen)) + 5);
293 _generate_c_file(c_filename, cname, (files4gen != itr)); 308 strcpy(output_filename, eina_list_data_get(files4gen));
309 if (C_GEN == gen_opt) strcat(output_filename, ".c");
310 else strcat(output_filename, ".h");
294 } 311 }
295 } 312 switch (gen_opt)
296 313 {
297 if (leg_filename) 314 case H_GEN: case H_EO_APP:
298 { 315 {
299 printf("%s legacy file %s\n", (lappend) ? "Appending" : "Generating", leg_filename); 316 INF("%s header file %s\n", (gen_opt == H_EO_APP) ? "Appending" : "Generating", output_filename);
300 _generate_legacy_header_file(leg_filename, classname, lappend); 317 _generate_h_file(output_filename, classname, gen_opt == H_EO_APP);
301 } 318 break;
302 319 }
303 if (eoleg_filename) 320 case H_LEG_APP:
304 { 321 {
305 printf("Generating eo and legacy header file %s\n", eoleg_filename); 322 INF("Appending legacy file %s\n", output_filename);
306 _generate_eo_and_legacy_h_file(eoleg_filename, classname); 323 _generate_legacy_header_file(output_filename, classname, EINA_TRUE);
324 break;
325 }
326 case H_LEG_EO_GEN:
327 {
328 INF("Generating eo and legacy header file %s\n", output_filename);
329 _generate_eo_and_legacy_h_file(output_filename, classname);
330 break;
331 }
332 case C_GEN:
333 {
334 INF("Generating source file %s\n", output_filename);
335 _generate_c_file(output_filename, classname, EINA_FALSE);
336 break;
337 }
338 default:
339 free(output_filename);
340 printf("Bad generation option\n");
341 goto end;
342 }
343 free(output_filename);
307 } 344 }
308 345
309 ret = 0; 346 ret = 0;
@@ -311,6 +348,13 @@ end:
311 EINA_LIST_FREE(included_files, filename) 348 EINA_LIST_FREE(included_files, filename)
312 free((char *)filename); 349 free((char *)filename);
313 eina_list_free(files4gen); 350 eina_list_free(files4gen);
351
352 eina_log_timing(_eolian_gen_log_dom,
353 EINA_LOG_STATE_START,
354 EINA_LOG_STATE_SHUTDOWN);
355 eina_log_domain_unregister(_eolian_gen_log_dom);
356 _eolian_gen_log_dom = -1;
357
314 eolian_shutdown(); 358 eolian_shutdown();
315 eina_shutdown(); 359 eina_shutdown();
316 return ret; 360 return ret;