From 8ad4e0c02e9b95580a6ea9d7e3171a04cc3c608d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Tue, 4 Sep 2012 02:13:05 +0000 Subject: [PATCH] edje: report type of file when listing files used by an edc. SVN revision: 76095 --- legacy/edje/ChangeLog | 4 ++++ legacy/edje/NEWS | 1 + legacy/edje/src/bin/edje_cc.c | 9 ++++++++- legacy/edje/src/bin/edje_cc.h | 3 ++- legacy/edje/src/bin/edje_cc_out.c | 25 ++++++++++++++++--------- legacy/edje/src/bin/edje_cc_parse.c | 8 ++++++-- legacy/edje/src/bin/edje_watch.c | 18 +++++++++--------- legacy/edje/src/bin/epp/cpplib.c | 27 ++++++++++++++++++++------- legacy/edje/src/bin/epp/cpplib.h | 2 +- 9 files changed, 67 insertions(+), 30 deletions(-) diff --git a/legacy/edje/ChangeLog b/legacy/edje/ChangeLog index a900a0897f..65d03a2421 100644 --- a/legacy/edje/ChangeLog +++ b/legacy/edje/ChangeLog @@ -581,3 +581,7 @@ 2012-08-30 Cedric Bail * Check the number of parameter for image in edc. + +2012-09-04 Cedric Bail + + * Report type of file when listing file used by an edc. diff --git a/legacy/edje/NEWS b/legacy/edje/NEWS index ae9b9e5500..ed3389cb68 100644 --- a/legacy/edje/NEWS +++ b/legacy/edje/NEWS @@ -4,6 +4,7 @@ Changes since Edje 1.8.0: ------------------------- Additions: + * Report type of file when listing file used by an edc. Improvements: * Check the number of parameter for image in edc. diff --git a/legacy/edje/src/bin/edje_cc.c b/legacy/edje/src/bin/edje_cc.c index 960d83161e..b8ca86b3a7 100644 --- a/legacy/edje/src/bin/edje_cc.c +++ b/legacy/edje/src/bin/edje_cc.c @@ -31,6 +31,7 @@ int min_quality = 0; int max_quality = 100; int compress_mode = EET_COMPRESSION_DEFAULT; int threads = 0; +int anotate = 0; static void _edje_cc_log_cb(const Eina_Log_Domain *d, @@ -82,6 +83,7 @@ main_help(void) "Where OPTIONS is one or more of:\n" "\n" "-w files.txt Dump all sources files path into files.txt\n" + "-anotate Anotate the dumped files.\n" "-id image/directory Add a directory to look in for relative path images\n" "-fd font/directory Add a directory to look in for relative path fonts\n" "-sd sound/directory Add a directory to look in for relative path sounds samples\n" @@ -226,6 +228,10 @@ main(int argc, char **argv) watchfile = argv[i]; unlink(watchfile); } + else if (!strcmp(argv[i], "-anotate")) + { + anotate = 1; + } else if (!file_in) file_in = argv[i]; else if (!file_out) @@ -296,7 +302,8 @@ main(int argc, char **argv) exit(-1); } - using_file(file_in); + using_file(file_in, 'E'); + if (anotate) using_file(file_out, 'O'); if (!edje_init()) exit(-1); diff --git a/legacy/edje/src/bin/edje_cc.h b/legacy/edje/src/bin/edje_cc.h index d9468b6bcf..2001b904fb 100644 --- a/legacy/edje/src/bin/edje_cc.h +++ b/legacy/edje/src/bin/edje_cc.h @@ -202,7 +202,7 @@ void *mem_alloc(size_t size); char *mem_strdup(const char *s); #define SZ sizeof -void using_file(const char *filename); +void using_file(const char *filename, const char type); void error_and_abort(Eet_File *ef, const char *fmt, ...); @@ -235,5 +235,6 @@ extern New_Object_Handler object_handlers[]; extern New_Statement_Handler statement_handlers[]; extern int compress_mode; extern int threads; +extern int anotate; #endif diff --git a/legacy/edje/src/bin/edje_cc_out.c b/legacy/edje/src/bin/edje_cc_out.c index 9d327b1c77..ea8b07fade 100644 --- a/legacy/edje/src/bin/edje_cc_out.c +++ b/legacy/edje/src/bin/edje_cc_out.c @@ -425,7 +425,7 @@ data_thread_fonts(void *data, Ecore_Thread *thread __UNUSED__) f = eina_file_open(fc->fn->file, 0); if (f) { - using_file(fc->fn->file); + using_file(fc->fn->file, 'F'); m = eina_file_map_all(f, EINA_FILE_SEQUENTIAL); } else @@ -438,7 +438,7 @@ data_thread_fonts(void *data, Ecore_Thread *thread __UNUSED__) f = eina_file_open(buf, 0); if (f) { - using_file(buf); + using_file(buf, 'F'); m = eina_file_map_all(f, EINA_FILE_SEQUENTIAL); if (m) break; eina_file_close(f); @@ -805,7 +805,7 @@ data_write_images(Eet_File *ef, int *image_num) pending_threads++; if (threads) evas_object_image_preload(im, 0); - using_file(buf); + using_file(buf, 'I'); if (!threads) data_image_preload_done(iw, evas, im, NULL); break; @@ -822,7 +822,7 @@ data_write_images(Eet_File *ef, int *image_num) pending_threads++; if (threads) evas_object_image_preload(im, 0); - using_file(img->entry); + using_file(img->entry, 'I'); if (!threads) data_image_preload_done(iw, evas, im, NULL); } @@ -868,9 +868,9 @@ data_thread_sounds(void *data, Ecore_Thread *thread __UNUSED__) enc_info = _edje_multisense_encode(snd_path, sw->sample, sw->sample->quality); f = eina_file_open(enc_info->file, 0); - if (f) using_file(enc_info->file); + if (f) using_file(enc_info->file, 'S'); #else - if (f) using_file(snd_path); + if (f) using_file(snd_path, 'S'); #endif if (!f) { @@ -2569,14 +2569,21 @@ data_process_script_lookups(void) } void -using_file(const char *filename) +using_file(const char *filename, const char type) { FILE *f; if (!watchfile) return; f = fopen(watchfile, "ab"); if (!f) return ; - fputs(filename, f); - fputc('\n', f); + if (anotate) + { + fprintf(f, "%c: %s\n", type, filename); + } + else + { + fputs(filename, f); + fputc('\n', f); + } fclose(f); } diff --git a/legacy/edje/src/bin/edje_cc_parse.c b/legacy/edje/src/bin/edje_cc_parse.c index d315790fbe..b327752f25 100644 --- a/legacy/edje/src/bin/edje_cc_parse.c +++ b/legacy/edje/src/bin/edje_cc_parse.c @@ -738,8 +738,12 @@ compile(void) eina_prefix_lib_get(pfx)); if (ecore_file_exists(buf2)) { - snprintf(buf, sizeof(buf), "%s -a %s %s -I%s %s -o %s", - buf2, watchfile ? watchfile : "/dev/null", file_in, inc, def, tmpn); + if (anotate) + snprintf(buf, sizeof(buf), "%s -anotate -a %s %s -I%s %s -o %s", + buf2, watchfile ? watchfile : "/dev/null", file_in, inc, def, tmpn); + else + snprintf(buf, sizeof(buf), "%s -a %s %s -I%s %s -o %s", + buf2, watchfile ? watchfile : "/dev/null", file_in, inc, def, tmpn); ret = system(buf); } else diff --git a/legacy/edje/src/bin/edje_watch.c b/legacy/edje/src/bin/edje_watch.c index 01033b6439..cb37cc76b1 100644 --- a/legacy/edje/src/bin/edje_watch.c +++ b/legacy/edje/src/bin/edje_watch.c @@ -33,8 +33,11 @@ read_watch_file(const char *file) { const char *path; - path = eina_stringshare_add_length(ln->start, ln->length); - r = eina_list_append(r, eio_monitor_add(path)); + if (ln->length < 4) continue ; + path = eina_stringshare_add_length(ln->start + 3, ln->length); + fprintf(stderr, "%c: %s\n", *ln->start, path); + if (*ln->start != 'O') + r = eina_list_append(r, eio_monitor_add(path)); eina_stringshare_del(path); } eina_iterator_free(it); @@ -53,11 +56,11 @@ rebuild(void *data __UNUSED__) double start, end; start = ecore_time_get(); - fprintf(stderr, "SYSTEM('%s')\n", edje_cc_command); + fprintf(stderr, "* SYSTEM('%s')\n", edje_cc_command); if (system(edje_cc_command) == 0) read_watch_file(watchfile); end = ecore_time_get(); - fprintf(stderr, "DONE IN %f\n", end - start); + fprintf(stderr, "* DONE IN %f\n", end - start); timeout = NULL; return EINA_FALSE; @@ -66,9 +69,6 @@ rebuild(void *data __UNUSED__) Eina_Bool some_change(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) { - Eio_Monitor_Event *ev = event; - - fprintf(stderr, "EVENT %i on [%s]\n", type, ev->filename); if (timeout) ecore_timer_del(timeout); timeout = ecore_timer_add(0.5, rebuild, NULL); @@ -89,7 +89,7 @@ main(int argc, char **argv) eio_init(); if (argc < 2) return -1; - + ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, some_change, NULL); ecore_event_handler_add(EIO_MONITOR_FILE_CREATED, some_change, NULL); ecore_event_handler_add(EIO_MONITOR_FILE_DELETED, some_change, NULL); @@ -110,7 +110,7 @@ main(int argc, char **argv) buf = eina_strbuf_new(); if (!buf) return -1; - eina_strbuf_append_printf(buf, "%s/edje_cc -threads -fastcomp -w %s ", PACKAGE_BIN_DIR, watchfile); + eina_strbuf_append_printf(buf, "%s/edje_cc -anotate -threads -fastcomp -w %s ", PACKAGE_BIN_DIR, watchfile); for (i = 1; i < argc; ++i) eina_strbuf_append_printf(buf, "%s ", argv[i]); diff --git a/legacy/edje/src/bin/epp/cpplib.c b/legacy/edje/src/bin/epp/cpplib.c index 30c7f0182a..2d8b266ddd 100644 --- a/legacy/edje/src/bin/epp/cpplib.c +++ b/legacy/edje/src/bin/epp/cpplib.c @@ -513,6 +513,8 @@ unsigned char is_hor_space[256]; /* table to tell if c is horizontal or vertical space. */ static unsigned char is_space[256]; +static int anotate = 0; + /* Initialize syntactic classifications of characters. */ static void @@ -5489,7 +5491,7 @@ open_include_file(cpp_reader * pfile, char *filename, && !strncmp(searchptr->fname, filename, p - filename)) { /* FILENAME is in SEARCHPTR, which we've already checked. */ - using_file(filename); + using_file(filename, 'E'); return open(filename, O_RDONLY | O_BINARY, 0666); } if (p == filename) @@ -5510,11 +5512,11 @@ open_include_file(cpp_reader * pfile, char *filename, for (map = read_name_map(pfile, dir); map; map = map->map_next) if (!strcmp(map->map_from, from)) { - using_file(map->map_to); + using_file(map->map_to, 'E'); return open(map->map_to, O_RDONLY | O_BINARY, 0666); } - using_file(filename); + using_file(filename, 'E'); return open(filename, O_RDONLY | O_BINARY, 0666); } @@ -5524,7 +5526,7 @@ static int open_include_file(cpp_reader * pfile __UNUSED__, char *filename, file_name_list * searchptr __UNUSED__) { - using_file(filename); + using_file(filename, 'E'); return open(filename, O_RDONLY | O_BINARY, 0666); } @@ -6578,6 +6580,10 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv) opts->watchfile = argv[i]; } } + else if (!strcmp(argv[i], "-anotate")) + { + anotate = 1; + } break; } @@ -7449,13 +7455,20 @@ cpp_perror_with_name(cpp_reader * pfile, const char *name) extern cpp_options options; void -using_file(const char *filename) +using_file(const char *filename, const char type) { FILE *f; f = fopen(options.watchfile, "a"); if (!f) return ; - fputs(filename, f); - fputc('\n', f); + if (anotate) + { + fprintf(f, "%c: %s\n", type, filename); + } + else + { + fputs(filename, f); + fputc('\n', f); + } fclose(f); } diff --git a/legacy/edje/src/bin/epp/cpplib.h b/legacy/edje/src/bin/epp/cpplib.h index a34a7652bb..310c424486 100644 --- a/legacy/edje/src/bin/epp/cpplib.h +++ b/legacy/edje/src/bin/epp/cpplib.h @@ -639,7 +639,7 @@ void *xmalloc(unsigned size); void *xrealloc(void *old, unsigned size); void *xcalloc(unsigned number, unsigned size); -void using_file(const char *filename); +void using_file(const char *filename, const char type); #ifdef __EMX__ #define PATH_SEPARATOR ';'