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

Side by Side Diff: lib/src/executable.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 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 | « lib/src/error_group.dart ('k') | lib/src/global_packages.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'package:async/async.dart';
8 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
9 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
10 11
11 import 'barback/asset_environment.dart'; 12 import 'barback/asset_environment.dart';
12 import 'entrypoint.dart'; 13 import 'entrypoint.dart';
13 import 'exit_codes.dart' as exit_codes; 14 import 'exit_codes.dart' as exit_codes;
14 import 'io.dart'; 15 import 'io.dart';
15 import 'log.dart' as log; 16 import 'log.dart' as log;
16 import 'utils.dart'; 17 import 'utils.dart';
17 18
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 return _runCachedExecutable(entrypoint, localSnapshotPath, args, 88 return _runCachedExecutable(entrypoint, localSnapshotPath, args,
88 checked: checked); 89 checked: checked);
89 } 90 }
90 91
91 // If the command has a path separator, then it's a path relative to the 92 // If the command has a path separator, then it's a path relative to the
92 // root of the package. Otherwise, it's implicitly understood to be in 93 // root of the package. Otherwise, it's implicitly understood to be in
93 // "bin". 94 // "bin".
94 if (p.split(executable).length == 1) executable = p.join("bin", executable); 95 if (p.split(executable).length == 1) executable = p.join("bin", executable);
95 96
96 var vmArgs = []; 97 var vmArgs = <String>[];
97 98
98 // Run in checked mode. 99 // Run in checked mode.
99 if (checked) vmArgs.add("--checked"); 100 if (checked) vmArgs.add("--checked");
100 101
101 var executableUrl = await _executableUrl( 102 var executableUrl = await _executableUrl(
102 entrypoint, package, executable, isGlobal: isGlobal, mode: mode); 103 entrypoint, package, executable, isGlobal: isGlobal, mode: mode);
103 104
104 if (executableUrl == null) { 105 if (executableUrl == null) {
105 var message = "Could not find ${log.bold(executable)}"; 106 var message = "Could not find ${log.bold(executable)}";
106 if (isGlobal || package != entrypoint.root.name) { 107 if (isGlobal || package != entrypoint.root.name) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 /// 212 ///
212 /// If [checked] is set, runs the snapshot in checked mode. 213 /// If [checked] is set, runs the snapshot in checked mode.
213 /// 214 ///
214 /// Returns the snapshot's exit code. 215 /// Returns the snapshot's exit code.
215 /// 216 ///
216 /// This doesn't do any validation of the snapshot's SDK version. 217 /// This doesn't do any validation of the snapshot's SDK version.
217 Future<int> runSnapshot(String path, Iterable<String> args, {recompile(), 218 Future<int> runSnapshot(String path, Iterable<String> args, {recompile(),
218 String packagesFile, bool checked: false}) async { 219 String packagesFile, bool checked: false}) async {
219 // TODO(nweiz): pass a flag to silence the "Wrong full snapshot version" 220 // TODO(nweiz): pass a flag to silence the "Wrong full snapshot version"
220 // message when issue 20784 is fixed. 221 // message when issue 20784 is fixed.
221 var vmArgs = []; 222 var vmArgs = <String>[];
222 if (checked) vmArgs.add("--checked"); 223 if (checked) vmArgs.add("--checked");
223 224
224 if (packagesFile != null) { 225 if (packagesFile != null) {
225 // We use an absolute path here not because the VM insists but because it's 226 // We use an absolute path here not because the VM insists but because it's
226 // helpful for the subprocess to be able to spawn Dart with 227 // helpful for the subprocess to be able to spawn Dart with
227 // Platform.executableArguments and have that work regardless of the working 228 // Platform.executableArguments and have that work regardless of the working
228 // directory. 229 // directory.
229 vmArgs.add("--packages=${p.toUri(p.absolute(packagesFile))}"); 230 vmArgs.add("--packages=${p.toUri(p.absolute(packagesFile))}");
230 } 231 }
231 232
232 vmArgs.add(path); 233 vmArgs.add(path);
233 vmArgs.addAll(args); 234 vmArgs.addAll(args);
234 235
235 // We need to split stdin so that we can send the same input both to the 236 // We need to split stdin so that we can send the same input both to the
236 // first and second process, if we start more than one. 237 // first and second process, if we start more than one.
237 var stdin1; 238 var stdin1;
238 var stdin2; 239 var stdin2;
239 if (recompile == null) { 240 if (recompile == null) {
240 stdin1 = stdin; 241 stdin1 = stdin;
241 } else { 242 } else {
242 var pair = tee(stdin); 243 var stdins = StreamSplitter.splitFrom(stdin);
243 stdin1 = pair.first; 244 stdin1 = stdins.first;
244 stdin2 = pair.last; 245 stdin2 = stdins.last;
245 } 246 }
246 247
247 runProcess(input) async { 248 runProcess(input) async {
248 var process = await Process.start(Platform.executable, vmArgs); 249 var process = await Process.start(Platform.executable, vmArgs);
249 250
250 _forwardSignals(process); 251 _forwardSignals(process);
251 252
252 // Note: we're not using process.std___.pipe(std___) here because 253 // Note: we're not using process.std___.pipe(std___) here because
253 // that prevents pub from also writing to the output streams. 254 // that prevents pub from also writing to the output streams.
254 process.stderr.listen(stderr.add); 255 process.stderr.listen(stderr.add);
(...skipping 30 matching lines...) Expand all
285 Future<int> _runCachedExecutable(Entrypoint entrypoint, String snapshotPath, 286 Future<int> _runCachedExecutable(Entrypoint entrypoint, String snapshotPath,
286 List<String> args, {bool checked: false}) { 287 List<String> args, {bool checked: false}) {
287 return runSnapshot(snapshotPath, args, 288 return runSnapshot(snapshotPath, args,
288 packagesFile: entrypoint.packagesFile, 289 packagesFile: entrypoint.packagesFile,
289 checked: checked, 290 checked: checked,
290 recompile: () { 291 recompile: () {
291 log.fine("Precompiled executable is out of date."); 292 log.fine("Precompiled executable is out of date.");
292 return entrypoint.precompileExecutables(); 293 return entrypoint.precompileExecutables();
293 }); 294 });
294 } 295 }
OLDNEW
« no previous file with comments | « lib/src/error_group.dart ('k') | lib/src/global_packages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698