Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: build/symlink.py

Issue 1632073002: dont symlink if it's already correctly linked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Make a symlink and optionally touch a file (to handle dependencies).""" 6 """Make a symlink and optionally touch a file (to handle dependencies)."""
7 7
8 8
9 import errno 9 import errno
10 import optparse 10 import optparse
(...skipping 10 matching lines...) Expand all
21 options, args = parser.parse_args(argv[1:]) 21 options, args = parser.parse_args(argv[1:])
22 if len(args) < 2: 22 if len(args) < 2:
23 parser.error('at least two arguments required.') 23 parser.error('at least two arguments required.')
24 24
25 target = args[-1] 25 target = args[-1]
26 sources = args[:-1] 26 sources = args[:-1]
27 for s in sources: 27 for s in sources:
28 t = os.path.join(target, os.path.basename(s)) 28 t = os.path.join(target, os.path.basename(s))
29 if len(sources) == 1 and not os.path.isdir(target): 29 if len(sources) == 1 and not os.path.isdir(target):
30 t = target 30 t = target
31 if os.path.realpath(t) == s:
32 continue
31 try: 33 try:
32 os.symlink(s, t) 34 os.symlink(s, t)
33 except OSError, e: 35 except OSError, e:
34 if e.errno == errno.EEXIST and options.force: 36 if e.errno == errno.EEXIST and options.force:
35 if os.path.isdir(t): 37 if os.path.isdir(t):
36 shutil.rmtree(t, ignore_errors=True) 38 shutil.rmtree(t, ignore_errors=True)
37 else: 39 else:
38 os.remove(t) 40 os.remove(t)
39 os.symlink(s, t) 41 os.symlink(s, t)
40 else: 42 else:
41 raise 43 raise
42 44
43 45
44 if options.touch: 46 if options.touch:
45 with open(options.touch, 'w') as f: 47 with open(options.touch, 'w') as f:
46 pass 48 pass
47 49
48 50
49 if __name__ == '__main__': 51 if __name__ == '__main__':
50 sys.exit(Main(sys.argv)) 52 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698