Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 builtin; | 5 library builtin; |
| 6 // NOTE: Do not import 'dart:io' in builtin. | 6 // NOTE: Do not import 'dart:io' in builtin. |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:_internal'; | 9 import 'dart:_internal'; |
| 10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 if (!_setupCompleted) { | 221 if (!_setupCompleted) { |
| 222 _setupHooks(); | 222 _setupHooks(); |
| 223 } | 223 } |
| 224 if (_traceLoading) { | 224 if (_traceLoading) { |
| 225 _log('Setting package root: $packageRoot'); | 225 _log('Setting package root: $packageRoot'); |
| 226 } | 226 } |
| 227 packageRoot = _enforceTrailingSlash(packageRoot); | 227 packageRoot = _enforceTrailingSlash(packageRoot); |
| 228 if (packageRoot.startsWith('file:') || | 228 if (packageRoot.startsWith('file:') || |
| 229 packageRoot.startsWith('http:') || | 229 packageRoot.startsWith('http:') || |
| 230 packageRoot.startsWith('https:')) { | 230 packageRoot.startsWith('https:')) { |
| 231 _packageRoot = _workingDirectory.resolve(packageRoot); | 231 _packageRoot = _workingDirectory.resolve(packageRoot); |
|
Lasse Reichstein Nielsen
2015/12/17 07:03:33
If packageRoot starts with a scheme, then _working
Ivan Posva
2015/12/17 15:44:35
Thanks for your suggestion, but I don't think they
Lasse Reichstein Nielsen
2015/12/17 16:34:29
If packageRoot starts with file:, http: or https:,
| |
| 232 } else { | 232 } else { |
| 233 packageRoot = _sanitizeWindowsPath(packageRoot); | 233 packageRoot = _sanitizeWindowsPath(packageRoot); |
| 234 packageRoot = _trimWindowsPath(packageRoot); | 234 packageRoot = _trimWindowsPath(packageRoot); |
| 235 _packageRoot = _workingDirectory.resolveUri(new Uri.file(packageRoot)); | 235 _packageRoot = _workingDirectory.resolveUri(new Uri.file(packageRoot)); |
|
Lasse Reichstein Nielsen
2015/12/17 07:03:33
Maybe use "new Uri.directory" instead. It ensures
Ivan Posva
2015/12/17 15:44:35
The slash has already been added with _enforceTrai
| |
| 236 } | 236 } |
| 237 // Now that we have determined the packageRoot value being used, set it | |
| 238 // up for use in Platform.packageRoot. | |
| 239 VMLibraryHooks.packageRoot = _packageRoot.toString(); | |
| 237 if (_traceLoading) { | 240 if (_traceLoading) { |
| 238 _log('Package root URI: $_packageRoot'); | 241 _log('Package root URI: $_packageRoot'); |
| 239 } | 242 } |
| 240 } | 243 } |
| 241 | 244 |
| 242 | 245 |
| 243 // Given a uri with a 'package' scheme, return a Uri that is prefixed with | 246 // Given a uri with a 'package' scheme, return a Uri that is prefixed with |
| 244 // the package root. | 247 // the package root. |
| 245 Uri _resolvePackageUri(Uri uri) { | 248 Uri _resolvePackageUri(Uri uri) { |
| 246 if (!uri.host.isEmpty) { | 249 if (!uri.host.isEmpty) { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 if (_workingDirectory == null) { | 478 if (_workingDirectory == null) { |
| 476 throw 'No current working directory set.'; | 479 throw 'No current working directory set.'; |
| 477 } | 480 } |
| 478 var packagesName = _sanitizeWindowsPath(packagesParam); | 481 var packagesName = _sanitizeWindowsPath(packagesParam); |
| 479 var packagesUri = Uri.parse(packagesName); | 482 var packagesUri = Uri.parse(packagesName); |
| 480 if (packagesUri.scheme == '') { | 483 if (packagesUri.scheme == '') { |
| 481 // Script does not have a scheme, assume that it is a path, | 484 // Script does not have a scheme, assume that it is a path, |
| 482 // resolve it against the working directory. | 485 // resolve it against the working directory. |
| 483 packagesUri = _workingDirectory.resolveUri(packagesUri); | 486 packagesUri = _workingDirectory.resolveUri(packagesUri); |
| 484 } | 487 } |
| 488 VMLibraryHooks.packageConfig = packagesUri.toString(); | |
| 485 if (_traceLoading) { | 489 if (_traceLoading) { |
| 486 _log('Resolved packages map to: $packagesUri'); | 490 _log('Resolved packages map to: $packagesUri'); |
| 487 } | 491 } |
| 488 | 492 |
| 489 // Request the loading and parsing of the packages map at the specified URI. | 493 // Request the loading and parsing of the packages map at the specified URI. |
| 490 // Create a port to receive the packages map on. | 494 // Create a port to receive the packages map on. |
| 491 assert(_packagesPort == null); | 495 assert(_packagesPort == null); |
| 492 _packagesPort = new RawReceivePort(_handlePackagesReply); | 496 _packagesPort = new RawReceivePort(_handlePackagesReply); |
| 493 var sp = _packagesPort.sendPort; | 497 var sp = _packagesPort.sendPort; |
| 494 | 498 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 } | 832 } |
| 829 | 833 |
| 830 | 834 |
| 831 // Register callbacks and hooks with the rest of the core libraries. | 835 // Register callbacks and hooks with the rest of the core libraries. |
| 832 _setupHooks() { | 836 _setupHooks() { |
| 833 _setupCompleted = true; | 837 _setupCompleted = true; |
| 834 VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes; | 838 VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes; |
| 835 VMLibraryHooks.getPackageRoot = _getPackageRoot; | 839 VMLibraryHooks.getPackageRoot = _getPackageRoot; |
| 836 VMLibraryHooks.getPackageMap = _getPackageMap; | 840 VMLibraryHooks.getPackageMap = _getPackageMap; |
| 837 } | 841 } |
| OLD | NEW |