edje: @feature to include license in edje file.

This will close T1027.
This commit is contained in:
Cedric Bail 2014-03-03 08:39:53 -03:00
parent f3ba81f7c1
commit 92a24dea79
3 changed files with 59 additions and 3 deletions

View File

@ -21,6 +21,7 @@ char *file_in = NULL;
char *tmp_dir = NULL;
char *file_out = NULL;
char *watchfile = NULL;
char *license = NULL;
static const char *progname = NULL;
@ -90,6 +91,7 @@ main_help(void)
"-sd sound/directory Add a directory to look in for relative path sounds samples\n"
"-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"
"-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"
@ -194,6 +196,12 @@ main(int argc, char **argv)
if (!tmp_dir)
tmp_dir = argv[i];
}
else if ((!strcmp(argv[i], "-l") || !strcmp(argv[i], "--license")) && (i < (argc - 1)))
{
i++;
if (!license)
license = argv[i];
}
else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
{
i++;

View File

@ -227,6 +227,7 @@ extern char *file_in;
extern char *tmp_dir;
extern char *file_out;
extern char *watchfile;
extern char *license;
extern int no_lossy;
extern int no_comp;
extern int no_raw;

View File

@ -1345,16 +1345,13 @@ data_scripts_exe_del_cb(void *data EINA_UNUSED, int evtype EINA_UNUSED, void *ev
}
if (threads)
{
pending_threads++;
ecore_thread_run(data_thread_script, data_thread_script_end, NULL, sc);
}
else
{
pending_threads++;
data_thread_script(sc, NULL);
data_thread_script_end(sc, NULL);
}
pending_threads--;
if (pending_threads <= 0) ecore_main_loop_quit();
return ECORE_CALLBACK_CANCEL;
}
@ -1643,6 +1640,45 @@ data_thread_source_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
if (pending_threads <= 0) ecore_main_loop_quit();
}
static void
data_thread_license(void *data, Ecore_Thread *thread EINA_UNUSED)
{
Eet_File *ef = data;
Eina_File *f;
void *m;
int bytes;
f = eina_file_open(license, 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);
if ((bytes <= 0) || eina_file_map_faulted(f, m))
{
ERR("Unable to write license part \"%s\".", license);
}
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 EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
{
pending_threads--;
if (pending_threads <= 0) ecore_main_loop_quit();
}
static void
data_thread_fontmap(void *data, Ecore_Thread *thread EINA_UNUSED)
{
@ -1721,6 +1757,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)
{
pending_threads++;
if (threads)
ecore_thread_run(data_thread_license, data_thread_license_end, NULL, ef);
else
{
data_thread_license(ef, NULL);
data_thread_license_end(ef, NULL);
}
}
pending_threads--;
if (pending_threads > 0) ecore_main_loop_begin();
INF("THREADS: %3.5f", ecore_time_get() - t);