OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
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 | |
4 # BSD-style license that can be found in the LICENSE file. | |
5 | |
6 | |
7 '''Tool for creating symlinks from SOURCES to TARGET. | |
8 | |
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 | |
11 the name of the target link. | |
12 | |
13 Usage: | |
14 python tools/make_links.py TARGET SOURCES... | |
15 ''' | |
16 | |
17 import os | |
18 import subprocess | |
19 import sys | |
20 import utils | |
21 | |
22 | |
23 def make_link(source, target): | |
24 if utils.GuessOS() == 'win32': | |
25 return subprocess.call(['mklink', '/j', target, source]) | |
26 else: | |
27 return subprocess.call(['ln', '-s', source, target]) | |
28 | |
29 | |
30 def main(argv): | |
31 target = argv[1] | |
32 for source in argv[2:]: | |
33 # Assume the source directory is named ".../TARGET_NAME/lib". | |
34 (name, lib) = os.path.split(source) | |
35 if lib != 'lib': | |
36 name = source | |
37 # Remove any addtional path components preceding TARGET_NAME. | |
38 (path, name) = os.path.split(name) | |
39 exit_code = make_link(os.path.relpath(source, start=target), | |
40 os.path.join(target, name)) | |
41 if exit_code != 0: | |
42 return exit_code | |
43 return 0 | |
44 | |
45 | |
46 if __name__ == '__main__': | |
47 sys.exit(main(sys.argv)) | |
OLD | NEW |