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

Side by Side Diff: tools/create_sdk.py

Issue 13979006: Pass in arguments to create_sdk instead of using positional command line arguments (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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
« dart.gyp ('K') | « dart.gyp ('k') | 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 # 2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 # A script which will be invoked from gyp to create an SDK. 7 # A script which will be invoked from gyp to create an SDK.
8 # 8 #
9 # Usage: create_sdk.py sdk_directory 9 # Usage: create_sdk.py sdk_directory
10 # 10 #
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 # ......unittest/ 48 # ......unittest/
49 # ......(more will come here) 49 # ......(more will come here)
50 # ....util/ 50 # ....util/
51 # ......analyzer/ 51 # ......analyzer/
52 # ........dart_analyzer.jar 52 # ........dart_analyzer.jar
53 # ........(third-party libraries for dart_analyzer) 53 # ........(third-party libraries for dart_analyzer)
54 # ......pub/ 54 # ......pub/
55 # ......(more will come here) 55 # ......(more will come here)
56 56
57 57
58 58 import optparse
59 import os 59 import os
60 import re 60 import re
61 import sys 61 import sys
62 import subprocess 62 import subprocess
63 import tempfile 63 import tempfile
64 import utils 64 import utils
65 65
66 HOST_OS = utils.GuessOS() 66 HOST_OS = utils.GuessOS()
67 67
68 # TODO(dgrove): Only import modules following Google style guide. 68 # TODO(dgrove): Only import modules following Google style guide.
69 from os.path import basename, dirname, join, realpath, exists, isdir 69 from os.path import basename, dirname, join, realpath, exists, isdir
70 70
71 # TODO(dgrove): Only import modules following Google style guide. 71 # TODO(dgrove): Only import modules following Google style guide.
72 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move 72 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move
73 73
74
75 def GetOptions():
76 options = optparse.OptionParser(usage='usage: %prog [options]')
77 options.add_option("--sdk_output_dir",
78 help='Where to output the sdk')
79 options.add_option("--utils_snapshot_location",
80 help='Location of the utils snapshot.')
81 return options.parse_args()
82
83
74 def ReplaceInFiles(paths, subs): 84 def ReplaceInFiles(paths, subs):
75 '''Reads a series of files, applies a series of substitutions to each, and 85 '''Reads a series of files, applies a series of substitutions to each, and
76 saves them back out. subs should by a list of (pattern, replace) tuples.''' 86 saves them back out. subs should by a list of (pattern, replace) tuples.'''
77 for path in paths: 87 for path in paths:
78 contents = open(path).read() 88 contents = open(path).read()
79 for pattern, replace in subs: 89 for pattern, replace in subs:
80 contents = re.sub(pattern, replace, contents) 90 contents = re.sub(pattern, replace, contents)
81 91
82 dest = open(path, 'w') 92 dest = open(path, 'w')
83 dest.write(contents) 93 dest.write(contents)
(...skipping 25 matching lines...) Expand all
109 119
110 120
111 def CopySnapshots(snapshot, sdk_root): 121 def CopySnapshots(snapshot, sdk_root):
112 copyfile(snapshot, join(sdk_root, 'bin', 'snapshots', basename(snapshot))) 122 copyfile(snapshot, join(sdk_root, 'bin', 'snapshots', basename(snapshot)))
113 123
114 124
115 def Main(argv): 125 def Main(argv):
116 # Pull in all of the gypi files which will be munged into the sdk. 126 # Pull in all of the gypi files which will be munged into the sdk.
117 HOME = dirname(dirname(realpath(__file__))) 127 HOME = dirname(dirname(realpath(__file__)))
118 128
119 # TODO(ricow): change to use option parser, issue 9820. 129 (options, args) = GetOptions()
120 SDK = argv[1] 130
131 SDK = options.sdk_output_dir
121 SDK_tmp = '%s.tmp' % SDK 132 SDK_tmp = '%s.tmp' % SDK
122 133
123 SNAPSHOT_LOCATION = argv[2] 134 SNAPSHOT_LOCATION = options.utils_snapshot_location
124 SNAPSHOT = join(SNAPSHOT_LOCATION, 'utils_wrapper.dart.snapshot') 135 SNAPSHOT = join(SNAPSHOT_LOCATION, 'utils_wrapper.dart.snapshot')
125 136
126 # TODO(dgrove) - deal with architectures that are not ia32. 137 # TODO(dgrove) - deal with architectures that are not ia32.
127 138
128 if exists(SDK): 139 if exists(SDK):
129 rmtree(SDK) 140 rmtree(SDK)
130 141
131 if exists(SDK_tmp): 142 if exists(SDK_tmp):
132 rmtree(SDK_tmp) 143 rmtree(SDK_tmp)
133 144
134 os.makedirs(SDK_tmp) 145 os.makedirs(SDK_tmp)
135 146
136 # Create and populate sdk/bin. 147 # Create and populate sdk/bin.
137 BIN = join(SDK_tmp, 'bin') 148 BIN = join(SDK_tmp, 'bin')
138 os.makedirs(BIN) 149 os.makedirs(BIN)
139 150
140 os.makedirs(join(BIN, 'snapshots')) 151 os.makedirs(join(BIN, 'snapshots'))
141 152
142 # Copy the Dart VM binary and the Windows Dart VM link library 153 # Copy the Dart VM binary and the Windows Dart VM link library
143 # into sdk/bin. 154 # into sdk/bin.
144 # 155 #
145 # TODO(dgrove) - deal with architectures that are not ia32. 156 # TODO(dgrove) - deal with architectures that are not ia32.
146 build_dir = os.path.dirname(argv[1]) 157 build_dir = os.path.dirname(SDK)
147 dart_file_extension = '' 158 dart_file_extension = ''
148 analyzer_file_extension = '' 159 analyzer_file_extension = ''
149 if HOST_OS == 'win32': 160 if HOST_OS == 'win32':
150 dart_file_extension = '.exe' 161 dart_file_extension = '.exe'
151 analyzer_file_extension = '.bat' 162 analyzer_file_extension = '.bat'
152 dart_import_lib_src = join(HOME, build_dir, 'dart.lib') 163 dart_import_lib_src = join(HOME, build_dir, 'dart.lib')
153 dart_import_lib_dest = join(BIN, 'dart.lib') 164 dart_import_lib_dest = join(BIN, 'dart.lib')
154 copyfile(dart_import_lib_src, dart_import_lib_dest) 165 copyfile(dart_import_lib_src, dart_import_lib_dest)
155 dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension) 166 dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension)
156 dart_dest_binary = join(BIN, 'dart' + dart_file_extension) 167 dart_dest_binary = join(BIN, 'dart' + dart_file_extension)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: 297 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
287 f.write(revision + '\n') 298 f.write(revision + '\n')
288 f.close() 299 f.close()
289 300
290 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) 301 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README'))
291 302
292 move(SDK_tmp, SDK) 303 move(SDK_tmp, SDK)
293 304
294 if __name__ == '__main__': 305 if __name__ == '__main__':
295 sys.exit(Main(sys.argv)) 306 sys.exit(Main(sys.argv))
OLDNEW
« dart.gyp ('K') | « dart.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698