summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2014-03-06 16:33:06 +0900
committerCedric BAIL <cedric.bail@samsung.com>2014-03-06 16:33:06 +0900
commitdea550eba1c0ba29f934e29072dde1c53b1e4863 (patch)
tree8d13396c128973c2d929e7cae87257fd37cc7e0e
parentc3e0f5c4ef7922c2fe29db66e4744a987f31bff3 (diff)
downloadefl-dea550eba1c0ba29f934e29072dde1c53b1e4863.tar.gz
edje: add AUTHORS and more than one license file to Edje.
@feature
-rw-r--r--src/bin/edje/edje_cc.c11
-rw-r--r--src/bin/edje/edje_cc.h2
-rw-r--r--src/bin/edje/edje_cc_out.c125
3 files changed, 130 insertions, 8 deletions
diff --git a/src/bin/edje/edje_cc.c b/src/bin/edje/edje_cc.c
index 5c62fb61f0..422ff676fd 100644
--- a/src/bin/edje/edje_cc.c
+++ b/src/bin/edje/edje_cc.c
@@ -21,7 +21,9 @@ char *file_in = NULL;
char *tmp_dir = NULL;
char *file_out = NULL;
char *watchfile = NULL;
+char *authors = NULL;
char *license = NULL;
+Eina_List *licenses = NULL;
static const char *progname = NULL;
@@ -92,6 +94,7 @@ main_help(void)
"-dd data/directory Add a directory to look in for relative path data.file entries\n"
"-td temp/directory Directory to store temporary files\n"
"-l license Specify the license of a theme\n"
+ "-a authors Specify AUTHORS\n"
"-v Verbose output\n"
"-no-lossy Do NOT allow images to be lossy\n"
"-no-comp Do NOT allow images to be stored with lossless compression\n"
@@ -201,6 +204,14 @@ main(int argc, char **argv)
i++;
if (!license)
license = argv[i];
+ else
+ licenses = eina_list_append(licenses, argv[i]);
+ }
+ else if ((!strcmp(argv[i], "-a") || !strcmp(argv[i], "--authors")) && (i < (argc - 1)))
+ {
+ i++;
+ if (!authors)
+ authors = argv[i];
}
else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
{
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index 10d2a4ba25..48bb023976 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -228,6 +228,8 @@ extern char *tmp_dir;
extern char *file_out;
extern char *watchfile;
extern char *license;
+extern char *authors;
+extern Eina_List *licenses;
extern int no_lossy;
extern int no_comp;
extern int no_raw;
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index e269eccc9b..6a75c4c84a 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -123,6 +123,7 @@ typedef struct _Fonts_Write Fonts_Write;
typedef struct _Image_Write Image_Write;
typedef struct _Sound_Write Sound_Write;
typedef struct _Group_Write Group_Write;
+typedef struct _License_Write License_Write;
struct _Script_Write
{
@@ -175,6 +176,13 @@ struct _Group_Write
char *errstr;
};
+struct _License_Write
+{
+ Eet_File *ef;
+ const char *file;
+ Eina_Bool master;
+};
+
struct _Image_Unused_Ids
{
int old_id;
@@ -1643,21 +1651,120 @@ data_thread_source_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
static void
data_thread_license(void *data, Ecore_Thread *thread EINA_UNUSED)
{
+ License_Write *lw = data;
+ Eet_File *ef = lw->ef;
+ Eina_File *f;
+ void *m;
+ int bytes;
+
+ f = eina_file_open(lw->file, 0);
+ if (!f) return ;
+
+ m = eina_file_map_all(f, EINA_FILE_WILLNEED);
+ if (!m) goto on_error;
+
+ if (lw->master)
+ {
+ bytes = eet_write(ef, "edje/license", m, eina_file_size_get(f), compress_mode);
+ }
+ else
+ {
+ char *s = alloca(strlen(lw->file) + 1 + 13);
+
+ strcpy(s, lw->file);
+ sprintf(s, "edje/license/%s", basename(s));
+
+ bytes = eet_write(ef, s, m, eina_file_size_get(f), compress_mode);
+ }
+
+ if ((bytes <= 0) || eina_file_map_faulted(f, m))
+ {
+ ERR("Unable to write license part \"%s\".", lw->file);
+ }
+ else
+ {
+ INF("Wrote %9i bytes (%4iKb) for \"%s\" license entry compress: [real: %2.1f%%]",
+ bytes, (bytes + 512) / 1024, license,
+ 100 - (100 * (double)bytes) / ((double)(eina_file_size_get(f))));
+ }
+
+ eina_file_map_free(f, m);
+
+ on_error:
+ eina_file_close(f);
+}
+
+static void
+data_thread_license_end(void *data, Ecore_Thread *thread EINA_UNUSED)
+{
+ pending_threads--;
+ if (pending_threads <= 0) ecore_main_loop_quit();
+ free(data);
+}
+
+static void
+data_write_license(Eet_File *ef)
+{
+ License_Write *lw;
+ Eina_List *l;
+ const char *file;
+
+ if (!license) return ;
+
+ lw = calloc(1, sizeof (License_Write));
+ if (!lw) return ;
+
+ lw->ef = ef;
+ lw->file = license;
+ lw->master = EINA_TRUE;
+
+ pending_threads++;
+ if (threads)
+ ecore_thread_run(data_thread_license, data_thread_license_end, NULL, lw);
+ else
+ {
+ data_thread_license(lw, NULL);
+ data_thread_license_end(lw, NULL);
+ }
+
+ EINA_LIST_FOREACH(licenses, l, file)
+ {
+ lw = calloc(1, sizeof (License_Write));
+ if (!lw) return ;
+
+ lw->ef = ef;
+ lw->file = file;
+ lw->master = EINA_FALSE;
+
+ pending_threads++;
+ if (threads)
+ ecore_thread_run(data_thread_license, data_thread_license_end, NULL, lw);
+ else
+ {
+ data_thread_license(lw, NULL);
+ data_thread_license_end(lw, NULL);
+ }
+ }
+}
+
+static void
+data_thread_authors(void *data, Ecore_Thread *thread EINA_UNUSED)
+{
Eet_File *ef = data;
Eina_File *f;
void *m;
int bytes;
- f = eina_file_open(license, 0);
+ f = eina_file_open(authors, 0);
if (!f) return ;
m = eina_file_map_all(f, EINA_FILE_WILLNEED);
if (!m) goto on_error;
- bytes = eet_write(ef, "edje/license", m, eina_file_size_get(f), compress_mode);
+ bytes = eet_write(ef, "edje/authors", m, eina_file_size_get(f), compress_mode);
if ((bytes <= 0) || eina_file_map_faulted(f, m))
{
- ERR("Unable to write license part \"%s\".", license);
+ ERR("Unable to write license part \"%s\".", authors);
}
else
{
@@ -1673,7 +1780,7 @@ data_thread_license(void *data, Ecore_Thread *thread EINA_UNUSED)
}
static void
-data_thread_license_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
+data_thread_authors_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
{
pending_threads--;
if (pending_threads <= 0) ecore_main_loop_quit();
@@ -1757,15 +1864,17 @@ data_write(void)
INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get();
data_write_sounds(ef, &sound_num);
INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get();
- if (license)
+ data_write_license(ef);
+ INF("license: %3.5f", ecore_time_get() - t); t = ecore_time_get();
+ if (authors)
{
pending_threads++;
if (threads)
- ecore_thread_run(data_thread_license, data_thread_license_end, NULL, ef);
+ ecore_thread_run(data_thread_authors, data_thread_authors_end, NULL, ef);
else
{
- data_thread_license(ef, NULL);
- data_thread_license_end(ef, NULL);
+ data_thread_authors(ef, NULL);
+ data_thread_authors_end(ef, NULL);
}
}
pending_threads--;