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

Side by Side Diff: bindings/dart/gyp/scripts/build_dart_snapshot.py

Issue 1660113002: Updated to Chrome 45 (2454) moved from SVN to git. Base URL: https://github.com/dart-lang/webcore.git@roll_45
Patch Set: Created 4 years, 10 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 | « bindings/README ('k') | bindings/dart/scripts/__init__.py » ('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/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (C) 2011 Google Inc. All rights reserved. 3 # Copyright (C) 2011 Google Inc. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 for p in snapshottedLibPaths] 61 for p in snapshottedLibPaths]
62 62
63 # Generate a Dart script to build the snapshot from. 63 # Generate a Dart script to build the snapshot from.
64 snapshotScriptName = os.path.join(outputFilePath, 'snapshotScript.dart') 64 snapshotScriptName = os.path.join(outputFilePath, 'snapshotScript.dart')
65 with file(snapshotScriptName, 'w') as snapshotScript: 65 with file(snapshotScriptName, 'w') as snapshotScript:
66 snapshotScript.write('library snapshot;\n') 66 snapshotScript.write('library snapshot;\n')
67 for name, _ in snapshottedLibs: 67 for name, _ in snapshottedLibs:
68 # Skip internal libraries - they should be indirectly imported via t he public ones. 68 # Skip internal libraries - they should be indirectly imported via t he public ones.
69 if not name.startswith('_'): 69 if not name.startswith('_'):
70 snapshotScript.write('import \'dart:%(name)s\' as %(name)s;\n' % {'name': name}) 70 snapshotScript.write('import \'dart:%(name)s\' as %(name)s;\n' % {'name': name})
71 snapshotScript.write('import \'dart:vmserviceio\';\n')
71 72
72 binarySnapshotFile = path(outputFilePath, 'DartSnapshot.bin') 73 binaryVmIsolateSnapshotFile = path(outputFilePath, 'DartVmIsolateSnapshot.bi n')
74 binaryIsolateSnapshotFile = path(outputFilePath, 'DartIsolateSnapshot.bin')
73 75
74 # Build a command to generate the snapshot bin file. 76 # Build a command to generate the snapshot bin file.
75 command = [ 77 command = [
76 'python', 78 'python',
77 path(dartPath, 'runtime', 'tools', 'create_snapshot_bin.py'), 79 path(dartPath, 'runtime', 'tools', 'create_snapshot_bin.py'),
78 '--executable=%s' % path(genSnapshotBinPath), 80 '--executable=%s' % path(genSnapshotBinPath),
79 '--output_bin=%s' % binarySnapshotFile, 81 '--vm_output_bin=%s' % binaryVmIsolateSnapshotFile,
82 '--output_bin=%s' % binaryIsolateSnapshotFile,
80 '--script=%s' % snapshotScriptName, 83 '--script=%s' % snapshotScriptName,
81 ] 84 ]
82 command.extend(['--url_mapping=dart:%s,%s' % lib for lib in snapshottedLibs] ) 85 command.extend(['--url_mapping=dart:%s,%s' % lib for lib in snapshottedLibs] )
83 86
84 pipe = subprocess.Popen(command, 87 pipe = subprocess.Popen(command,
85 stdout=subprocess.PIPE, 88 stdout=subprocess.PIPE,
86 stderr=subprocess.PIPE) 89 stderr=subprocess.PIPE)
87 out, error = pipe.communicate() 90 out, error = pipe.communicate()
88 if (pipe.returncode != 0): 91 if (pipe.returncode != 0):
89 raise Exception('Snapshot bin generation failed: %s/%s' % (out, error)) 92 raise Exception('Snapshot bin generation failed: %s/%s' % (out, error))
90 93
91 # Build a command to generate the snapshot file. 94 # Build a command to generate the snapshot file.
92 command = [ 95 command = [
93 'python', 96 'python',
94 path(dartPath, 'runtime', 'tools', 'create_snapshot_file.py'), 97 path(dartPath, 'runtime', 'tools', 'create_snapshot_file.py'),
95 '--input_cc=%s' % dartSnapshotTemplateFile, 98 '--input_cc=%s' % dartSnapshotTemplateFile,
96 '--input_bin=%s' % binarySnapshotFile, 99 '--vm_input_bin=%s' % binaryVmIsolateSnapshotFile,
100 '--input_bin=%s' % binaryIsolateSnapshotFile,
97 '--output=%s' % path(outputFilePath, 'DartSnapshot.bytes'), 101 '--output=%s' % path(outputFilePath, 'DartSnapshot.bytes'),
98 ] 102 ]
99 103
100 pipe = subprocess.Popen(command, 104 pipe = subprocess.Popen(command,
101 stdout=subprocess.PIPE, 105 stdout=subprocess.PIPE,
102 stderr=subprocess.PIPE) 106 stderr=subprocess.PIPE)
103 out, error = pipe.communicate() 107 out, error = pipe.communicate()
104 if (pipe.returncode != 0): 108 if (pipe.returncode != 0):
105 raise Exception('Snapshot file generation failed: %s/%s' % (out, error)) 109 raise Exception('Snapshot file generation failed: %s/%s' % (out, error))
106 110
107 snapshotSizeInBytes = os.path.getsize(binarySnapshotFile) 111 snapshotSizeInBytes = os.path.getsize(binaryIsolateSnapshotFile)
108 productDir = os.path.dirname(genSnapshotBinPath) 112 productDir = os.path.dirname(genSnapshotBinPath)
109 snapshotSizeOutputPath = os.path.join(productDir, 'snapshot-size.txt') 113 snapshotSizeOutputPath = os.path.join(productDir, 'snapshot-size.txt')
110 with file(snapshotSizeOutputPath, 'w') as snapshotSizeFile: 114 with file(snapshotSizeOutputPath, 'w') as snapshotSizeFile:
111 snapshotSizeFile.write('%d\n' % snapshotSizeInBytes) 115 snapshotSizeFile.write('%d\n' % snapshotSizeInBytes)
112 116
113 return 0 117 return 0
114 118
115 if __name__ == '__main__': 119 if __name__ == '__main__':
116 sys.exit(main(sys.argv)) 120 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « bindings/README ('k') | bindings/dart/scripts/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698