Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: tools/licenses.py

Issue 12177010: Generate about:credits page automatically at build time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ninja Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_resources.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/licenses.py
diff --git a/tools/licenses.py b/tools/licenses.py
index 10a8d330ec73559bc76c9b8090e411a83e5056da..da650f61d6787ffebbbc287c7b42efea31019f2b 100755
--- a/tools/licenses.py
+++ b/tools/licenses.py
@@ -401,8 +401,12 @@ def ScanThirdPartyDirs(root=None):
return len(errors) == 0
-def GenerateCredits(root=None):
- """Generate about:credits, dumping the result to stdout."""
+def GenerateCredits():
+ """Generate about:credits."""
+
+ if len(sys.argv) not in (2, 3):
+ print 'usage: licenses.py credits [output_file]'
+ return False
def EvaluateTemplate(template, env, escape=True):
"""Expand a template with variables like {{foo}} using a
@@ -413,8 +417,7 @@ def GenerateCredits(root=None):
template = template.replace('{{%s}}' % key, val)
return template
- if root is None:
- root = os.getcwd()
+ root = os.path.join(os.path.dirname(__file__), '..')
third_party_dirs = FindThirdPartyDirs(PRUNE_PATHS, root)
entry_template = open(os.path.join(root, 'chrome', 'browser', 'resources',
@@ -444,9 +447,18 @@ def GenerateCredits(root=None):
file_template = open(os.path.join(root, 'chrome', 'browser', 'resources',
'about_credits.tmpl'), 'rb').read()
- print "<!-- Generated by licenses.py; do not edit. -->"
- print EvaluateTemplate(file_template, {'entries': '\n'.join(entries)},
- escape=False)
+ template_contents = "<!-- Generated by licenses.py; do not edit. -->"
+ template_contents += EvaluateTemplate(file_template,
+ {'entries': '\n'.join(entries)},
+ escape=False)
+
+ if len(sys.argv) == 3:
+ with open(sys.argv[2], 'w') as output_file:
+ output_file.write(template_contents)
+ elif len(sys.argv) == 2:
+ print template_contents
+
+ return True
def main():
« no previous file with comments | « chrome/chrome_resources.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698