Skip to content

Commit

Permalink
[WPE][GTK] generate-pdfjs-gresource-manifest.py should be more carefu…
Browse files Browse the repository at this point in the history
…l about unknown files

https://bugs.webkit.org/show_bug.cgi?id=240536

Patch by Michael Catanzaro <mcatanzaro@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/250676@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
mcatanzaro authored and webkit-commit-queue committed May 18, 2022
1 parent 7c5c984 commit 354999d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Tools/glib/generate-pdfjs-gresource-manifest.py
Expand Up @@ -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)
Expand All @@ -53,7 +55,10 @@ def resource_name(filename):
# 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
Expand Down

0 comments on commit 354999d

Please sign in to comment.