OLD | NEW |
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 library pub.executable; | 5 library pub.executable; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (package != entrypoint.root.name) { | 104 if (package != entrypoint.root.name) { |
105 message += " in package ${log.bold(package)}"; | 105 message += " in package ${log.bold(package)}"; |
106 } | 106 } |
107 log.error("$message."); | 107 log.error("$message."); |
108 return exit_codes.NO_INPUT; | 108 return exit_codes.NO_INPUT; |
109 } | 109 } |
110 | 110 |
111 // If we're running an executable directly from the filesystem, make sure that | 111 // If we're running an executable directly from the filesystem, make sure that |
112 // it knows where to load the packages. If it's a dependency's executable, for | 112 // it knows where to load the packages. If it's a dependency's executable, for |
113 // example, it may not have the right packages directory itself. | 113 // example, it may not have the right packages directory itself. |
114 if (executableUrl.scheme == 'file' || executableUrl.scheme == '') { | 114 // |
| 115 // We don't do this for global executables because older ones may not have a |
| 116 // `.packages` file generated. If they do, the VM's logic will find it |
| 117 // automatically. |
| 118 if (!isGlobal && |
| 119 (executableUrl.scheme == 'file' || executableUrl.scheme == '')) { |
115 // We use an absolute path here not because the VM insists but because it's | 120 // We use an absolute path here not because the VM insists but because it's |
116 // helpful for the subprocess to be able to spawn Dart with | 121 // helpful for the subprocess to be able to spawn Dart with |
117 // Platform.executableArguments and have that work regardless of the working | 122 // Platform.executableArguments and have that work regardless of the working |
118 // directory. | 123 // directory. |
119 vmArgs.add('--packages=${p.toUri(p.absolute(entrypoint.packagesFile))}'); | 124 vmArgs.add('--packages=${p.toUri(p.absolute(entrypoint.packagesFile))}'); |
120 } | 125 } |
121 | 126 |
122 vmArgs.add(executableUrl.toString()); | 127 vmArgs.add(executableUrl.toString()); |
123 vmArgs.addAll(args); | 128 vmArgs.addAll(args); |
124 | 129 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 Future<int> _runCachedExecutable(Entrypoint entrypoint, String snapshotPath, | 280 Future<int> _runCachedExecutable(Entrypoint entrypoint, String snapshotPath, |
276 List<String> args, {bool checked: false}) { | 281 List<String> args, {bool checked: false}) { |
277 return runSnapshot(snapshotPath, args, | 282 return runSnapshot(snapshotPath, args, |
278 packagesFile: entrypoint.packagesFile, | 283 packagesFile: entrypoint.packagesFile, |
279 checked: checked, | 284 checked: checked, |
280 recompile: () { | 285 recompile: () { |
281 log.fine("Precompiled executable is out of date."); | 286 log.fine("Precompiled executable is out of date."); |
282 return entrypoint.precompileExecutables(); | 287 return entrypoint.precompileExecutables(); |
283 }); | 288 }); |
284 } | 289 } |
OLD | NEW |