2012-05-02 Cedric Bail
* Doing less allocation and reuse Evas_Map does help.
+
+2012-05-08 Cedric Bail
+
+ * Add edje_watch tools to automatically rebuild edc.
Changes since Edje 1.2.0:
-------------------------
+Additions:
+ * Add edje_watch to monitore change on edje source.
+
Improvements:
* Allocate once and reuse Evas_Map.
EFL_ENABLE_BIN([edje-player])
EFL_ENABLE_BIN([edje-inspector])
EFL_ENABLE_BIN([edje-external-inspector])
+EFL_ENABLE_BIN([edje-watch])
# Optional EDJE_PROGRAM_CACHE (use much more ram, but increase speed in some cases)
want_edje_program_cache="no"
],
[have_ecore_imf="no"])
+have_eio="no"
+PKG_CHECK_MODULES([EIO],
+ [
+ eio >= 1.0.0
+ ],
+ [
+ AC_DEFINE([HAVE_EIO], [1], [Eio is available for monitoring file assynchronously])
+ have_eio="yes"
+ requirement_edje="eio >= 1.0.0 ${requirement_edje}"
+ ],
+ [have_eio="no"])
+
# Enable Multisense use
want_multisense="yes"
AC_ARG_ENABLE([multisense],
PKG_CHECK_MODULES([EDJE_EXTERNAL_INSPECTOR], [ecore >= 1.2.0 evas >= 1.2.0 eina >= 1.2.0])
fi
+if test "x$have_edje_watch" = "xyes"; then
+ PKG_CHECK_MODULES([EDJE_WATCH], [ecore >= 1.2.0 eina >= 1.2.0 eio >= 1.0.0])
+fi
### Checks for header files
AC_CHECK_HEADERS([locale.h sys/resource.h])
echo " Build edje_player............: $have_edje_player"
echo " Build edje_inspector.........: $have_edje_inspector"
echo " Build edje_external_inspector: $have_edje_external_inspector"
+echo " Build edje_watch.............: $have_edje_watch"
echo
echo "Compilation............: make (or gmake)"
echo " CPPFLAGS.............: $CPPFLAGS"
bin_SCRIPTS = @EDJE_RECC_PRG@
-bin_PROGRAMS = @EDJE_CC_PRG@ @EDJE_DECC_PRG@ @EDJE_PLAYER_PRG@ @EDJE_INSPECTOR_PRG@ @EDJE_EXTERNAL_INSPECTOR_PRG@
+bin_PROGRAMS = @EDJE_CC_PRG@ @EDJE_DECC_PRG@ @EDJE_PLAYER_PRG@ @EDJE_INSPECTOR_PRG@ @EDJE_EXTERNAL_INSPECTOR_PRG@ @EDJE_WATCH_PRG@
-EXTRA_PROGRAMS = edje_cc edje_decc edje_player edje_inspector edje_external_inspector
+EXTRA_PROGRAMS = edje_cc edje_decc edje_player edje_inspector edje_external_inspector edje_watch
edje_cc_SOURCES = \
edje_cc.c \
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
-DEPP_DIR=\"$(libdir)/$(PACKAGE)/utils\" \
-@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EVIL_CFLAGS@ @SNDFILE_CFLAGS@
+@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EIO_CFLAGS@ @EVIL_CFLAGS@ @SNDFILE_CFLAGS@
edje_cc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_CC_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ -lm
edje_cc_LDFLAGS = @lt_enable_auto_import@
+edje_watch_SOURCES = \
+edje_watch.c
+
+edje_watch_CPPFLAGS = \
+-I$(top_srcdir)/src/bin \
+-I$(top_srcdir)/src/lib \
+-DPACKAGE_BIN_DIR=\"$(bindir)\" \
+@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EIO_CFLAGS@ @EVIL_CFLAGS@ @EDJE_WATCH_CFLAGS@
+edje_watch_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_WATCH_LIBS@
+edje_watch_LDFLAGS = @lt_enable_auto_import@
edje_decc_SOURCES = \
edje_decc.c \
edje_decc_CPPFLAGS = \
-I$(top_srcdir)/src/bin \
-I$(top_srcdir)/src/lib \
-@EDJE_CFLAGS@ @EDJE_DECC_CFLAGS@ @EVIL_CFLAGS@
+@EDJE_CFLAGS@ @EDJE_DECC_CFLAGS@ @EIO_CFLAGS@ @EVIL_CFLAGS@
edje_decc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_DECC_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
edje_decc_LDFLAGS = @lt_enable_auto_import@
edje_player_CPPFLAGS = \
-I$(top_srcdir)/src/bin \
-I$(top_srcdir)/src/lib \
-@EDJE_PLAYER_CFLAGS@ @EVIL_CFLAGS@
+@EDJE_PLAYER_CFLAGS@ @EVIL_CFLAGS@ @EIO_CFLAGS@
edje_player_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_PLAYER_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
edje_player_LDFLAGS = @lt_enable_auto_import@
edje_inspector_CPPFLAGS = \
-I$(top_srcdir)/src/bin \
-I$(top_srcdir)/src/lib \
-@EDJE_INSPECTOR_CFLAGS@
+@EDJE_INSPECTOR_CFLAGS@ @EIO_CFLAGS@
edje_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@
edje_inspector_LDFLAGS = @lt_enable_auto_import@
edje_external_inspector_CPPFLAGS = \
-I$(top_srcdir)/src/bin \
-I$(top_srcdir)/src/lib \
-@EDJE_EXTERNAL_INSPECTOR_CFLAGS@
+@EDJE_EXTERNAL_INSPECTOR_CFLAGS@ @EIO_CFLAGS@
edje_external_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_EXTERNAL_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@
edje_external_inspector_LDFLAGS = @lt_enable_auto_import@
char *tmp_dir = NULL;
char *file_out = NULL;
char *progname = NULL;
+char *watchfile = NULL;
int verbose = 0;
int no_lossy = 0;
"\n"
"Where OPTIONS is one or more of:\n"
"\n"
+ "-w files.txt Dump all sources files path into files.txt\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"
i++;
file_out = argv[i];
}
+ else if ((!strcmp(argv[i], "-w")) && (i < (argc - 1)))
+ {
+ i++;
+ watchfile = argv[i];
+ unlink(watchfile);
+ }
else if (!file_in)
file_in = argv[i];
else if (!file_out)
char *mem_strdup(const char *s);
#define SZ sizeof
+void using_file(const char *filename);
+
void error_and_abort(Eet_File *ef, const char *fmt, ...);
/* global vars */
extern char *tmp_dir;
extern char *file_out;
extern char *progname;
+extern char *watchfile;
extern int verbose;
extern int no_lossy;
extern int no_comp;
{
long pos;
+ using_file(fn->file);
fseek(f, 0, SEEK_END);
pos = ftell(f);
rewind(f);
{
long pos;
+ using_file(buf);
fseek(f, 0, SEEK_END);
pos = ftell(f);
rewind(f);
evas_object_image_file_set(im, buf, NULL);
load_err = evas_object_image_load_error_get(im);
if (load_err == EVAS_LOAD_ERROR_NONE)
- break;
+ {
+ using_file(buf);
+ break;
+ }
evas_object_del(im);
im = NULL;
if (load_err != EVAS_LOAD_ERROR_DOES_NOT_EXIST)
evas_object_del(im);
im = NULL;
}
+ if (im) using_file(img->entry);
}
}
if (im)
stat(enc_info->file, &st);
size = st.st_size;
fp = fopen(enc_info->file, "rb");
+ if (fp) using_file(enc_info->file);
#else
fp = fopen(snd_path, "rb");
+ if (fp) using_file(snd_path);
#endif
if (!fp)
{
strncpy(cl->ptr, buf, n);
}
}
+
+void
+using_file(const char *filename)
+{
+ FILE *f;
+
+ f = fopen(watchfile, "a");
+ if (!f) return ;
+ fputs(filename, f);
+ fputc('\n', f);
+ fclose(f);
+}
eina_prefix_lib_get(pfx));
if (ecore_file_exists(buf2))
{
- snprintf(buf, sizeof(buf), "%s %s -I%s %s -o %s",
- buf2, file_in, inc, def, tmpn);
+ 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
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <Eina.h>
+#include <Ecore.h>
+#include <Eio.h>
+#ifdef HAVE_EVIL
+# include <Evil.h>
+#endif
+
+char watchfile[PATH_MAX];
+char *edje_cc_command = NULL;
+Eina_List *watching = NULL;
+Ecore_Timer *timeout = NULL;
+
+static void
+read_watch_file(const char *file)
+{
+ Eina_File *f;
+ Eina_Iterator *it;
+ Eina_File_Lines *ln;
+ Eio_Monitor *mon;
+ Eina_List *r = NULL;
+
+ f = eina_file_open(file, EINA_FALSE);
+ if (!f) return ;
+
+ it = eina_file_map_lines(f);
+ if (!it) goto err;
+
+ EINA_ITERATOR_FOREACH(it, ln)
+ {
+ const char *path;
+
+ path = eina_stringshare_add_length(ln->line.start, ln->length);
+ r = eina_list_append(r, eio_monitor_add(path));
+ eina_stringshare_del(path);
+ }
+ eina_iterator_free(it);
+
+ EINA_LIST_FREE(watching, mon)
+ eio_monitor_del(mon);
+ watching = r;
+
+ err:
+ eina_file_close(f);
+}
+
+Eina_Bool
+rebuild(void *data __UNUSED__)
+{
+ fprintf(stderr, "SYSTEM('%s')\n", edje_cc_command);
+ if (system(edje_cc_command) == 0)
+ read_watch_file(watchfile);
+ fprintf(stderr, "DONE\n");
+
+ timeout = NULL;
+ return EINA_FALSE;
+}
+
+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);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+int
+main(int argc, char **argv)
+{
+ char *watchout;
+ Eina_Strbuf *buf;
+ int tfd;
+ int i;
+
+ eina_init();
+ ecore_init();
+ 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);
+ ecore_event_handler_add(EIO_MONITOR_FILE_CLOSED, some_change, NULL);
+
+#ifdef HAVE_EVIL
+ watchout = (char *)evil_tmpdir_get();
+#else
+ watchout = "/tmp";
+#endif
+
+ snprintf(watchfile, PATH_MAX, "%s/edje_watch-tmp-XXXXXX", watchout);
+
+ tfd = mkstemp(watchfile);
+ if (tfd < 0) return -1;
+ close(tfd);
+
+ buf = eina_strbuf_new();
+ if (!buf) return -1;
+
+ eina_strbuf_append_printf(buf, "%s/edje_cc -w %s ", PACKAGE_BIN_DIR, watchfile);
+ for (i = 1; i < argc; ++i)
+ eina_strbuf_append_printf(buf, "%s ", argv[i]);
+
+ edje_cc_command = eina_strbuf_string_steal(buf);
+
+ eina_strbuf_free(buf);
+
+ fprintf(stderr, "SYSTEM('%s')\n", edje_cc_command);
+ system(edje_cc_command);
+ read_watch_file(watchfile);
+
+ ecore_main_loop_begin();
+
+ eio_shutdown();
+ ecore_shutdown();
+ eina_shutdown();
+
+ return 1;
+}
&& !strncmp(searchptr->fname, filename, p - filename))
{
/* FILENAME is in SEARCHPTR, which we've already checked. */
+ using_file(filename);
return open(filename, O_RDONLY | O_BINARY, 0666);
}
if (p == filename)
}
for (map = read_name_map(pfile, dir); map; map = map->map_next)
if (!strcmp(map->map_from, from))
- return open(map->map_to, O_RDONLY | O_BINARY, 0666);
+ {
+ using_file(map->map_to);
+ return open(map->map_to, O_RDONLY | O_BINARY, 0666);
+ }
+ using_file(filename);
return open(filename, O_RDONLY | O_BINARY, 0666);
}
open_include_file(cpp_reader * pfile __UNUSED__, char *filename,
file_name_list * searchptr __UNUSED__)
{
+ using_file(filename);
return open(filename, O_RDONLY | O_BINARY, 0666);
}
i++, push_pending(pfile, "-D", argv[i]);
break;
+ case 'a':
+ {
+ if (!strcmp(argv[i], "-a"))
+ {
+ if (i + 1 == argc)
+ cpp_fatal("Filename missing after `-a` option");
+ else if (strcmp(argv[++i], "/dev/null"))
+ {
+ opts->watchfile = argv[i];
+ }
+ }
+ break;
+ }
+
case 'A':
{
char *p = NULL;
*
* Support for_lint flag.
*/
+
+extern cpp_options options;
+
+void
+using_file(const char *filename)
+{
+ FILE *f;
+
+ f = fopen(options.watchfile, "a");
+ if (!f) return ;
+ fputs(filename, f);
+ fputc('\n', f);
+ fclose(f);
+}
/* Target-name to write with the dependency information. */
char *deps_target;
+
+ /* Target file to write all include file */
+ const char *watchfile;
};
#define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional)
void *xrealloc(void *old, unsigned size);
void *xcalloc(unsigned number, unsigned size);
+void using_file(const char *filename);
+
#ifdef __EMX__
#define PATH_SEPARATOR ';'
#endif