Title: [294379] trunk/Tools/glib/generate-pdfjs-gresource-manifest.py
Revision
294379
Author
commit-qu...@webkit.org
Date
2022-05-17 18:45:35 -0700 (Tue, 17 May 2022)

Log Message

[WPE][GTK] generate-pdfjs-gresource-manifest.py should be more careful about unknown files
https://bugs.webkit.org/show_bug.cgi?id=240536

Patch by Michael Catanzaro <mcatanz...@redhat.com> on 2022-05-17
Reviewed by Adrian Perez de Castro.

Instead of silently ignoring unexpected files, let's create a list of
all files that we do not want to include in the resource manifest.
Anything unexpected will result in a build failure so that there are no
mistakes.

Also, change the lists at the top of the script into sets. Adrian
noticed that they do not need to be ordered.

* Tools/glib/generate-pdfjs-gresource-manifest.py:
(get_filenames):
(get_filenames.should_ignore_resource): Deleted.

Canonical link: https://commits.webkit.org/250668@main

Modified Paths

Diff

Modified: trunk/Tools/glib/generate-pdfjs-gresource-manifest.py (294378 => 294379)


--- trunk/Tools/glib/generate-pdfjs-gresource-manifest.py	2022-05-18 01:43:48 UTC (rev 294378)
+++ trunk/Tools/glib/generate-pdfjs-gresource-manifest.py	2022-05-18 01:45:35 UTC (rev 294379)
@@ -19,18 +19,20 @@
 import os
 import sys
 
-VALID_EXTENSIONS = ['.html', '.js', '.css', '.svg', '.png', '.gif', '.cur', '.bcmap', '.properties', '.pfb', '.ttf']
-COMPRESSIBLE_EXTENSIONS = ['.html', '.js', '.css', '.svg', '.properties']
-BASE_DIRS = ['pdfjs/', 'pdfjs-extras/']
+VALID_EXTENSIONS = {'.html', '.js', '.css', '.svg', '.png', '.gif', '.cur', '.bcmap', '.properties', '.pfb', '.ttf'}
+COMPRESSIBLE_EXTENSIONS = {'.html', '.js', '.css', '.svg', '.properties'}
+BASE_DIRS = {'pdfjs/', 'pdfjs-extras/'}
 
+IGNORE = {'LICENSE',
+          'README.webkit',
+          'web/cmaps/LICENSE',
+          'web/standard_fonts/LICENSE_FOXIT',
+          'web/standard_fonts/LICENSE_LIBERATION'}
 
+
 def get_filenames(directory):
     filenames = []
 
-    def should_ignore_resource(resource):
-        if os.path.splitext(resource)[1] not in VALID_EXTENSIONS:
-            return True
-
     def resource_name(filename):
         for base_directory in BASE_DIRS:
             base_dir_index = filename.rfind(base_directory)
@@ -53,7 +55,10 @@
             # separator is properly replaced.
             if os.sep != '/':
                 name = name.replace(os.sep, '/')
-            if not should_ignore_resource(name):
+            if name not in IGNORE:
+                if os.path.splitext(name)[1] not in VALID_EXTENSIONS:
+                    print('Unexpected file %s, please teach generate-pdfjs-gresource-manifest.py how to handle it' % filename, file=sys.stderr)
+                    sys.exit(1)
                 filenames.append(name)
 
     return filenames
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to