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

Side by Side Diff: remoting/webapp/build-html.py

Issue 1296283002: Create list file for GN target //remoting/webapp:unit_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « remoting/webapp/BUILD.gn ('k') | remoting/webapp/files.gni » ('j') | 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 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Builds the complete main.html file from the basic components. 6 """Builds the complete main.html file from the basic components.
7 """ 7 """
8 8
9 from HTMLParser import HTMLParser 9 from HTMLParser import HTMLParser
10 import argparse 10 import argparse
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 if line.strip() == '': 107 if line.strip() == '':
108 output.write('\n') 108 output.write('\n')
109 else: 109 else:
110 output.write((' ' * indent) + line) 110 output.write((' ' * indent) + line)
111 111
112 112
113 def parseArgs(): 113 def parseArgs():
114 parser = argparse.ArgumentParser() 114 parser = argparse.ArgumentParser()
115 parser.add_argument( 115 parser.add_argument(
116 '--js', nargs='+', help='The Javascript files to include in HTML <head>') 116 '--js',
117 nargs='+',
118 default={},
119 help='The Javascript files to include in HTML <head>')
120 parser.add_argument(
121 '--js-list-file',
122 help='The name of a file containing a list of files, one per line, '
123 'identifying the Javascript to include in HTML <head>. This is an '
124 'alternate to specifying the files directly via the "--js" option. '
125 'The files listed in this file are appended to the files passed via '
126 'the "--js" option, if any.')
117 parser.add_argument( 127 parser.add_argument(
118 '--templates', 128 '--templates',
119 nargs='*', 129 nargs='*',
120 default=[], 130 default=[],
121 help='The html template files used by input-template') 131 help='The html template files used by input-template')
122 parser.add_argument( 132 parser.add_argument(
123 '--exclude-js', 133 '--exclude-js',
124 nargs='*', 134 nargs='*',
125 default=[], 135 default=[],
126 help='The Javascript files to exclude from <--js> and <--instrumentedjs>') 136 help='The Javascript files to exclude from <--js> and <--instrumentedjs>')
127 parser.add_argument( 137 parser.add_argument(
128 '--instrument-js', 138 '--instrument-js',
129 nargs='*', 139 nargs='*',
130 default=[], 140 default=[],
131 help='Javascript to include and instrument for code coverage') 141 help='Javascript to include and instrument for code coverage')
132 parser.add_argument( 142 parser.add_argument(
133 '--template-dir', 143 '--template-dir',
134 default = ".", 144 default = ".",
135 help='Directory template references in html are relative to') 145 help='Directory template references in html are relative to')
136 parser.add_argument('output_file') 146 parser.add_argument('output_file')
137 parser.add_argument('input_template') 147 parser.add_argument('input_template')
138 return parser.parse_args(sys.argv[1:]) 148 return parser.parse_args(sys.argv[1:])
139 149
140 150
141 def main(): 151 def main():
142 args = parseArgs() 152 args = parseArgs()
143 153
144 out_file = args.output_file 154 out_file = args.output_file
145 js_files = set(args.js) - set(args.exclude_js) 155 js_files = set(args.js)
156
157 # Load the files from the --js-list-file.
158 js_list_file = args.js_list_file
159 if js_list_file:
160 js_files = js_files.union(set(line.rstrip() for line in open(js_list_file)))
161
162 js_files = js_files - set(args.exclude_js)
146 instrumented_js_files = set(args.instrument_js) - set(args.exclude_js) 163 instrumented_js_files = set(args.instrument_js) - set(args.exclude_js)
147 164
148 # Create the output directory if it does not exist. 165 # Create the output directory if it does not exist.
149 out_directory = os.path.dirname(out_file) 166 out_directory = os.path.dirname(out_file)
150 if out_directory is not '' and not os.path.exists(out_directory): 167 if out_directory is not '' and not os.path.exists(out_directory):
151 os.makedirs(out_directory) 168 os.makedirs(out_directory)
152 169
153 # Generate the main HTML file from the templates. 170 # Generate the main HTML file from the templates.
154 with open(out_file, 'w') as output: 171 with open(out_file, 'w') as output:
155 gen = GenerateWebappHtml(args.templates, js_files, instrumented_js_files, 172 gen = GenerateWebappHtml(args.templates, js_files, instrumented_js_files,
156 args.template_dir) 173 args.template_dir)
157 gen.processTemplate(output, args.input_template, 0) 174 gen.processTemplate(output, args.input_template, 0)
158 175
159 # Verify that all the expected templates were found. 176 # Verify that all the expected templates were found.
160 if not gen.verifyTemplateList(): 177 if not gen.verifyTemplateList():
161 error('Extra templates specified') 178 error('Extra templates specified')
162 179
163 # Verify that the generated HTML file is valid. 180 # Verify that the generated HTML file is valid.
164 with open(out_file, 'r') as input_html: 181 with open(out_file, 'r') as input_html:
165 parser = HtmlChecker() 182 parser = HtmlChecker()
166 parser.feed(input_html.read()) 183 parser.feed(input_html.read())
167 184
168 185
169 if __name__ == '__main__': 186 if __name__ == '__main__':
170 sys.exit(main()) 187 sys.exit(main())
OLDNEW
« no previous file with comments | « remoting/webapp/BUILD.gn ('k') | remoting/webapp/files.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698