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

Side by Side Diff: dart/tools/make_links.py

Issue 32113003: Use os.remove() instead of shutil.rmtree() since the latter actually does follow pseudo-symlinks on… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 6
7 '''Tool for creating symlinks from SOURCES to TARGET. 7 '''Tool for creating symlinks from SOURCES to TARGET.
8 8
9 For each SOURCE in SOURCES create a link from SOURCE to TARGET. If a 9 For each SOURCE in SOURCES create a link from SOURCE to TARGET. If a
10 SOURCE ends with .../lib, the lib suffix is ignored when determining 10 SOURCE ends with .../lib, the lib suffix is ignored when determining
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 dir_name = os.path.dirname(options.timestamp_file) 56 dir_name = os.path.dirname(options.timestamp_file)
57 if not os.path.exists(dir_name): 57 if not os.path.exists(dir_name):
58 os.mkdir(dir_name) 58 os.mkdir(dir_name)
59 open(options.timestamp_file, 'w').close() 59 open(options.timestamp_file, 'w').close()
60 60
61 61
62 def main(argv): 62 def main(argv):
63 (options, args) = get_options() 63 (options, args) = get_options()
64 target = os.path.relpath(args[0]) 64 target = os.path.relpath(args[0])
65 if os.path.exists(target): 65 if os.path.exists(target):
66 # Remove the packages directory if it already exists. 66 # If the packages directory already exists, delete the current links inside
67 # This is necessary, otherwise we can end up having links in there 67 # it. This is necessary, otherwise we can end up having links in there
68 # pointing to directories which no longer exist (on incremental builds). 68 # pointing to directories which no longer exist (on incremental builds).
69 print 'Removing %s' % target 69 for link in os.listdir(target):
70 shutil.rmtree(target) 70 os.remove(os.path.join(target, link))
kustermann 2013/10/23 08:10:29 If os.remove() raises on these pseudo-symlinks, I'
71 os.makedirs(target) 71 else:
72 os.makedirs(target)
72 for source in args[1:]: 73 for source in args[1:]:
73 # Assume the source directory is named ".../NAME/lib". 74 # Assume the source directory is named ".../NAME/lib".
74 (name, lib) = os.path.split(source) 75 (name, lib) = os.path.split(source)
75 if lib != 'lib': 76 if lib != 'lib':
76 name = source 77 name = source
77 # Remove any addtional path components preceding NAME. 78 # Remove any addtional path components preceding NAME.
78 (path, name) = os.path.split(name) 79 (path, name) = os.path.split(name)
79 if utils.GuessOS() == 'win32': 80 if utils.GuessOS() == 'win32':
80 source = os.path.relpath(source) 81 source = os.path.relpath(source)
81 else: 82 else:
82 source = os.path.relpath(source, start=target) 83 source = os.path.relpath(source, start=target)
83 exit_code = make_link(source, os.path.join(target, name)) 84 exit_code = make_link(source, os.path.join(target, name))
84 if exit_code != 0: 85 if exit_code != 0:
85 return exit_code 86 return exit_code
86 create_timestamp_file(options) 87 create_timestamp_file(options)
87 return 0 88 return 0
88 89
89 90
90 if __name__ == '__main__': 91 if __name__ == '__main__':
91 sys.exit(main(sys.argv)) 92 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