3 # Copyright (C) 2010 Google Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
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
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.
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.
36 def generate_include_tag(resource_path):
37 (dir_name, file_name) = os.path.split(resource_path)
38 if (file_name.endswith('.js')):
39 return ' <script type="text/javascript" src="%s"></script>\n' % file_name
40 elif (file_name.endswith('.css')):
41 return ' <link rel="stylesheet" type="text/css" href="%s">\n' % file_name
46 def write_devtools_html(inspector_file, devtools_file, debug, debug_files):
47 for line in inspector_file:
48 if not debug and '<script ' in line:
50 if not debug and '<link ' in line:
54 for resource in debug_files:
55 devtools_file.write(generate_include_tag(resource))
57 devtools_file.write(generate_include_tag("devTools.css"))
58 devtools_file.write(generate_include_tag("DevTools.js"))
59 devtools_file.write(line)
61 devtools_file.write(generate_include_tag("buildSystemOnly.js"))
67 print('usage: %s inspector_html devtools_html debug'
68 ' css_and_js_files_list' % argv[0])
71 # The first argument is ignored. We put 'webkit.gyp' in the inputs list
72 # for this script, so every time the list of script gets changed, our html
74 inspector_html_name = argv[1]
75 devtools_html_name = argv[2]
76 debug = argv[3] != '0'
77 inspector_html = open(inspector_html_name, 'r')
78 devtools_html = open(devtools_html_name, 'w')
80 write_devtools_html(inspector_html, devtools_html, debug, argv[4:])
83 inspector_html.close()
85 # Touch output file directory to make sure that Xcode will copy
86 # modified resource files.
87 if sys.platform == 'darwin':
88 output_dir_name = os.path.dirname(devtools_html_name)
89 os.utime(output_dir_name, None)
91 if __name__ == '__main__':
92 sys.exit(main(sys.argv))