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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart

Issue 586173002: Make binstubs run snapshots directly when possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise! Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/entrypoint.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart b/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
index 8df986b1883774adbcb781456f41ee72e01f99d4..1e7cce48199dd3b3bbe66c10c90e2fc67b7379d2 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
@@ -237,38 +237,45 @@ class AssetEnvironment {
/// [directory].
///
/// If [executableIds] is passed, only those executables are precompiled.
- Future precompileExecutables(String packageName, String directory,
- {Iterable<AssetId> executableIds}) {
+ ///
+ /// Returns a map from executable ID to path for the snapshots that were
nweiz 2014/09/23 00:15:44 This says "executable ID" but actually returns the
Bob Nystrom 2014/09/23 18:23:27 Done.
+ /// successfully precompiled.
+ Future<Map<String, String>> precompileExecutables(String packageName,
+ String directory, {Iterable<AssetId> executableIds}) async {
if (executableIds == null) {
executableIds = graph.packages[packageName].executableIds;
}
- log.fine("executables for $packageName: $executableIds");
- if (executableIds.isEmpty) return null;
+
+ log.fine("Executables for $packageName: $executableIds");
+ if (executableIds.isEmpty) return [];
var package = graph.packages[packageName];
- return servePackageBinDirectory(packageName).then((server) {
- return waitAndPrintErrors(executableIds.map((id) {
+ var server = await servePackageBinDirectory(packageName);
+ try {
+ var precompiled = {};
+ await waitAndPrintErrors(executableIds.map((id) async {
var basename = path.url.basename(id.path);
var snapshotPath = path.join(directory, "$basename.snapshot");
- return runProcess(Platform.executable, [
+ var result = await runProcess(Platform.executable, [
'--snapshot=$snapshotPath',
server.url.resolve(basename).toString()
- ]).then((result) {
- if (result.success) {
- log.message("Precompiled ${_formatExecutable(id)}.");
- } else {
- throw new ApplicationException(
- log.yellow("Failed to precompile "
- "${_formatExecutable(id)}:\n") +
- result.stderr.join('\n'));
- }
- });
- })).whenComplete(() {
- // Don't return this future, since we have no need to wait for the
- // server to fully shut down.
- server.close();
- });
- });
+ ]);
+ if (result.success) {
+ log.message("Precompiled ${_formatExecutable(id)}.");
+ precompiled[path.withoutExtension(basename)] = snapshotPath;
+ } else {
+ throw new ApplicationException(
+ log.yellow("Failed to precompile ${_formatExecutable(id)}:\n") +
+ result.stderr.join('\n'));
+ }
+ }));
+
+ return precompiled;
+ } finally {
+ // Don't await this future, since we have no need to wait for the server
+ // to fully shut down.
+ server.close();
+ }
}
/// Returns the executable name for [id].
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/entrypoint.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698