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

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

Issue 343653006: Handle deletion of files in package dir on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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
« 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 67
68 def main(argv): 68 def main(argv):
69 (options, args) = get_options() 69 (options, args) = get_options()
70 target = os.path.relpath(args[0]) 70 target = os.path.relpath(args[0])
71 if os.path.exists(target): 71 if os.path.exists(target):
72 # If the packages directory already exists, delete the current links inside 72 # If the packages directory already exists, delete the current links inside
73 # it. This is necessary, otherwise we can end up having links in there 73 # it. This is necessary, otherwise we can end up having links in there
74 # pointing to directories which no longer exist (on incremental builds). 74 # pointing to directories which no longer exist (on incremental builds).
75 for link in os.listdir(target): 75 for link in os.listdir(target):
76 if utils.GuessOS() == 'win32': 76 full_link = os.path.join(target, link)
77 # It seems like python on windows is treating pseudo symlinks to 77 if os.path.isdir(full_link) and utils.IsWindows():
78 # It seems like python on Windows is treating pseudo symlinks to
78 # directories as directories. 79 # directories as directories.
79 os.rmdir(os.path.join(target, link)) 80 os.rmdir(full_link)
80 else: 81 else:
81 os.remove(os.path.join(target, link)) 82 os.remove(full_link)
82 else: 83 else:
83 os.makedirs(target) 84 os.makedirs(target)
84 for source in args[1:]: 85 for source in args[1:]:
85 # Assume the source directory is named ".../NAME/lib". 86 # Assume the source directory is named ".../NAME/lib".
86 (name, lib) = os.path.split(source) 87 (name, lib) = os.path.split(source)
87 if lib != 'lib': 88 if lib != 'lib':
88 name = source 89 name = source
89 # Remove any addtional path components preceding NAME. 90 # Remove any addtional path components preceding NAME.
90 (path, name) = os.path.split(name) 91 (path, name) = os.path.split(name)
91 orig_source = source 92 orig_source = source
92 if utils.GuessOS() == 'win32': 93 if utils.GuessOS() == 'win32':
93 source = os.path.relpath(source) 94 source = os.path.relpath(source)
94 else: 95 else:
95 source = os.path.relpath(source, start=target) 96 source = os.path.relpath(source, start=target)
96 exit_code = make_link(source, os.path.join(target, name), orig_source) 97 exit_code = make_link(source, os.path.join(target, name), orig_source)
97 if exit_code != 0: 98 if exit_code != 0:
98 return exit_code 99 return exit_code
99 create_timestamp_file(options) 100 create_timestamp_file(options)
100 return 0 101 return 0
101 102
102 103
103 if __name__ == '__main__': 104 if __name__ == '__main__':
104 sys.exit(main(sys.argv)) 105 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