summaryrefslogtreecommitdiffstats
path: root/tools/licenses.py
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 20:03:38 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 20:03:38 +0000
commit689d81cc49a1c71e0e02eaf182906b68dfe33f01 (patch)
treebe70947ed2deab4cc3c6243e4a001d4198a1a53e /tools/licenses.py
parentb5d583ae936d009a7f00d9e81cec88b371eefbff (diff)
downloadchromium_src-689d81cc49a1c71e0e02eaf182906b68dfe33f01.zip
chromium_src-689d81cc49a1c71e0e02eaf182906b68dfe33f01.tar.gz
chromium_src-689d81cc49a1c71e0e02eaf182906b68dfe33f01.tar.bz2
Add SwiftShader copyright info and logo to about:credits.
Adds support to tools/licenses.py for including html in about:credits, and use to include SwiftShader's logo and license info. BUG=112611 TEST= Review URL: https://chromiumcodereview.appspot.com/9318014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120377 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/licenses.py')
-rwxr-xr-xtools/licenses.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/tools/licenses.py b/tools/licenses.py
index fc07af7..d724540 100755
--- a/tools/licenses.py
+++ b/tools/licenses.py
@@ -151,6 +151,18 @@ class LicenseError(Exception):
fully filled out."""
pass
+def AbsolutePath(path, filename):
+ """Convert a path in README.chromium to be absolute based on the source
+ root."""
+ if filename.startswith('/'):
+ # Absolute-looking paths are relative to the source root
+ # (which is the directory we're run from).
+ absolute_path = os.path.join(os.getcwd(), filename[1:])
+ else:
+ absolute_path = os.path.join(path, filename)
+ if os.path.exists(absolute_path):
+ return absolute_path
+ return None
def ParseDir(path):
"""Examine a third_party/foo component and extract its metadata."""
@@ -163,6 +175,10 @@ def ParseDir(path):
"URL": None, # Project home page.
}
+ # Relative path to a file containing some html we're required to place in
+ # about:credits.
+ optional_keys = ["Required Text"]
+
if path in SPECIAL_CASES:
metadata.update(SPECIAL_CASES[path])
else:
@@ -175,7 +191,7 @@ def ParseDir(path):
line = line.strip()
if not line:
break
- for key in metadata.keys():
+ for key in metadata.keys() + optional_keys:
field = key + ": "
if line.startswith(field):
metadata[key] = line[len(field):]
@@ -189,16 +205,10 @@ def ParseDir(path):
# Check that the license file exists.
for filename in (metadata["License File"], "COPYING"):
- if filename.startswith('/'):
- # Absolute-looking paths are relative to the source root
- # (which is the directory we're run from).
- license_path = os.path.join(os.getcwd(), filename[1:])
- else:
- license_path = os.path.join(path, filename)
- if os.path.exists(license_path):
+ license_path = AbsolutePath(path, filename)
+ if license_path is not None:
metadata["License File"] = license_path
break
- license_path = None
if not license_path:
raise LicenseError("License file not found. "
@@ -207,6 +217,13 @@ def ParseDir(path):
"or add a 'License File:' line to README.chromium "
"with the appropriate path.")
+ if "Required Text" in metadata:
+ required_path = AbsolutePath(path, metadata["Required Text"])
+ if required_path is not None:
+ metadata["Required Text"] = required_path
+ else:
+ raise LicenseError("Required text file listed but not found.")
+
return metadata
@@ -269,7 +286,7 @@ def GenerateCredits():
"""Expand a template with variables like {{foo}} using a
dictionary of expansions."""
for key, val in env.items():
- if escape:
+ if escape and not key.endswith("_unescaped"):
val = cgi.escape(val)
template = template.replace('{{%s}}' % key, val)
return template
@@ -290,7 +307,11 @@ def GenerateCredits():
'name': metadata['Name'],
'url': metadata['URL'],
'license': open(metadata['License File'], 'rb').read(),
+ 'license_unescaped': '',
}
+ if 'Required Text' in metadata:
+ required_text = open(metadata['Required Text'], 'rb').read()
+ env["license_unescaped"] = required_text
entries.append(EvaluateTemplate(entry_template, env))
file_template = open('chrome/browser/resources/about_credits.tmpl',