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: Source/devtools/scripts/generate_devtools_html.py

Issue 646413002: DevTools: Refactor build script to copy module files in debug_devtools mode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed, GN fixed, obsolete file removed Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2010 Google Inc. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
14 # distribution.
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #
31
32 from os import path
33 import os
34 import sys
35
36
37 def generate_include_tag(resource_path):
38 if (resource_path.endswith('.js')):
39 return ' <script type="text/javascript" src="%s"></script>\n' % resou rce_path
40 elif (resource_path.endswith('.css')):
41 return ' <link rel="stylesheet" type="text/css" href="%s">\n' % resou rce_path
42 else:
43 assert resource_path
44
45
46 def write_app_input_html(app_input_file, app_output_file, application_name, debu g):
47 for line in app_input_file:
48 if not debug:
49 if '<script ' in line or '<link ' in line:
50 continue
51 if '</head>' in line:
52 app_output_file.write(generate_include_tag("%s.css" % applicatio n_name))
53 app_output_file.write(generate_include_tag("%s.js" % application _name))
54 app_output_file.write(line)
55
56
57 def main(argv):
58
59 if len(argv) < 4:
60 print('usage: %s app_input_html generated_app_html debug' % argv[0])
61 return 1
62 # The first argument is ignored. We put 'web.gyp' in the inputs list
63 # for this script, so every time the list of script gets changed, our html
64 # file is rebuilt.
65 app_input_html_name = argv[1]
66 app_output_html_name = argv[2]
67 debug = argv[3] != '0'
68 application_name = path.splitext(path.basename(app_input_html_name))[0]
69 with open(app_input_html_name, 'r') as app_input_html:
70 with open(app_output_html_name, 'w') as app_output_html:
71 write_app_input_html(app_input_html, app_output_html, application_na me, debug)
72
73 if __name__ == '__main__':
74 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698