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

Side by Side Diff: webkit/support/setup_third_party.py

Issue 8930019: Use a shorter include paths on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | 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/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 """A helper script for setting up forwarding headers.""" 6 """A helper script for setting up forwarding headers."""
7 7
8 import errno 8 import errno
9 import os 9 import os
10 import sys 10 import sys
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 out_filename = NormalizePath(out_filename) 96 out_filename = NormalizePath(out_filename)
97 ancestor = os.path.commonprefix([input_filename, out_filename]) 97 ancestor = os.path.commonprefix([input_filename, out_filename])
98 98
99 assert os.path.isdir(ancestor) 99 assert os.path.isdir(ancestor)
100 num_parent_dirs = 0 100 num_parent_dirs = 0
101 out_dir = os.path.split(out_filename)[0] 101 out_dir = os.path.split(out_filename)[0]
102 while os.path.normpath(ancestor) != os.path.normpath(out_dir): 102 while os.path.normpath(ancestor) != os.path.normpath(out_dir):
103 num_parent_dirs += 1 103 num_parent_dirs += 1
104 out_dir = os.path.split(out_dir)[0] 104 out_dir = os.path.split(out_dir)[0]
105 105
106 rel_path = os.path.join('/'.join(['..'] * num_parent_dirs), 106 if sys.platform == 'win32':
107 input_filename[len(ancestor):]) 107 # Windows has a file path limit of 260 characters that we can hit when
M-A Ruel 2011/12/15 01:19:37 Why not do the same on all platforms?
108 # generating these forwarding headers. Instead of writing the full
109 # relative path, just write the path relative to the WebKit/chromium dir,
110 # which is in the include path.
111 rel_path = input_filename[len(ancestor):]
112 else:
113 rel_path = os.path.join('/'.join(['..'] * num_parent_dirs),
114 input_filename[len(ancestor):])
108 115
109 out_file = open(out_filename, 'w') 116 out_file = open(out_filename, 'w')
110 out_file.write("""// This file is generated. Do not edit. 117 out_file.write("""// This file is generated. Do not edit.
111 #include "%s" 118 #include "%s"
112 """ % rel_path) 119 """ % rel_path)
113 out_file.close() 120 out_file.close()
114 121
115 122
116 def Main(argv): 123 def Main(argv):
117 commands = { 124 commands = {
118 'inputs': Inputs, 125 'inputs': Inputs,
119 'outputs': Outputs, 126 'outputs': Outputs,
120 'setup_headers': SetupHeaders, 127 'setup_headers': SetupHeaders,
121 } 128 }
122 command = argv[1] 129 command = argv[1]
123 args = argv[2:] 130 args = argv[2:]
124 return commands[command](args) 131 return commands[command](args)
125 132
126 133
127 if __name__ == '__main__': 134 if __name__ == '__main__':
128 sys.exit(Main(sys.argv)) 135 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698