edje: @feature to include license in edje file.
authorCedric Bail <cedric.bail@free.fr>
Mon, 3 Mar 2014 11:39:53 +0000 (08:39 -0300)
committerCedric Bail <cedric.bail@free.fr>
Mon, 3 Mar 2014 11:39:53 +0000 (08:39 -0300)
This will close T1027.

src/bin/edje/edje_cc.c
src/bin/edje/edje_cc.h
src/bin/edje/edje_cc_out.c

index d7143556775698be94a63b2a3aff09344a38fe77..5c62fb61f0ca79b8385ef1dbe80807b0fda885db 100644 (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++;
index 3d9973d9a9a478b6685833a693bf2a84fc0b6606..10d2a4ba25eb6a891dc9353fe589829c75642713 100644 (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;
index e30b5965cc7d7ebe2cc78def2adfd10018a8a9c7..e269eccc9bf92a016eecb8f7bfa6d140e6e25eab 100644 (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);