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

Unified Diff: dart/lib/compiler/implementation/dart2js.dart

Issue 10207010: Make dart2js work on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/frog/frog_leg.dart ('k') | dart/lib/compiler/implementation/filenames.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/dart2js.dart
diff --git a/dart/lib/compiler/implementation/dart2js.dart b/dart/lib/compiler/implementation/dart2js.dart
index 2b729f578224a9fbc7e8ff6daffda9630afbbd9f..fb84a947503d18192946a28c076d82507634c0e6 100644
--- a/dart/lib/compiler/implementation/dart2js.dart
+++ b/dart/lib/compiler/implementation/dart2js.dart
@@ -11,39 +11,11 @@
#import('../compiler.dart', prefix: 'api');
#import('colors.dart');
#import('source_file.dart');
-
-String relativize(Uri base, Uri uri) {
- if (base.scheme == 'file' &&
- base.scheme == uri.scheme &&
- base.userInfo == uri.userInfo &&
- base.domain == uri.domain &&
- base.port == uri.port &&
- uri.query == "" && uri.fragment == "") {
- if (uri.path.startsWith(base.path)) {
- return uri.path.substring(base.path.length);
- }
- List<String> uriParts = uri.path.split('/');
- List<String> baseParts = base.path.split('/');
- int common = 0;
- int length = Math.min(uriParts.length, baseParts.length);
- while (common < length && uriParts[common] == baseParts[common]) {
- common++;
- }
- StringBuffer sb = new StringBuffer();
- for (int i = common + 1; i < baseParts.length; i++) {
- sb.add('../');
- }
- for (int i = common; i < uriParts.length - 1; i++) {
- sb.add('${uriParts[i]}/');
- }
- sb.add('${uriParts.last()}');
- return sb.toString();
- }
- return uri.toString();
-}
+#import('filenames.dart');
+#import('util/uri_extras.dart');
void compile(List<String> argv) {
- Uri cwd = new Uri(scheme: 'file', path: getCurrentDirectory());
+ Uri cwd = getCurrentDirectory();
bool throwOnError = false;
bool showWarnings = true;
bool verbose = false;
@@ -59,16 +31,18 @@ void compile(List<String> argv) {
} else if ('--verbose' == argument) {
verbose = true;
} else if (argument.startsWith('--library-root=')) {
- String path = argument.substring(argument.indexOf('=') + 1);
+ String path =
+ nativeToUriPath(argument.substring(argument.indexOf('=') + 1));
if (!path.endsWith("/")) path = "$path/";
libraryRoot = cwd.resolve(path);
} else if (argument.startsWith('--out=')) {
- String path = argument.substring(argument.indexOf('=') + 1);
+ String path =
+ nativeToUriPath(argument.substring(argument.indexOf('=') + 1));
out = cwd.resolve(path);
} else if (argument.startsWith('-')) {
throw new AbortLeg('unknown option $argument');
} else {
- arguments.add(argument);
+ arguments.add(nativeToUriPath(argument));
}
}
if (arguments.isEmpty()) {
@@ -86,7 +60,7 @@ void compile(List<String> argv) {
if (uri.scheme != 'file') {
throw new IllegalArgumentException(uri);
}
- String source = readAll(uri.path);
+ String source = readAll(uriPathToNative(uri.path));
dartBytesRead += source.length;
sourceFiles[uri.toString()] =
new SourceFile(relativize(cwd, uri), source);
@@ -137,7 +111,7 @@ void writeString(Uri uri, String text) {
if (uri.scheme != 'file') {
throw new AbortLeg('unhandled scheme ${uri.scheme}');
}
- var file = new File(uri.path).openSync(FileMode.WRITE);
+ var file = new File(uriPathToNative(uri.path)).openSync(FileMode.WRITE);
file.writeStringSync(text);
file.closeSync();
}
@@ -150,9 +124,3 @@ String readAll(String filename) {
file.closeSync();
return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest());
}
-
-String getCurrentDirectory() {
- String dir = new File(".").fullPathSync();
- if (dir.endsWith("/")) return dir;
- return "$dir/";
-}
« no previous file with comments | « dart/frog/frog_leg.dart ('k') | dart/lib/compiler/implementation/filenames.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698