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

Side by Side Diff: build/android/gyp/jinja_template.py

Issue 2621413002: Android: Split up build.gradle.jinja (Closed)
Patch Set: Rebase Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « build/android/gradle/root.jinja ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Renders one or more template files using the Jinja template engine.""" 7 """Renders one or more template files using the Jinja template engine."""
8 8
9 import codecs 9 import codecs
10 import argparse 10 import argparse
(...skipping 19 matching lines...) Expand all
30 contents, filename, uptodate = jinja2.FileSystemLoader.get_source( 30 contents, filename, uptodate = jinja2.FileSystemLoader.get_source(
31 self, environment, template) 31 self, environment, template)
32 self.loaded_templates.add(os.path.relpath(filename)) 32 self.loaded_templates.add(os.path.relpath(filename))
33 return contents, filename, uptodate 33 return contents, filename, uptodate
34 34
35 35
36 class JinjaProcessor(object): 36 class JinjaProcessor(object):
37 """Allows easy rendering of jinja templates with input file tracking.""" 37 """Allows easy rendering of jinja templates with input file tracking."""
38 def __init__(self, loader_base_dir, variables=None): 38 def __init__(self, loader_base_dir, variables=None):
39 self.loader_base_dir = loader_base_dir 39 self.loader_base_dir = loader_base_dir
40 self.variables = variables 40 self.variables = variables or {}
41 self.loader = _RecordingFileSystemLoader(loader_base_dir) 41 self.loader = _RecordingFileSystemLoader(loader_base_dir)
42 self.env = jinja2.Environment(loader=self.loader) 42 self.env = jinja2.Environment(loader=self.loader)
43 self.env.undefined = jinja2.StrictUndefined 43 self.env.undefined = jinja2.StrictUndefined
44 self.env.line_comment_prefix = '##' 44 self.env.line_comment_prefix = '##'
45 self.env.trim_blocks = True 45 self.env.trim_blocks = True
46 self.env.lstrip_blocks = True 46 self.env.lstrip_blocks = True
47 self._template_cache = {} # Map of path -> Template 47 self._template_cache = {} # Map of path -> Template
48 48
49 def Render(self, input_filename, variables=None): 49 def Render(self, input_filename, variables=None):
50 input_rel_path = os.path.relpath(input_filename, self.loader_base_dir) 50 input_rel_path = os.path.relpath(input_filename, self.loader_base_dir)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 options.outputs_zip) 132 options.outputs_zip)
133 133
134 if options.depfile: 134 if options.depfile:
135 output = options.output or options.outputs_zip 135 output = options.output or options.outputs_zip
136 deps = processor.GetLoadedTemplates() 136 deps = processor.GetLoadedTemplates()
137 build_utils.WriteDepfile(options.depfile, output, deps) 137 build_utils.WriteDepfile(options.depfile, output, deps)
138 138
139 139
140 if __name__ == '__main__': 140 if __name__ == '__main__':
141 main() 141 main()
OLDNEW
« no previous file with comments | « build/android/gradle/root.jinja ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698