| 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 |
| 11 the name of the target link. | 11 the name of the target link. |
| 12 | 12 |
| 13 Usage: | 13 Usage: |
| 14 python tools/make_links.py TARGET SOURCES... | 14 python tools/make_links.py TARGET SOURCES... |
| 15 ''' | 15 ''' |
| 16 | 16 |
| 17 import os | 17 import os |
| 18 import subprocess | 18 import subprocess |
| 19 import sys | 19 import sys |
| 20 import utils | 20 import utils |
| 21 | 21 |
| 22 | 22 |
| 23 def make_link(source, target): | 23 def make_link(source, target): |
| 24 # TODO(ahe): Remove this code when the build bots are green again. | |
| 25 bug_cleanup = os.path.join(target, 'lib') | |
| 26 if os.path.islink(bug_cleanup): | |
| 27 print 'Removing %s' % bug_cleanup | |
| 28 sys.stdout.flush() | |
| 29 os.unlink(bug_cleanup) | |
| 30 # End of temporary code. | |
| 31 | |
| 32 if os.path.islink(target): | 24 if os.path.islink(target): |
| 33 print 'Removing %s' % target | 25 print 'Removing %s' % target |
| 34 sys.stdout.flush() | 26 sys.stdout.flush() |
| 35 os.unlink(target) | 27 os.unlink(target) |
| 36 | 28 |
| 37 if os.path.isdir(target): | 29 if os.path.isdir(target): |
| 38 print 'Removing %s' % target | 30 print 'Removing %s' % target |
| 39 sys.stdout.flush() | 31 sys.stdout.flush() |
| 40 os.rmdir(target) | 32 os.rmdir(target) |
| 41 | 33 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 64 else: | 56 else: |
| 65 source = os.path.relpath(source, start=target) | 57 source = os.path.relpath(source, start=target) |
| 66 exit_code = make_link(source, os.path.join(target, name)) | 58 exit_code = make_link(source, os.path.join(target, name)) |
| 67 if exit_code != 0: | 59 if exit_code != 0: |
| 68 return exit_code | 60 return exit_code |
| 69 return 0 | 61 return 0 |
| 70 | 62 |
| 71 | 63 |
| 72 if __name__ == '__main__': | 64 if __name__ == '__main__': |
| 73 sys.exit(main(sys.argv)) | 65 sys.exit(main(sys.argv)) |
| OLD | NEW |