| OLD | NEW |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 # If the packages directory already exists, delete the current links inside | 66 # If the packages directory already exists, delete the current links inside |
| 67 # it. 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 for link in os.listdir(target): | 69 for link in os.listdir(target): |
| 70 os.remove(os.path.join(target, link)) | 70 if utils.GuessOS() == 'win32': |
| 71 # It seems like python on windows is treating pseudo symlinks to |
| 72 # directories as directories. |
| 73 os.rmdir(os.path.join(target, link)) |
| 74 else: |
| 75 os.remove(os.path.join(target, link)) |
| 71 else: | 76 else: |
| 72 os.makedirs(target) | 77 os.makedirs(target) |
| 73 for source in args[1:]: | 78 for source in args[1:]: |
| 74 # Assume the source directory is named ".../NAME/lib". | 79 # Assume the source directory is named ".../NAME/lib". |
| 75 (name, lib) = os.path.split(source) | 80 (name, lib) = os.path.split(source) |
| 76 if lib != 'lib': | 81 if lib != 'lib': |
| 77 name = source | 82 name = source |
| 78 # Remove any addtional path components preceding NAME. | 83 # Remove any addtional path components preceding NAME. |
| 79 (path, name) = os.path.split(name) | 84 (path, name) = os.path.split(name) |
| 80 if utils.GuessOS() == 'win32': | 85 if utils.GuessOS() == 'win32': |
| 81 source = os.path.relpath(source) | 86 source = os.path.relpath(source) |
| 82 else: | 87 else: |
| 83 source = os.path.relpath(source, start=target) | 88 source = os.path.relpath(source, start=target) |
| 84 exit_code = make_link(source, os.path.join(target, name)) | 89 exit_code = make_link(source, os.path.join(target, name)) |
| 85 if exit_code != 0: | 90 if exit_code != 0: |
| 86 return exit_code | 91 return exit_code |
| 87 create_timestamp_file(options) | 92 create_timestamp_file(options) |
| 88 return 0 | 93 return 0 |
| 89 | 94 |
| 90 | 95 |
| 91 if __name__ == '__main__': | 96 if __name__ == '__main__': |
| 92 sys.exit(main(sys.argv)) | 97 sys.exit(main(sys.argv)) |
| OLD | NEW |