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

Side by Side Diff: utils/compiler/create_snapshot_entry.dart

Issue 2442513003: GN: Build the SDK with app snapshots instead of script snapshots. (Closed)
Patch Set: . Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:io'; 5 import 'dart:io';
6 6
7 Future<String> getVersion(var rootPath) { 7 Future<String> getVersion(var rootPath) {
8 var suffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; 8 var suffix = Platform.operatingSystem == 'windows' ? '.exe' : '';
9 var printVersionScript = rootPath.resolve("tools/print_version.py"); 9 var printVersionScript = rootPath.resolve("tools/print_version.py");
10 return Process.run("python$suffix", 10 return Process.run("python$suffix",
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 }); 54 });
55 } 55 }
56 56
57 void writeSnapshotFile(var path, var content) { 57 void writeSnapshotFile(var path, var content) {
58 File file = new File(path); 58 File file = new File(path);
59 var writer = file.openSync(mode: FileMode.WRITE); 59 var writer = file.openSync(mode: FileMode.WRITE);
60 writer.writeStringSync(content); 60 writer.writeStringSync(content);
61 writer.close(); 61 writer.close();
62 } 62 }
63 63
64 Future createSnapshot(var dart_file) {
65 return Process.run(Platform.executable,
66 ["--packages=../../.packages",
67 "--snapshot=$dart_file.snapshot",
68 dart_file])
69 .then((result) {
70 if (result.exitCode != 0) {
71 print("Could not generate snapshot: result code ${result.exitCode}");
72 print(result.stdout);
73 print(result.stderr);
74 throw "Could not generate snapshot";
75 }
76 });
77 }
78
79 /** 64 /**
80 * Takes the following arguments: 65 * Takes the following arguments:
81 * --output_dir=val The full path to the output_dir. 66 * --output_dir=val The full path to the output_dir.
82 * --dart2js_main=val The path to the dart2js main script relative to root. 67 * --dart2js_main=val The path to the dart2js main script relative to root.
83 */ 68 */
84 void main(List<String> arguments) { 69 void main(List<String> arguments) {
85 var validArguments = ["--output_dir", "--dart2js_main"]; 70 var validArguments = ["--output_dir", "--dart2js_main"];
86 var args = {}; 71 var args = {};
87 for (var argument in arguments) { 72 for (var argument in arguments) {
88 var argumentSplit = argument.split("="); 73 var argumentSplit = argument.split("=");
89 if (argumentSplit.length != 2) throw "Invalid argument $argument, no ="; 74 if (argumentSplit.length != 2) throw "Invalid argument $argument, no =";
90 if (!validArguments.contains(argumentSplit[0])) { 75 if (!validArguments.contains(argumentSplit[0])) {
91 throw "Invalid argument $argument"; 76 throw "Invalid argument $argument";
92 } 77 }
93 args[argumentSplit[0].substring(2)] = argumentSplit[1]; 78 args[argumentSplit[0].substring(2)] = argumentSplit[1];
94 } 79 }
95 if (!args.containsKey("dart2js_main")) throw "Please specify dart2js_main"; 80 if (!args.containsKey("dart2js_main")) throw "Please specify dart2js_main";
96 if (!args.containsKey("output_dir")) throw "Please specify output_dir"; 81 if (!args.containsKey("output_dir")) throw "Please specify output_dir";
97 82
98 var scriptFile = Uri.base.resolveUri(Platform.script); 83 var scriptFile = Uri.base.resolveUri(Platform.script);
99 var path = scriptFile.resolve("."); 84 var path = scriptFile.resolve(".");
100 var rootPath = path.resolve("../.."); 85 var rootPath = path.resolve("../..");
101 getSnapshotGenerationFile(args, rootPath).then((result) { 86 getSnapshotGenerationFile(args, rootPath).then((result) {
102 var wrapper = "${args['output_dir']}/utils_wrapper.dart"; 87 var wrapper = "${args['output_dir']}/utils_wrapper.dart";
103 writeSnapshotFile(wrapper, result); 88 writeSnapshotFile(wrapper, result);
104 createSnapshot(wrapper);
105 }); 89 });
106 90
107 getDart2jsSnapshotGenerationFile(args, rootPath).then((result) { 91 getDart2jsSnapshotGenerationFile(args, rootPath).then((result) {
108 var wrapper = "${args['output_dir']}/dart2js.dart"; 92 var wrapper = "${args['output_dir']}/dart2js.dart";
109 writeSnapshotFile(wrapper, result); 93 writeSnapshotFile(wrapper, result);
110 createSnapshot(wrapper);
111 }); 94 });
112
113 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698