| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 sys.stdout.flush() | 43 sys.stdout.flush() |
| 44 | 44 |
| 45 if utils.GuessOS() == 'win32': | 45 if utils.GuessOS() == 'win32': |
| 46 return subprocess.call(['mklink', '/j', target, source], shell=True) | 46 return subprocess.call(['mklink', '/j', target, source], shell=True) |
| 47 else: | 47 else: |
| 48 return subprocess.call(['ln', '-s', source, target]) | 48 return subprocess.call(['ln', '-s', source, target]) |
| 49 | 49 |
| 50 | 50 |
| 51 def main(argv): | 51 def main(argv): |
| 52 target = os.path.relpath(argv[1]) | 52 target = os.path.relpath(argv[1]) |
| 53 if not os.path.exists(target): |
| 54 os.makedirs(target) |
| 53 for source in argv[2:]: | 55 for source in argv[2:]: |
| 54 # Assume the source directory is named ".../TARGET_NAME/lib". | 56 # Assume the source directory is named ".../NAME/lib". |
| 55 (name, lib) = os.path.split(source) | 57 (name, lib) = os.path.split(source) |
| 56 if lib != 'lib': | 58 if lib != 'lib': |
| 57 name = source | 59 name = source |
| 58 # Remove any addtional path components preceding TARGET_NAME. | 60 # Remove any addtional path components preceding NAME. |
| 59 (path, name) = os.path.split(name) | 61 (path, name) = os.path.split(name) |
| 60 if utils.GuessOS() == 'win32': | 62 if utils.GuessOS() == 'win32': |
| 61 source = os.path.relpath(source) | 63 source = os.path.relpath(source) |
| 62 else: | 64 else: |
| 63 source = os.path.relpath(source, start=target) | 65 source = os.path.relpath(source, start=target) |
| 64 exit_code = make_link(source, os.path.join(target, name)) | 66 exit_code = make_link(source, os.path.join(target, name)) |
| 65 if exit_code != 0: | 67 if exit_code != 0: |
| 66 return exit_code | 68 return exit_code |
| 67 return 0 | 69 return 0 |
| 68 | 70 |
| 69 | 71 |
| 70 if __name__ == '__main__': | 72 if __name__ == '__main__': |
| 71 sys.exit(main(sys.argv)) | 73 sys.exit(main(sys.argv)) |
| OLD | NEW |