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

Unified Diff: chrome/browser/resources/chromeos/chromevox/tools/generate_manifest.py

Issue 295123002: Provide script/gypi support for manifest generation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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
Index: chrome/browser/resources/chromeos/chromevox/tools/generate_manifest.py
diff --git a/chrome/browser/resources/chromeos/chromevox/tools/generate_manifest.py b/chrome/browser/resources/chromeos/chromevox/tools/generate_manifest.py
new file mode 100755
index 0000000000000000000000000000000000000000..cce1050a720cdb71e6ce27d62bb245dc63e11316
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/tools/generate_manifest.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import io
+import optparse
+import os
+import sys
+
+jinja2_path = os.path.normpath(os.path.join(os.path.abspath(__file__),
+ *[os.path.pardir] * 7 + ['third_party']))
+nom_path = os.path.normpath(os.path.join(os.path.abspath(__file__),
+ *[os.path.pardir] * 7 + ['tools/json_comment_eater']))
+sys.path.insert(0, jinja2_path)
+sys.path.insert(0, nom_path)
+import jinja2
+from json_comment_eater import Nom
+
+
+'''Generate an extension manifest based on a template.'''
+
+
+def processJinjaTemplate(input_file, output_file, context):
+ (template_path, template_name) = os.path.split(input_file)
+ env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path))
+ template = env.get_template(template_name)
+ rendered = template.render(context)
+ rendered_without_comments = Nom(rendered)
+ # Simply for validation.
+ json.loads(rendered_without_comments)
+ with io.open(output_file, 'w', encoding='utf-8') as manifest_file:
+ manifest_file.write(rendered_without_comments)
+
+
+def main():
+ parser = optparse.OptionParser(description=__doc__)
+ parser.usage = '%prog [options] <template_manifest_path>'
+ parser.add_option(
+ '-o', '--output_manifest', action='store', metavar='OUTPUT_MANIFEST',
+ help='File to place generated manifest')
+ parser.add_option(
+ '-g', '--is_guest_manifest', action='store', metavar='GUEST_MANIFEST',
+ help='Generate a guest mode capable manifest')
+
+ options, args = parser.parse_args()
+ if len(args) != 1:
+ print >>sys.stderr, 'Expected exactly one argument'
+ sys.exit(1)
+ processJinjaTemplate(args[0], options.output_manifest, parser.values.__dict__)
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/manifest_guest.json ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698