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

Side by Side Diff: tools/make_links.py

Issue 15870012: Add packages as a dependency for dart2js target (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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 | Annotate | Revision Log
« no previous file with comments | « pkg/pkg.gyp ('k') | utils/compiler/compiler.gyp » ('j') | 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) 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 OPTIONS TARGET SOURCES...
15 ''' 15 '''
16 16
17 import optparse
17 import os 18 import os
18 import subprocess 19 import subprocess
19 import sys 20 import sys
20 import utils 21 import utils
21 22
22 23
24 def get_options():
25 result = optparse.OptionParser()
26 result.add_option("--timestamp_file", "",
27 help='Create a timestamp file when done creating the links.',
28 default='')
29 return result.parse_args()
30
23 def make_link(source, target): 31 def make_link(source, target):
24 if os.path.islink(target): 32 if os.path.islink(target):
25 print 'Removing %s' % target 33 print 'Removing %s' % target
26 sys.stdout.flush() 34 sys.stdout.flush()
27 os.unlink(target) 35 os.unlink(target)
28 36
29 if os.path.isdir(target): 37 if os.path.isdir(target):
30 print 'Removing %s' % target 38 print 'Removing %s' % target
31 sys.stdout.flush() 39 sys.stdout.flush()
32 os.rmdir(target) 40 os.rmdir(target)
33 41
34 print 'Creating link from %s to %s' % (source, target) 42 print 'Creating link from %s to %s' % (source, target)
35 sys.stdout.flush() 43 sys.stdout.flush()
36 44
37 if utils.GuessOS() == 'win32': 45 if utils.GuessOS() == 'win32':
38 return subprocess.call(['mklink', '/j', target, source], shell=True) 46 return subprocess.call(['mklink', '/j', target, source], shell=True)
39 else: 47 else:
40 return subprocess.call(['ln', '-s', source, target]) 48 return subprocess.call(['ln', '-s', source, target])
41 49
50 def create_timestamp_file(options):
51 if options.timestamp_file != '':
52 dir_name = os.path.dirname(options.timestamp_file)
53 if not os.path.exists(dir_name):
54 os.mkdir(dir_name)
55 open(options.timestamp_file, 'w').close()
56
42 57
43 def main(argv): 58 def main(argv):
44 target = os.path.relpath(argv[1]) 59 (options, args) = get_options()
60 target = os.path.relpath(args[0])
45 if not os.path.exists(target): 61 if not os.path.exists(target):
46 os.makedirs(target) 62 os.makedirs(target)
47 for source in argv[2:]: 63 for source in args[1:]:
48 # Assume the source directory is named ".../NAME/lib". 64 # Assume the source directory is named ".../NAME/lib".
49 (name, lib) = os.path.split(source) 65 (name, lib) = os.path.split(source)
50 if lib != 'lib': 66 if lib != 'lib':
51 name = source 67 name = source
52 # Remove any addtional path components preceding NAME. 68 # Remove any addtional path components preceding NAME.
53 (path, name) = os.path.split(name) 69 (path, name) = os.path.split(name)
54 if utils.GuessOS() == 'win32': 70 if utils.GuessOS() == 'win32':
55 source = os.path.relpath(source) 71 source = os.path.relpath(source)
56 else: 72 else:
57 source = os.path.relpath(source, start=target) 73 source = os.path.relpath(source, start=target)
58 exit_code = make_link(source, os.path.join(target, name)) 74 exit_code = make_link(source, os.path.join(target, name))
59 if exit_code != 0: 75 if exit_code != 0:
60 return exit_code 76 return exit_code
77 create_timestamp_file(options)
61 return 0 78 return 0
62 79
63 80
64 if __name__ == '__main__': 81 if __name__ == '__main__':
65 sys.exit(main(sys.argv)) 82 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « pkg/pkg.gyp ('k') | utils/compiler/compiler.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698