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

Side by Side Diff: build/symlink.py

Issue 16096006: Skip argv[0] when processing command line options in symlink.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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
11 import os.path 11 import os.path
12 import sys 12 import sys
13 13
14 14
15 def Main(argv): 15 def Main(argv):
16 parser = optparse.OptionParser() 16 parser = optparse.OptionParser()
17 parser.add_option('-f', '--force', action='store_true') 17 parser.add_option('-f', '--force', action='store_true')
18 parser.add_option('--touch') 18 parser.add_option('--touch')
19 19
20 options, args = parser.parse_args(argv) 20 options, args = parser.parse_args(argv[1:])
21 if len(args) < 2: 21 if len(args) < 2:
22 parser.error('at least two arguments required.') 22 parser.error('at least two arguments required.')
23 23
24 target = args[-1] 24 target = args[-1]
25 sources = args[:-1] 25 sources = args[:-1]
26 for s in sources: 26 for s in sources:
27 t = os.path.join(target, os.path.basename(s)) 27 t = os.path.join(target, os.path.basename(s))
28 try: 28 try:
29 os.symlink(s, t) 29 os.symlink(s, t)
30 except OSError, e: 30 except OSError, e:
31 if e.errno == errno.EEXIST and options.force: 31 if e.errno == errno.EEXIST and options.force:
32 os.remove(t) 32 os.remove(t)
33 os.symlink(s, t) 33 os.symlink(s, t)
34 else: 34 else:
35 raise 35 raise
36 36
37 37
38 if options.touch: 38 if options.touch:
39 with open(options.touch, 'w') as f: 39 with open(options.touch, 'w') as f:
40 pass 40 pass
41 41
42 42
43 if __name__ == '__main__': 43 if __name__ == '__main__':
44 sys.exit(Main(sys.argv)) 44 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