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

Side by Side Diff: runtime/bin/builtin.dart

Issue 10134015: added package_root flag to standalone dart vm (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix blank lines Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/main.cc » ('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) 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 #import("dart:uri"); 6 #import("dart:uri");
7 7
8 void print(arg) { 8 void print(arg) {
9 _Logger._printString(arg.toString()); 9 _Logger._printString(arg.toString());
10 } 10 }
(...skipping 14 matching lines...) Expand all
25 25
26 // Code to deal with URI resolution for the standalone binary. 26 // Code to deal with URI resolution for the standalone binary.
27 // For Windows we need to massage the paths a bit according to 27 // For Windows we need to massage the paths a bit according to
28 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx 28 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
29 var _is_windows; 29 var _is_windows;
30 30
31 // The URI that the entrypoint script was loaded from. Remembered so that 31 // The URI that the entrypoint script was loaded from. Remembered so that
32 // package imports can be resolved relative to it. 32 // package imports can be resolved relative to it.
33 Uri _entrypoint; 33 Uri _entrypoint;
34 34
35 // The directory to look in to resolve "package:" scheme URIs.
36 String _packageRoot;
37
35 void _logResolution(String msg) { 38 void _logResolution(String msg) {
36 final enabled = false; 39 final enabled = false;
37 if (enabled) { 40 if (enabled) {
38 _Logger._printString(msg); 41 _Logger._printString(msg);
39 } 42 }
40 } 43 }
41 44
45 String _setPackageRoot(String packageRoot) {
46 // TODO(mattsh) - refactor windows drive and path handling code
47 // so it can be used here if needed.
48 _packageRoot = packageRoot;
49 }
50
42 String _resolveScriptUri(String cwd, String scriptName, bool windows) { 51 String _resolveScriptUri(String cwd, String scriptName, bool windows) {
43 _is_windows = windows; 52 _is_windows = windows;
44 _logResolution("# Current working directory: $cwd"); 53 _logResolution("# Current working directory: $cwd");
45 _logResolution("# ScriptName: $scriptName"); 54 _logResolution("# ScriptName: $scriptName");
46 if (windows) { 55 if (windows) {
47 // Convert 56 // Convert
48 // C:\one\two\three 57 // C:\one\two\three
49 // to 58 // to
50 // /C:/one/two/three 59 // /C:/one/two/three
51 cwd = "/${cwd.replaceAll('\\', '/')}"; 60 cwd = "/${cwd.replaceAll('\\', '/')}";
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 String _filePathFromPackageUri(Uri uri) { 143 String _filePathFromPackageUri(Uri uri) {
135 if (uri.domain != '') { 144 if (uri.domain != '') {
136 var path = (uri.path != '') ? '${uri.domain}${uri.path}' : uri.domain; 145 var path = (uri.path != '') ? '${uri.domain}${uri.path}' : uri.domain;
137 var right = 'package:$path'; 146 var right = 'package:$path';
138 var wrong = 'package://$path'; 147 var wrong = 'package://$path';
139 148
140 throw "URIs using the 'package:' scheme should look like " + 149 throw "URIs using the 'package:' scheme should look like " +
141 "'$right', not '$wrong'."; 150 "'$right', not '$wrong'.";
142 } 151 }
143 152
144 var path = _entrypoint.resolve('packages/${uri.path}').path; 153 var path;
154 if (_packageRoot !== null) {
155 path = "${_packageRoot}${uri.path}";
156 } else {
157 path = _entrypoint.resolve('packages/${uri.path}').path;
158 }
159
145 _logResolution("# Package: $path"); 160 _logResolution("# Package: $path");
146 return path; 161 return path;
147 } 162 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698