OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 import os.path | 6 import os.path |
7 import sys | 7 import sys |
8 | 8 |
9 def GenerateIncludeTag(resource_path): | 9 def GenerateIncludeTag(resource_path): |
10 (dir_name, file_name) = os.path.split(resource_path) | 10 (dir_name, file_name) = os.path.split(resource_path) |
11 if (file_name.endswith('.js')): | 11 if (file_name.endswith('.js')): |
12 return ' <script type="text/javascript" src="%s"></script>\n' % file_name | 12 return ' <script type="text/javascript" src="%s"></script>\n' % file_name |
13 elif (file_name.endswith('.css')): | 13 elif (file_name.endswith('.css')): |
14 return ' <link rel="stylesheet" type="text/css" href="%s">\n' % file_name | 14 return ' <link rel="stylesheet" type="text/css" href="%s">\n' % file_name |
15 else: | 15 else: |
16 assert false | 16 assert false |
17 | 17 |
18 | 18 |
19 def main(argv): | 19 def main(argv): |
20 | 20 |
21 if len(argv) < 4: | 21 if len(argv) < 4: |
22 print 'usage: %s inspector_html devtools_html css_and_js_files_list' % argv[
0] | 22 print('usage: %s ignored inspector_html devtools_html' |
| 23 ' css_and_js_files_list' % argv[0]) |
23 return 1 | 24 return 1 |
24 | 25 |
25 inspector_html_name = argv[1] | 26 # The first argument is ignored. We put 'webkit.gyp' in the inputs list |
26 devtools_html_name = argv[2] | 27 # for this script, so every time the list of script gets changed, our html |
| 28 # file is rebuilt. |
| 29 inspector_html_name = argv[2] |
| 30 devtools_html_name = argv[3] |
27 inspector_html = open(inspector_html_name, 'r') | 31 inspector_html = open(inspector_html_name, 'r') |
28 devtools_html = open(devtools_html_name, 'w') | 32 devtools_html = open(devtools_html_name, 'w') |
29 | 33 |
30 for line in inspector_html: | 34 for line in inspector_html: |
31 if '</head>' in line: | 35 if '</head>' in line: |
32 devtools_html.write('\n <!-- The following lines are added to include D
evTools resources -->\n') | 36 devtools_html.write('\n <!-- The following lines are added to include D
evTools resources -->\n') |
33 for resource in argv[3:]: | 37 for resource in argv[4:]: |
34 devtools_html.write(GenerateIncludeTag(resource)) | 38 devtools_html.write(GenerateIncludeTag(resource)) |
35 devtools_html.write(' <!-- End of auto-added files list -->\n') | 39 devtools_html.write(' <!-- End of auto-added files list -->\n') |
36 devtools_html.write(line) | 40 devtools_html.write(line) |
37 | 41 |
38 devtools_html.close() | 42 devtools_html.close() |
39 inspector_html.close() | 43 inspector_html.close() |
40 | 44 |
41 # Touch output file directory to make sure that Xcode will copy | 45 # Touch output file directory to make sure that Xcode will copy |
42 # modified resource files. | 46 # modified resource files. |
43 if sys.platform == 'darwin': | 47 if sys.platform == 'darwin': |
44 output_dir_name = os.path.dirname(devtools_html_name) | 48 output_dir_name = os.path.dirname(devtools_html_name) |
45 os.utime(output_dir_name, None) | 49 os.utime(output_dir_name, None) |
46 | 50 |
47 if __name__ == '__main__': | 51 if __name__ == '__main__': |
48 sys.exit(main(sys.argv)) | 52 sys.exit(main(sys.argv)) |
OLD | NEW |