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)
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;
21char *tmp_dir = NULL; 21char *tmp_dir = NULL;
22char *file_out = NULL; 22char *file_out = NULL;
23char *watchfile = NULL; 23char *watchfile = NULL;
24char *authors = NULL;
24char *license = NULL; 25char *license = NULL;
26Eina_List *licenses = NULL;
25 27
26static const char *progname = NULL; 28static const char *progname = NULL;
27 29
@@ -92,6 +94,7 @@ main_help(void)
92 "-dd data/directory Add a directory to look in for relative path data.file entries\n" 94 "-dd data/directory Add a directory to look in for relative path data.file entries\n"
93 "-td temp/directory Directory to store temporary files\n" 95 "-td temp/directory Directory to store temporary files\n"
94 "-l license Specify the license of a theme\n" 96 "-l license Specify the license of a theme\n"
97 "-a authors Specify AUTHORS\n"
95 "-v Verbose output\n" 98 "-v Verbose output\n"
96 "-no-lossy Do NOT allow images to be lossy\n" 99 "-no-lossy Do NOT allow images to be lossy\n"
97 "-no-comp Do NOT allow images to be stored with lossless compression\n" 100 "-no-comp Do NOT allow images to be stored with lossless compression\n"
@@ -201,6 +204,14 @@ main(int argc, char **argv)
201 i++; 204 i++;
202 if (!license) 205 if (!license)
203 license = argv[i]; 206 license = argv[i];
207 else
208 licenses = eina_list_append(licenses, argv[i]);
209 }
210 else if ((!strcmp(argv[i], "-a") || !strcmp(argv[i], "--authors")) && (i < (argc - 1)))
211 {
212 i++;
213 if (!authors)
214 authors = argv[i];
204 } 215 }
205 else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1))) 216 else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
206 { 217 {
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;
228extern char *file_out; 228extern char *file_out;
229extern char *watchfile; 229extern char *watchfile;
230extern char *license; 230extern char *license;
231extern char *authors;
232extern Eina_List *licenses;
231extern int no_lossy; 233extern int no_lossy;
232extern int no_comp; 234extern int no_comp;
233extern int no_raw; 235extern 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;
123typedef struct _Image_Write Image_Write; 123typedef struct _Image_Write Image_Write;
124typedef struct _Sound_Write Sound_Write; 124typedef struct _Sound_Write Sound_Write;
125typedef struct _Group_Write Group_Write; 125typedef struct _Group_Write Group_Write;
126typedef struct _License_Write License_Write;
126 127
127struct _Script_Write 128struct _Script_Write
128{ 129{
@@ -175,6 +176,13 @@ struct _Group_Write
175 char *errstr; 176 char *errstr;
176}; 177};
177 178
179struct _License_Write
180{
181 Eet_File *ef;
182 const char *file;
183 Eina_Bool master;
184};
185
178struct _Image_Unused_Ids 186struct _Image_Unused_Ids
179{ 187{
180 int old_id; 188 int old_id;
@@ -1643,21 +1651,120 @@ data_thread_source_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
1643static void 1651static void
1644data_thread_license(void *data, Ecore_Thread *thread EINA_UNUSED) 1652data_thread_license(void *data, Ecore_Thread *thread EINA_UNUSED)
1645{ 1653{
1654 License_Write *lw = data;
1655 Eet_File *ef = lw->ef;
1656 Eina_File *f;
1657 void *m;
1658 int bytes;
1659
1660 f = eina_file_open(lw->file, 0);
1661 if (!f) return ;
1662
1663 m = eina_file_map_all(f, EINA_FILE_WILLNEED);
1664 if (!m) goto on_error;
1665
1666 if (lw->master)
1667 {
1668 bytes = eet_write(ef, "edje/license", m, eina_file_size_get(f), compress_mode);
1669 }
1670 else
1671 {
1672 char *s = alloca(strlen(lw->file) + 1 + 13);
1673
1674 strcpy(s, lw->file);
1675 sprintf(s, "edje/license/%s", basename(s));
1676
1677 bytes = eet_write(ef, s, m, eina_file_size_get(f), compress_mode);
1678 }
1679
1680 if ((bytes <= 0) || eina_file_map_faulted(f, m))
1681 {
1682 ERR("Unable to write license part \"%s\".", lw->file);
1683 }
1684 else
1685 {
1686 INF("Wrote %9i bytes (%4iKb) for \"%s\" license entry compress: [real: %2.1f%%]",
1687 bytes, (bytes + 512) / 1024, license,
1688 100 - (100 * (double)bytes) / ((double)(eina_file_size_get(f))));
1689 }
1690
1691 eina_file_map_free(f, m);
1692
1693 on_error:
1694 eina_file_close(f);
1695}
1696
1697static void
1698data_thread_license_end(void *data, Ecore_Thread *thread EINA_UNUSED)
1699{
1700 pending_threads--;
1701 if (pending_threads <= 0) ecore_main_loop_quit();
1702 free(data);
1703}
1704
1705static void
1706data_write_license(Eet_File *ef)
1707{
1708 License_Write *lw;
1709 Eina_List *l;
1710 const char *file;
1711
1712 if (!license) return ;
1713
1714 lw = calloc(1, sizeof (License_Write));
1715 if (!lw) return ;
1716
1717 lw->ef = ef;
1718 lw->file = license;
1719 lw->master = EINA_TRUE;
1720
1721 pending_threads++;
1722 if (threads)
1723 ecore_thread_run(data_thread_license, data_thread_license_end, NULL, lw);
1724 else
1725 {
1726 data_thread_license(lw, NULL);
1727 data_thread_license_end(lw, NULL);
1728 }
1729
1730 EINA_LIST_FOREACH(licenses, l, file)
1731 {
1732 lw = calloc(1, sizeof (License_Write));
1733 if (!lw) return ;
1734
1735 lw->ef = ef;
1736 lw->file = file;
1737 lw->master = EINA_FALSE;
1738
1739 pending_threads++;
1740 if (threads)
1741 ecore_thread_run(data_thread_license, data_thread_license_end, NULL, lw);
1742 else
1743 {
1744 data_thread_license(lw, NULL);
1745 data_thread_license_end(lw, NULL);
1746 }
1747 }
1748}
1749
1750static void
1751data_thread_authors(void *data, Ecore_Thread *thread EINA_UNUSED)
1752{
1646 Eet_File *ef = data; 1753 Eet_File *ef = data;
1647 Eina_File *f; 1754 Eina_File *f;
1648 void *m; 1755 void *m;
1649 int bytes; 1756 int bytes;
1650 1757
1651 f = eina_file_open(license, 0); 1758 f = eina_file_open(authors, 0);
1652 if (!f) return ; 1759 if (!f) return ;
1653 1760
1654 m = eina_file_map_all(f, EINA_FILE_WILLNEED); 1761 m = eina_file_map_all(f, EINA_FILE_WILLNEED);
1655 if (!m) goto on_error; 1762 if (!m) goto on_error;
1656 1763
1657 bytes = eet_write(ef, "edje/license", m, eina_file_size_get(f), compress_mode); 1764 bytes = eet_write(ef, "edje/authors", m, eina_file_size_get(f), compress_mode);
1658 if ((bytes <= 0) || eina_file_map_faulted(f, m)) 1765 if ((bytes <= 0) || eina_file_map_faulted(f, m))
1659 { 1766 {
1660 ERR("Unable to write license part \"%s\".", license); 1767 ERR("Unable to write license part \"%s\".", authors);
1661 } 1768 }
1662 else 1769 else
1663 { 1770 {
@@ -1673,7 +1780,7 @@ data_thread_license(void *data, Ecore_Thread *thread EINA_UNUSED)
1673} 1780}
1674 1781
1675static void 1782static void
1676data_thread_license_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED) 1783data_thread_authors_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
1677{ 1784{
1678 pending_threads--; 1785 pending_threads--;
1679 if (pending_threads <= 0) ecore_main_loop_quit(); 1786 if (pending_threads <= 0) ecore_main_loop_quit();
@@ -1757,15 +1864,17 @@ data_write(void)
1757 INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); 1864 INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get();
1758 data_write_sounds(ef, &sound_num); 1865 data_write_sounds(ef, &sound_num);
1759 INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get(); 1866 INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get();
1760 if (license) 1867 data_write_license(ef);
1868 INF("license: %3.5f", ecore_time_get() - t); t = ecore_time_get();
1869 if (authors)
1761 { 1870 {
1762 pending_threads++; 1871 pending_threads++;
1763 if (threads) 1872 if (threads)
1764 ecore_thread_run(data_thread_license, data_thread_license_end, NULL, ef); 1873 ecore_thread_run(data_thread_authors, data_thread_authors_end, NULL, ef);
1765 else 1874 else
1766 { 1875 {
1767 data_thread_license(ef, NULL); 1876 data_thread_authors(ef, NULL);
1768 data_thread_license_end(ef, NULL); 1877 data_thread_authors_end(ef, NULL);
1769 } 1878 }
1770 } 1879 }
1771 pending_threads--; 1880 pending_threads--;