edje decompiling works now! you can decompile an edje .eet back into source
files (.edc's, fonts and images) and it will even make a handy build/sh to rebuild the .edc into the original .eet again! :) NB: only works on .et's created with this edje_cc or newer as i needed to incpude some extra debug info :) SVN revision: 11431
This commit is contained in:
parent
52a6615758
commit
5b7136d3f8
|
@ -121,13 +121,17 @@ fi
|
||||||
AC_SUBST(edje_def)
|
AC_SUBST(edje_def)
|
||||||
|
|
||||||
EDJE_CC_PRG=""
|
EDJE_CC_PRG=""
|
||||||
|
EDJE_DECC_PRG=""
|
||||||
if test "x$have_edje_cc" = "xyes"; then
|
if test "x$have_edje_cc" = "xyes"; then
|
||||||
AM_CONDITIONAL(BUILD_EDJE_CC, true)
|
AM_CONDITIONAL(BUILD_EDJE_CC, true)
|
||||||
EDJE_CC_PRG="edje_cc"
|
EDJE_CC_PRG="edje_cc"
|
||||||
|
EDJE_DECC_PRG="edje_decc"
|
||||||
else
|
else
|
||||||
AM_CONDITIONAL(BUILD_EDJE_CC, false)
|
AM_CONDITIONAL(BUILD_EDJE_CC, false)
|
||||||
|
AM_CONDITIONAL(BUILD_EDJE_DECC, false)
|
||||||
fi
|
fi
|
||||||
AC_SUBST(EDJE_CC_PRG)
|
AC_SUBST(EDJE_CC_PRG)
|
||||||
|
AC_SUBST(EDJE_DECC_PRG)
|
||||||
|
|
||||||
AC_ARG_WITH(eet,
|
AC_ARG_WITH(eet,
|
||||||
[ --with-eet=DIR use eet in <DIR>],
|
[ --with-eet=DIR use eet in <DIR>],
|
||||||
|
|
|
@ -12,10 +12,12 @@ INCLUDES = \
|
||||||
bin_PROGRAMS = \
|
bin_PROGRAMS = \
|
||||||
edje \
|
edje \
|
||||||
edje_ls \
|
edje_ls \
|
||||||
@EDJE_CC_PRG@
|
@EDJE_CC_PRG@ \
|
||||||
|
@EDJE_DECC_PRG@
|
||||||
|
|
||||||
EXTRA_PROGRAMS = \
|
EXTRA_PROGRAMS = \
|
||||||
edje_cc
|
edje_cc \
|
||||||
|
edje_decc
|
||||||
|
|
||||||
edje_SOURCES = \
|
edje_SOURCES = \
|
||||||
edje_main.c \
|
edje_main.c \
|
||||||
|
@ -38,7 +40,8 @@ edje_cc.h \
|
||||||
edje_cc_out.c \
|
edje_cc_out.c \
|
||||||
edje_cc_parse.c \
|
edje_cc_parse.c \
|
||||||
edje_cc_mem.c \
|
edje_cc_mem.c \
|
||||||
edje_cc_handlers.c
|
edje_cc_handlers.c \
|
||||||
|
edje_cc_sources.c
|
||||||
|
|
||||||
edje_cc_LDADD = \
|
edje_cc_LDADD = \
|
||||||
$(top_builddir)/src/lib/libedje.la \
|
$(top_builddir)/src/lib/libedje.la \
|
||||||
|
@ -51,6 +54,24 @@ edje_cc_LDFLAGS =
|
||||||
edje_cc_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la
|
edje_cc_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la
|
||||||
|
|
||||||
|
|
||||||
|
edje_decc_SOURCES = \
|
||||||
|
edje_decc.c \
|
||||||
|
edje_decc.h \
|
||||||
|
edje_cc_mem.c \
|
||||||
|
edje_cc_sources.c
|
||||||
|
|
||||||
|
edje_decc_LDADD = \
|
||||||
|
$(top_builddir)/src/lib/libedje.la \
|
||||||
|
@imlib2_libs@
|
||||||
|
|
||||||
|
edje_decc_CPPFLAGS = @edje_def@
|
||||||
|
|
||||||
|
edje_decc_LDFLAGS =
|
||||||
|
|
||||||
|
edje_decc_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
edje_ls_SOURCES = \
|
edje_ls_SOURCES = \
|
||||||
edje_ls.c
|
edje_ls.c
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,9 @@ main(int argc, char **argv)
|
||||||
edje_file = mem_alloc(SZ(Edje_File));
|
edje_file = mem_alloc(SZ(Edje_File));
|
||||||
edje_file->version = EDJE_FILE_VERSION;
|
edje_file->version = EDJE_FILE_VERSION;
|
||||||
|
|
||||||
|
source_edd();
|
||||||
|
source_fetch();
|
||||||
|
|
||||||
data_setup();
|
data_setup();
|
||||||
compile();
|
compile();
|
||||||
data_process_scripts();
|
data_process_scripts();
|
||||||
|
|
|
@ -25,9 +25,12 @@
|
||||||
/* types */
|
/* types */
|
||||||
typedef struct _New_Object_Handler New_Object_Handler;
|
typedef struct _New_Object_Handler New_Object_Handler;
|
||||||
typedef struct _New_Statement_Handler New_Statement_Handler;
|
typedef struct _New_Statement_Handler New_Statement_Handler;
|
||||||
|
typedef struct _Font_List Font_List;
|
||||||
typedef struct _Font Font;
|
typedef struct _Font Font;
|
||||||
typedef struct _Code Code;
|
typedef struct _Code Code;
|
||||||
typedef struct _Code_Program Code_Program;
|
typedef struct _Code_Program Code_Program;
|
||||||
|
typedef struct _SrcFile SrcFile;
|
||||||
|
typedef struct _SrcFile_List SrcFile_List;
|
||||||
|
|
||||||
struct _New_Object_Handler
|
struct _New_Object_Handler
|
||||||
{
|
{
|
||||||
|
@ -41,6 +44,11 @@ struct _New_Statement_Handler
|
||||||
void (*func)(void);
|
void (*func)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _Font_List
|
||||||
|
{
|
||||||
|
Evas_List *list;
|
||||||
|
};
|
||||||
|
|
||||||
struct _Font
|
struct _Font
|
||||||
{
|
{
|
||||||
char *file;
|
char *file;
|
||||||
|
@ -61,6 +69,17 @@ struct _Code_Program
|
||||||
char *script;
|
char *script;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _SrcFile
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
char *file;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _SrcFile_List
|
||||||
|
{
|
||||||
|
Evas_List *list;
|
||||||
|
};
|
||||||
|
|
||||||
/* global fn calls */
|
/* global fn calls */
|
||||||
void data_setup(void);
|
void data_setup(void);
|
||||||
void data_write(void);
|
void data_write(void);
|
||||||
|
@ -91,6 +110,13 @@ double parse_float_range(int n, double f, double t);
|
||||||
int object_handler_num(void);
|
int object_handler_num(void);
|
||||||
int statement_handler_num(void);
|
int statement_handler_num(void);
|
||||||
|
|
||||||
|
void source_edd(void);
|
||||||
|
void source_fetch(void);
|
||||||
|
int source_append(Eet_File *ef);
|
||||||
|
SrcFile_List *source_load(Eet_File *ef);
|
||||||
|
int source_fontmap_save(Eet_File *ef, Evas_List *fonts);
|
||||||
|
Font_List *source_fontmap_load(Eet_File *ef);
|
||||||
|
|
||||||
void *mem_alloc(size_t size);
|
void *mem_alloc(size_t size);
|
||||||
char *mem_strdup(const char *s);
|
char *mem_strdup(const char *s);
|
||||||
#define SZ sizeof
|
#define SZ sizeof
|
||||||
|
|
|
@ -90,6 +90,8 @@ data_write(void)
|
||||||
int bytes;
|
int bytes;
|
||||||
int input_bytes;
|
int input_bytes;
|
||||||
int total_bytes;
|
int total_bytes;
|
||||||
|
int src_bytes;
|
||||||
|
int fmap_bytes;
|
||||||
int input_raw_bytes;
|
int input_raw_bytes;
|
||||||
int image_num;
|
int image_num;
|
||||||
int font_num;
|
int font_num;
|
||||||
|
@ -99,6 +101,8 @@ data_write(void)
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
input_bytes = 0;
|
input_bytes = 0;
|
||||||
total_bytes = 0;
|
total_bytes = 0;
|
||||||
|
src_bytes = 0;
|
||||||
|
fmap_bytes = 0;
|
||||||
input_raw_bytes = 0;
|
input_raw_bytes = 0;
|
||||||
image_num = 0;
|
image_num = 0;
|
||||||
font_num = 0;
|
font_num = 0;
|
||||||
|
@ -549,6 +553,10 @@ data_write(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
src_bytes = source_append(ef);
|
||||||
|
total_bytes += src_bytes;
|
||||||
|
fmap_bytes = source_fontmap_save(ef, fonts);
|
||||||
|
total_bytes += fmap_bytes;
|
||||||
eet_close(ef);
|
eet_close(ef);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
|
@ -562,6 +570,8 @@ data_write(void)
|
||||||
" Wrote %i collections\n"
|
" Wrote %i collections\n"
|
||||||
" Wrote %i images\n"
|
" Wrote %i images\n"
|
||||||
" Wrote %i fonts\n"
|
" Wrote %i fonts\n"
|
||||||
|
" Wrote %i bytes (%iKb) of original source data\n"
|
||||||
|
" Wrote %i bytes (%iKb) of original source font map\n"
|
||||||
"Conservative compression summary:\n"
|
"Conservative compression summary:\n"
|
||||||
" Wrote total %i bytes (%iKb) from %i (%iKb) input data\n"
|
" Wrote total %i bytes (%iKb) from %i (%iKb) input data\n"
|
||||||
" Output file is %3.1f%% the size of the input data\n"
|
" Output file is %3.1f%% the size of the input data\n"
|
||||||
|
@ -574,6 +584,8 @@ data_write(void)
|
||||||
collection_num,
|
collection_num,
|
||||||
image_num,
|
image_num,
|
||||||
font_num,
|
font_num,
|
||||||
|
src_bytes, (src_bytes + 512) / 1024,
|
||||||
|
fmap_bytes, (fmap_bytes + 512) / 1024,
|
||||||
total_bytes, (total_bytes + 512) / 1024,
|
total_bytes, (total_bytes + 512) / 1024,
|
||||||
input_bytes, (input_bytes + 512) / 1024,
|
input_bytes, (input_bytes + 512) / 1024,
|
||||||
(100.0 * (double)total_bytes) / (double)input_bytes,
|
(100.0 * (double)total_bytes) / (double)input_bytes,
|
||||||
|
|
|
@ -0,0 +1,224 @@
|
||||||
|
#include "edje_cc.h"
|
||||||
|
|
||||||
|
static Eet_Data_Descriptor *_srcfile_edd = NULL;
|
||||||
|
static Eet_Data_Descriptor *_srcfile_list_edd = NULL;
|
||||||
|
|
||||||
|
static Eet_Data_Descriptor *_font_edd = NULL;
|
||||||
|
static Eet_Data_Descriptor *_font_list_edd = NULL;
|
||||||
|
|
||||||
|
static SrcFile_List srcfiles = {NULL};
|
||||||
|
|
||||||
|
void
|
||||||
|
source_edd(void)
|
||||||
|
{
|
||||||
|
_srcfile_edd = eet_data_descriptor_new("srcfile", sizeof(SrcFile),
|
||||||
|
(void *(*) (void *))evas_list_next,
|
||||||
|
(void *(*) (void *, void *))evas_list_append,
|
||||||
|
(void *(*) (void *))evas_list_data,
|
||||||
|
(void *(*) (void *))evas_list_free,
|
||||||
|
(void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach,
|
||||||
|
(void *(*) (void *, const char *, void *))evas_hash_add,
|
||||||
|
(void (*) (void *))evas_hash_free);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "name", name, EET_T_STRING);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "file", file, EET_T_STRING);
|
||||||
|
_srcfile_list_edd = eet_data_descriptor_new("srcfile_list", sizeof(SrcFile_List),
|
||||||
|
(void *(*) (void *))evas_list_next,
|
||||||
|
(void *(*) (void *, void *))evas_list_append,
|
||||||
|
(void *(*) (void *))evas_list_data,
|
||||||
|
(void *(*) (void *))evas_list_free,
|
||||||
|
(void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach,
|
||||||
|
(void *(*) (void *, const char *, void *))evas_hash_add,
|
||||||
|
(void (*) (void *))evas_hash_free);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_LIST(_srcfile_list_edd, SrcFile_List, "list", list, _srcfile_edd);
|
||||||
|
|
||||||
|
_font_edd = eet_data_descriptor_new("font", sizeof(Font),
|
||||||
|
(void *(*) (void *))evas_list_next,
|
||||||
|
(void *(*) (void *, void *))evas_list_append,
|
||||||
|
(void *(*) (void *))evas_list_data,
|
||||||
|
(void *(*) (void *))evas_list_free,
|
||||||
|
(void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach,
|
||||||
|
(void *(*) (void *, const char *, void *))evas_hash_add,
|
||||||
|
(void (*) (void *))evas_hash_free);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_font_edd, Font, "file", file, EET_T_STRING);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_font_edd, Font, "name", name, EET_T_STRING);
|
||||||
|
_font_list_edd = eet_data_descriptor_new("font_list", sizeof(Font_List),
|
||||||
|
(void *(*) (void *))evas_list_next,
|
||||||
|
(void *(*) (void *, void *))evas_list_append,
|
||||||
|
(void *(*) (void *))evas_list_data,
|
||||||
|
(void *(*) (void *))evas_list_free,
|
||||||
|
(void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach,
|
||||||
|
(void *(*) (void *, const char *, void *))evas_hash_add,
|
||||||
|
(void (*) (void *))evas_hash_free);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_LIST(_font_list_edd, Font_List, "list", list, _font_edd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
source_fetch(void)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
char buf[256 * 1024];
|
||||||
|
|
||||||
|
f = fopen(file_in, "r");
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long sz;
|
||||||
|
SrcFile *sf;
|
||||||
|
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
sz = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
sf = mem_alloc(SZ(SrcFile));
|
||||||
|
sf->name = strdup("main_edje_source.edc");
|
||||||
|
sf->file = mem_alloc(sz);
|
||||||
|
fread(sf->file, sz, 1, f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
srcfiles.list = evas_list_append(srcfiles.list, sf);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (fgets(buf, sizeof(buf), f))
|
||||||
|
{
|
||||||
|
char *p, *pp;
|
||||||
|
int notyet;
|
||||||
|
int forgetit;
|
||||||
|
int haveinclude;
|
||||||
|
int havefile;
|
||||||
|
char *file;
|
||||||
|
|
||||||
|
p = buf;
|
||||||
|
notyet = 1;
|
||||||
|
forgetit = 0;
|
||||||
|
haveinclude = 0;
|
||||||
|
havefile = 0;
|
||||||
|
file = NULL;
|
||||||
|
while ((!forgetit) && (*p))
|
||||||
|
{
|
||||||
|
if (notyet)
|
||||||
|
{
|
||||||
|
if (!isblank(*p))
|
||||||
|
{
|
||||||
|
if (*p == '#')
|
||||||
|
notyet = 0;
|
||||||
|
else
|
||||||
|
forgetit = 1;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!haveinclude)
|
||||||
|
{
|
||||||
|
if (!isblank(*p))
|
||||||
|
{
|
||||||
|
if (!strncmp(p, "include", 7))
|
||||||
|
{
|
||||||
|
haveinclude = 1;
|
||||||
|
p += 7;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
forgetit = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!havefile)
|
||||||
|
{
|
||||||
|
if (!isblank(*p))
|
||||||
|
{
|
||||||
|
if (*p == '"')
|
||||||
|
{
|
||||||
|
pp = strchr(p + 1, '"');
|
||||||
|
if (!pp)
|
||||||
|
forgetit = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file = mem_alloc(pp - p);
|
||||||
|
strncpy(file, p + 1, pp - p - 1);
|
||||||
|
file[pp - p - 1] = 0;
|
||||||
|
forgetit = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*p == '<')
|
||||||
|
{
|
||||||
|
pp = strchr(p + 1, '>');
|
||||||
|
if (!pp)
|
||||||
|
forgetit = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file = mem_alloc(pp - p);
|
||||||
|
strncpy(file, p + 1, pp - p - 1);
|
||||||
|
file[pp - p - 1] = 0;
|
||||||
|
forgetit = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
forgetit = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
FILE *ff;
|
||||||
|
|
||||||
|
ff = fopen(file, "r");
|
||||||
|
if (ff)
|
||||||
|
{
|
||||||
|
long sz;
|
||||||
|
SrcFile *sf;
|
||||||
|
|
||||||
|
fseek(ff, 0, SEEK_END);
|
||||||
|
sz = ftell(ff);
|
||||||
|
fseek(ff, 0, SEEK_SET);
|
||||||
|
sf = mem_alloc(SZ(SrcFile));
|
||||||
|
sf->name = file;
|
||||||
|
sf->file = mem_alloc(sz);
|
||||||
|
fread(sf->file, sz, 1, ff);
|
||||||
|
fclose(ff);
|
||||||
|
srcfiles.list = evas_list_append(srcfiles.list, sf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
source_append(Eet_File *ef)
|
||||||
|
{
|
||||||
|
return eet_data_write(ef, _srcfile_list_edd, "edje_sources", &srcfiles, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SrcFile_List *
|
||||||
|
source_load(Eet_File *ef)
|
||||||
|
{
|
||||||
|
SrcFile_List *s;
|
||||||
|
|
||||||
|
s = eet_data_read(ef, _srcfile_list_edd, "edje_sources");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
source_fontmap_save(Eet_File *ef, Evas_List *fonts)
|
||||||
|
{
|
||||||
|
Font_List fl;
|
||||||
|
|
||||||
|
fl.list = fonts;
|
||||||
|
return eet_data_write(ef, _font_list_edd, "edje_source_fontmap", &fl, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Font_List *
|
||||||
|
source_fontmap_load(Eet_File *ef)
|
||||||
|
{
|
||||||
|
Font_List *fl;
|
||||||
|
|
||||||
|
fl = eet_data_read(ef, _font_list_edd, "edje_source_fontmap");
|
||||||
|
return fl;
|
||||||
|
}
|
|
@ -0,0 +1,252 @@
|
||||||
|
/* ugly ugly. avert your eyes. */
|
||||||
|
#include "edje_decc.h"
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
char *progname = NULL;
|
||||||
|
char *file_in = NULL;
|
||||||
|
|
||||||
|
Edje_File *edje_file = NULL;
|
||||||
|
SrcFile_List *srcfiles = NULL;
|
||||||
|
Font_List *fontlist = NULL;
|
||||||
|
|
||||||
|
int line = 0;
|
||||||
|
|
||||||
|
int decomp(void);
|
||||||
|
void output(void);
|
||||||
|
int e_file_is_dir(char *file);
|
||||||
|
int e_file_mkdir(char *dir);
|
||||||
|
int e_file_mkpath(char *path);
|
||||||
|
|
||||||
|
static void
|
||||||
|
main_help(void)
|
||||||
|
{
|
||||||
|
printf
|
||||||
|
("Usage:\n"
|
||||||
|
"\t%s input_file.eet \n"
|
||||||
|
"\n"
|
||||||
|
,progname);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
setlocale(LC_NUMERIC, "C");
|
||||||
|
|
||||||
|
progname = argv[0];
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
if (!file_in)
|
||||||
|
file_in = argv[i];
|
||||||
|
}
|
||||||
|
if (!file_in)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: Error: no input file specified.\n", progname);
|
||||||
|
main_help();
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
edje_init();
|
||||||
|
eet_init();
|
||||||
|
source_edd();
|
||||||
|
|
||||||
|
if (!decomp()) return -1;
|
||||||
|
output();
|
||||||
|
|
||||||
|
eet_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
decomp(void)
|
||||||
|
{
|
||||||
|
Eet_File *ef;
|
||||||
|
ef = eet_open(file_in, EET_FILE_MODE_READ);
|
||||||
|
if (!ef) return 0;
|
||||||
|
|
||||||
|
srcfiles = source_load(ef);
|
||||||
|
if (!srcfiles)
|
||||||
|
{
|
||||||
|
eet_close(ef);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje_file");
|
||||||
|
fontlist = source_fontmap_load(ef);
|
||||||
|
eet_close(ef);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
output(void)
|
||||||
|
{
|
||||||
|
Evas_List *l;
|
||||||
|
Eet_File *ef;
|
||||||
|
char *outdir, *p;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
p = strrchr(file_in, '/');
|
||||||
|
if (p)
|
||||||
|
outdir = strdup(p + 1);
|
||||||
|
else
|
||||||
|
outdir = strdup(file_in);
|
||||||
|
p = strrchr(outdir, '.');
|
||||||
|
if (p) *p = 0;
|
||||||
|
|
||||||
|
e_file_mkpath(outdir);
|
||||||
|
|
||||||
|
ef = eet_open(file_in, EET_FILE_MODE_READ);
|
||||||
|
if (edje_file->image_dir)
|
||||||
|
{
|
||||||
|
for (l = edje_file->image_dir->entries; l; l = l->next)
|
||||||
|
{
|
||||||
|
Edje_Image_Directory_Entry *ei;
|
||||||
|
|
||||||
|
ei = l->data;
|
||||||
|
if ((ei->source_type) && (ei->entry))
|
||||||
|
{
|
||||||
|
DATA32 *pix;
|
||||||
|
int w, h, alpha, comp, qual, lossy;
|
||||||
|
char buf[4096];
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "images/%i", ei->id);
|
||||||
|
pix = eet_data_image_read(ef, buf, &w, &h, &alpha, &comp, &qual, &lossy);
|
||||||
|
if (pix)
|
||||||
|
{
|
||||||
|
Imlib_Image im;
|
||||||
|
char out[4096];
|
||||||
|
char *pp;
|
||||||
|
|
||||||
|
snprintf(out, sizeof(out), "%s/%s", outdir, ei->entry);
|
||||||
|
pp = strdup(out);
|
||||||
|
p = strrchr(pp, '/');
|
||||||
|
*p = 0;
|
||||||
|
e_file_mkpath(pp);
|
||||||
|
free(pp);
|
||||||
|
printf("Output Image: %s\n", out);
|
||||||
|
im = imlib_create_image_using_data(w, h, pix);
|
||||||
|
imlib_context_set_image(im);
|
||||||
|
if (alpha)
|
||||||
|
imlib_image_set_has_alpha(1);
|
||||||
|
if ((lossy) && (!alpha))
|
||||||
|
{
|
||||||
|
imlib_image_set_format("jpg");
|
||||||
|
imlib_image_attach_data_value("quality", NULL, qual, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imlib_image_set_format("png");
|
||||||
|
}
|
||||||
|
imlib_save_image(out);
|
||||||
|
imlib_free_image();
|
||||||
|
free(pix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (l = srcfiles->list; l; l = l->next)
|
||||||
|
{
|
||||||
|
SrcFile *sf;
|
||||||
|
char out[4096];
|
||||||
|
FILE *f;
|
||||||
|
char *pp;
|
||||||
|
|
||||||
|
sf = l->data;
|
||||||
|
snprintf(out, sizeof(out), "%s/%s", outdir, sf->name);
|
||||||
|
printf("Output Source File: %s\n", out);
|
||||||
|
pp = strdup(out);
|
||||||
|
p = strrchr(pp, '/');
|
||||||
|
*p = 0;
|
||||||
|
e_file_mkpath(pp);
|
||||||
|
free(pp);
|
||||||
|
f = fopen(out, "w");
|
||||||
|
fputs(sf->file, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
if (fontlist)
|
||||||
|
{
|
||||||
|
for (l = fontlist->list; l; l = l->next)
|
||||||
|
{
|
||||||
|
Font *fn;
|
||||||
|
void *font;
|
||||||
|
int fontsize;
|
||||||
|
char out[4096];
|
||||||
|
|
||||||
|
fn = l->data;
|
||||||
|
snprintf(out, sizeof(out), "fonts/%s", fn->name);
|
||||||
|
font = eet_read(ef, out, &fontsize);
|
||||||
|
if (font)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
snprintf(out, sizeof(out), "%s/%s", outdir, fn->file);
|
||||||
|
printf("Output Font: %s\n", out);
|
||||||
|
f = fopen(out, "w");
|
||||||
|
fwrite(font, fontsize, 1, f);
|
||||||
|
fclose(f);
|
||||||
|
free(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
char out[4096];
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
snprintf(out, sizeof(out), "%s/build.sh", outdir);
|
||||||
|
printf("Output Build Script: %s\n", out);
|
||||||
|
f = fopen(out, "w");
|
||||||
|
fprintf(f, "#!/bin/sh\n");
|
||||||
|
fprintf(f, "edje_cc -id . -fd . main_edje_source.edc %s.eet\n", outdir);
|
||||||
|
fclose(f);
|
||||||
|
chmod(out, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP);
|
||||||
|
}
|
||||||
|
eet_close(ef);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
e_file_is_dir(char *file)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if (stat(file, &st) < 0) return 0;
|
||||||
|
if (S_ISDIR(st.st_mode)) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||||
|
|
||||||
|
int
|
||||||
|
e_file_mkdir(char *dir)
|
||||||
|
{
|
||||||
|
if (mkdir(dir, default_mode) < 0) return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
e_file_mkpath(char *path)
|
||||||
|
{
|
||||||
|
char ss[PATH_MAX];
|
||||||
|
int i, ii;
|
||||||
|
|
||||||
|
ss[0] = 0;
|
||||||
|
i = 0;
|
||||||
|
ii = 0;
|
||||||
|
while (path[i])
|
||||||
|
{
|
||||||
|
if (ii == sizeof(ss) - 1) return 0;
|
||||||
|
ss[ii++] = path[i];
|
||||||
|
ss[ii] = 0;
|
||||||
|
if (path[i] == '/')
|
||||||
|
{
|
||||||
|
if (!e_file_is_dir(ss)) e_file_mkdir(ss);
|
||||||
|
else if (!e_file_is_dir(ss)) return 0;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (!e_file_is_dir(ss)) e_file_mkdir(ss);
|
||||||
|
else if (!e_file_is_dir(ss)) return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
#ifndef EDJE_DECC_H
|
||||||
|
#define EDJE_DECC_H
|
||||||
|
|
||||||
|
#include "edje_main.h"
|
||||||
|
/* Imlib2 stuff for loading up input images */
|
||||||
|
#define X_DISPLAY_MISSING
|
||||||
|
#include <Imlib2.h>
|
||||||
|
/* done Imlib2 stuff */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#ifdef HAVE_ALLOCA_H
|
||||||
|
#include <alloca.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* types */
|
||||||
|
typedef struct _Font Font;
|
||||||
|
typedef struct _Font_List Font_List;
|
||||||
|
typedef struct _SrcFile SrcFile;
|
||||||
|
typedef struct _SrcFile_List SrcFile_List;
|
||||||
|
|
||||||
|
struct _Font
|
||||||
|
{
|
||||||
|
char *file;
|
||||||
|
char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Font_List
|
||||||
|
{
|
||||||
|
Evas_List *list;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _SrcFile
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
char *file;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _SrcFile_List
|
||||||
|
{
|
||||||
|
Evas_List *list;
|
||||||
|
};
|
||||||
|
|
||||||
|
void source_edd(void);
|
||||||
|
void source_fetch(void);
|
||||||
|
int source_append(Eet_File *ef);
|
||||||
|
SrcFile_List *source_load(Eet_File *ef);
|
||||||
|
int source_fontmap_save(Eet_File *ef, Evas_List *fonts);
|
||||||
|
Font_List *source_fontmap_load(Eet_File *ef);
|
||||||
|
|
||||||
|
void *mem_alloc(size_t size);
|
||||||
|
char *mem_strdup(const char *s);
|
||||||
|
#define SZ sizeof
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue