[GTK] Reduce the binary size by compressing the text based web inspector resources
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Apr 2014 13:13:42 +0000 (13:13 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Apr 2014 13:13:42 +0000 (13:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121545

Reviewed by Gustavo Noronha Silva.

Compress text based files when compiling inspector resources. It
reduces the binary size in 3MB.

* gtk/generate-inspector-gresource-manifest.py:
(find_all_files_in_directory):
(is_compressible):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167306 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/gtk/generate-inspector-gresource-manifest.py

index 0aee560..e22babb 100644 (file)
@@ -1,3 +1,17 @@
+2014-04-15  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Reduce the binary size by compressing the text based web inspector resources
+        https://bugs.webkit.org/show_bug.cgi?id=121545
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Compress text based files when compiling inspector resources. It
+        reduces the binary size in 3MB.
+
+        * gtk/generate-inspector-gresource-manifest.py:
+        (find_all_files_in_directory):
+        (is_compressible):
+
 2014-04-14  Alexey Proskuryakov  <ap@apple.com>
 
         Remove Gtk WebKit1 tester.
index 0ab4474..c035e68 100755 (executable)
@@ -21,6 +21,7 @@ import os
 import sys
 
 ALLOWED_EXTENSIONS = ['.html', '.js', '.css', '.png', '.svg']
+COMPRESSIBLE_EXTENSIONS = ['.html', '.js', '.css', '.svg']
 
 
 def find_all_files_in_directory(directory):
@@ -38,6 +39,11 @@ def find_all_files_in_directory(directory):
 
     return to_return
 
+
+def is_compressible(filename):
+    return os.path.splitext(filename)[1] in COMPRESSIBLE_EXTENSIONS
+
+
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(description='Generate a GResources file for the inspector.')
     parser.add_argument('--output', nargs='?', type=argparse.FileType('w'), default=sys.stdout,
@@ -52,8 +58,13 @@ if __name__ == "__main__":
 """)
 
     for directory in extra_args[1:]:
-        for file in find_all_files_in_directory(directory):
-            arguments.output.write("            <file>%s</file>\n" % file)
+        for filename in find_all_files_in_directory(directory):
+            line = '            <file'
+            if is_compressible(filename):
+                line += ' compressed="true"'
+            line += '>%s</file>\n' % filename
+
+            arguments.output.write(line)
 
     arguments.output.write(\
     """    </gresource>