Index: tools/create_pub_snapshot.py |
diff --git a/tools/create_pub_snapshot.py b/tools/create_pub_snapshot.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d99c8bd76d0b44308a58819f5e7156625767bd58 |
--- /dev/null |
+++ b/tools/create_pub_snapshot.py |
@@ -0,0 +1,60 @@ |
+#!/usr/bin/env python |
+ |
+# Copyright (c) 2014 The Dart Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+""" |
+This script runs the async/await compiler on pub and then compiles the output |
+of that to a snapshot. |
+ |
+Usage: create_pub_snapshot.py <dart> <package root> <output dir> |
+ |
+When #104 is fixed, this script is no longer needed. Instead, replace the |
+generate_pub_snapshot action in utils/pub.gyp with: |
+ |
+ 'action': [ |
+ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)dart<(EXECUTABLE_SUFFIX)', |
+ '--package-root=<(PRODUCT_DIR)/pub_packages/', |
+ '--snapshot=<(SHARED_INTERMEDIATE_DIR)/pub.dart.snapshot', |
+ '../../sdk/lib/_internal/pub/bin/pub.dart', |
+ ] |
+""" |
+ |
+import os |
+import subprocess |
+import sys |
+ |
+ |
+def Main(): |
+ if len(sys.argv) < 4: |
+ raise Exception("""Not enough arguments. |
+ |
+Usage: create_pub_snapshot.py <dart> <package root> <output file>""") |
+ |
+ dart_path = sys.argv[1] |
+ package_root = sys.argv[2] |
+ output_dir = sys.argv[3] |
+ |
+ # Run the async compiler. |
+ status = subprocess.call([ |
+ dart_path, |
+ '--package-root=' + package_root, |
+ '../../sdk/lib/_internal/pub/bin/async_compile.dart', |
ricow1
2014/08/25 06:22:03
please add a comment about what this is relative t
Bob Nystrom
2014/08/25 17:40:00
Done.
|
+ output_dir, |
+ '--silent' |
+ ]) |
+ if status != 0: return status |
+ |
+ # Generate the snapshot from the output of that. |
+ subprocess.call([ |
ricow1
2014/08/25 06:22:03
set status = this call, otherwise the exitcode is
Bob Nystrom
2014/08/25 17:40:00
Oops, good catch! Fixed.
|
+ dart_path, |
+ '--package-root=' + package_root, |
+ '--snapshot=' + os.path.join(output_dir, 'pub.dart.snapshot'), |
+ os.path.join(output_dir, 'pub_async/bin/pub.dart') |
+ ]) |
+ if status != 0: return status |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(Main()) |