Chromium Code Reviews| 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') | |
|
ahe
2012/11/19 11:50:11
Using target here as source is relative to BUILD_R
| |
| 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 | |
| 24 if os.path.islink(target): | 32 if os.path.islink(target): |
| 25 os.unlink(target) | 33 os.unlink(target) |
| 26 | 34 |
| 27 # TODO(ahe): Remove this code when the build bots are green again. | |
| 28 bug_cleanup = os.path.join(source, 'lib') | |
| 29 if os.path.islink(bug_cleanup): | |
| 30 print 'Removing %s' % bug_cleanup | |
| 31 os.unlink(bug_cleanup) | |
| 32 # End of temporary code. | |
| 33 | |
| 34 if utils.GuessOS() == 'win32': | 35 if utils.GuessOS() == 'win32': |
| 35 return subprocess.call(['mklink', '/j', target, source]) | 36 return subprocess.call(['mklink', '/j', target, source]) |
| 36 else: | 37 else: |
| 37 return subprocess.call(['ln', '-s', source, target]) | 38 return subprocess.call(['ln', '-s', source, target]) |
| 38 | 39 |
| 39 | 40 |
| 40 def main(argv): | 41 def main(argv): |
| 41 target = argv[1] | 42 target = argv[1] |
| 42 for source in argv[2:]: | 43 for source in argv[2:]: |
| 43 # Assume the source directory is named ".../TARGET_NAME/lib". | 44 # Assume the source directory is named ".../TARGET_NAME/lib". |
| 44 (name, lib) = os.path.split(source) | 45 (name, lib) = os.path.split(source) |
| 45 if lib != 'lib': | 46 if lib != 'lib': |
| 46 name = source | 47 name = source |
| 47 # Remove any addtional path components preceding TARGET_NAME. | 48 # Remove any addtional path components preceding TARGET_NAME. |
| 48 (path, name) = os.path.split(name) | 49 (path, name) = os.path.split(name) |
| 49 exit_code = make_link(os.path.relpath(source, start=target), | 50 exit_code = make_link(os.path.relpath(source, start=target), |
| 50 os.path.join(target, name)) | 51 os.path.join(target, name)) |
| 51 if exit_code != 0: | 52 if exit_code != 0: |
| 52 return exit_code | 53 return exit_code |
| 53 return 0 | 54 return 0 |
| 54 | 55 |
| 55 | 56 |
| 56 if __name__ == '__main__': | 57 if __name__ == '__main__': |
| 57 sys.exit(main(sys.argv)) | 58 sys.exit(main(sys.argv)) |
| OLD | NEW |