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: tools/create_sdk.py

Issue 2646853005: Fuchsia: Copy libraries to SDK bin directory (Closed)
Patch Set: . Created 3 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 | « BUILD.gn ('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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 # TODO(dgrove): Only import modules following Google style guide. 86 # TODO(dgrove): Only import modules following Google style guide.
87 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move 87 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move
88 88
89 89
90 def GetOptions(): 90 def GetOptions():
91 options = optparse.OptionParser(usage='usage: %prog [options]') 91 options = optparse.OptionParser(usage='usage: %prog [options]')
92 options.add_option("--sdk_output_dir", 92 options.add_option("--sdk_output_dir",
93 help='Where to output the sdk') 93 help='Where to output the sdk')
94 options.add_option("--snapshot_location", 94 options.add_option("--snapshot_location",
95 help='Location of the snapshots.') 95 help='Location of the snapshots.')
96 options.add_option("--copy_libs",
97 action="store_true", default=False,
98 help='Copy dynamically linked libraries to the SDK bin directory.')
96 return options.parse_args() 99 return options.parse_args()
97 100
98 101
99 def ReplaceInFiles(paths, subs): 102 def ReplaceInFiles(paths, subs):
100 """Reads a series of files, applies a series of substitutions to each, and 103 """Reads a series of files, applies a series of substitutions to each, and
101 saves them back out. subs should by a list of (pattern, replace) tuples.""" 104 saves them back out. subs should by a list of (pattern, replace) tuples."""
102 for path in paths: 105 for path in paths:
103 contents = open(path).read() 106 contents = open(path).read()
104 for pattern, replace in subs: 107 for pattern, replace in subs:
105 contents = re.sub(pattern, replace, contents) 108 contents = re.sub(pattern, replace, contents)
(...skipping 18 matching lines...) Expand all
124 # If we're copying an SDK-specific shell script, strip off the suffix. 127 # If we're copying an SDK-specific shell script, strip off the suffix.
125 dest_file = basename(src_file) 128 dest_file = basename(src_file)
126 if dest_file.endswith('_sdk'): 129 if dest_file.endswith('_sdk'):
127 dest_file = dest_file.replace('_sdk', '') 130 dest_file = dest_file.replace('_sdk', '')
128 131
129 src = src_file + file_extension 132 src = src_file + file_extension
130 dest = join(dest_dir, dest_file + file_extension) 133 dest = join(dest_dir, dest_file + file_extension)
131 Copy(src, dest) 134 Copy(src, dest)
132 135
133 136
137 def CopyLibs(out_dir, bin_dir):
138 for library in ['libcrypto', 'libssl']:
139 ext = '.so'
140 if HOST_OS == 'macos':
141 ext = '.dylib'
142 elif HOST_OS == 'win32':
143 ext = '.dll'
144 src = os.path.join(out_dir, library + ext)
145 dst = os.path.join(bin_dir, library + ext)
146 if os.path.isfile(src):
147 copyfile(src, dst)
148 copymode(src, dst)
149
150
134 def CopyDartScripts(home, sdk_root): 151 def CopyDartScripts(home, sdk_root):
135 for executable in ['dart2js_sdk', 'dartanalyzer_sdk', 'dartfmt_sdk', 152 for executable in ['dart2js_sdk', 'dartanalyzer_sdk', 'dartfmt_sdk',
136 'pub_sdk', 'dartdoc', 'dartdevc_sdk']: 153 'pub_sdk', 'dartdoc', 'dartdevc_sdk']:
137 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), 154 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable),
138 os.path.join(sdk_root, 'bin')) 155 os.path.join(sdk_root, 'bin'))
139 156
140 157
141 def CopySnapshots(snapshots, sdk_root): 158 def CopySnapshots(snapshots, sdk_root):
142 for snapshot in ['analysis_server', 'dart2js', 'dartanalyzer', 'dartfmt', 159 for snapshot in ['analysis_server', 'dart2js', 'dartanalyzer', 'dartfmt',
143 'utils_wrapper', 'pub', 'dartdoc', 'dartdevc']: 160 'utils_wrapper', 'pub', 'dartdoc', 'dartdevc']:
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 323
307 # Copy dart2js/pub. 324 # Copy dart2js/pub.
308 CopyDartScripts(HOME, SDK_tmp) 325 CopyDartScripts(HOME, SDK_tmp)
309 326
310 CopySnapshots(SNAPSHOT, SDK_tmp) 327 CopySnapshots(SNAPSHOT, SDK_tmp)
311 CopyDartdocResources(HOME, SDK_tmp) 328 CopyDartdocResources(HOME, SDK_tmp)
312 CopyAnalyzerSources(HOME, LIB) 329 CopyAnalyzerSources(HOME, LIB)
313 CopyAnalysisSummaries(SNAPSHOT, LIB) 330 CopyAnalysisSummaries(SNAPSHOT, LIB)
314 CopyDevCompilerSdk(HOME, LIB) 331 CopyDevCompilerSdk(HOME, LIB)
315 332
333 if options.copy_libs:
334 CopyLibs(build_dir, BIN)
335
316 # Write the 'version' file 336 # Write the 'version' file
317 version = utils.GetVersion() 337 version = utils.GetVersion()
318 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') 338 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w')
319 versionFile.write(version + '\n') 339 versionFile.write(version + '\n')
320 versionFile.close() 340 versionFile.close()
321 341
322 # Write the 'revision' file 342 # Write the 'revision' file
323 revision = utils.GetGitRevision() 343 revision = utils.GetGitRevision()
324 344
325 if revision is not None: 345 if revision is not None:
326 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: 346 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
327 f.write('%s\n' % revision) 347 f.write('%s\n' % revision)
328 f.close() 348 f.close()
329 349
330 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) 350 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README'))
331 Copy(join(HOME, 'LICENSE'), join(SDK_tmp, 'LICENSE')) 351 Copy(join(HOME, 'LICENSE'), join(SDK_tmp, 'LICENSE'))
332 Copy(join(HOME, 'sdk', 'api_readme.md'), join(SDK_tmp, 'lib', 'api_readme.md') ) 352 Copy(join(HOME, 'sdk', 'api_readme.md'), join(SDK_tmp, 'lib', 'api_readme.md') )
333 353
334 move(SDK_tmp, SDK) 354 move(SDK_tmp, SDK)
335 355
336 if __name__ == '__main__': 356 if __name__ == '__main__':
337 sys.exit(Main()) 357 sys.exit(Main())
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698