| Index: dart/sdk/lib/_internal/compiler/implementation/dart2js.dart
|
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/dart2js.dart b/dart/sdk/lib/_internal/compiler/implementation/dart2js.dart
|
| index 62286a07529c38c2a4dd5c804a6ba73332ec3c3b..dc7b2574c2e0f56b9feb83b43916cac132856d21 100644
|
| --- a/dart/sdk/lib/_internal/compiler/implementation/dart2js.dart
|
| +++ b/dart/sdk/lib/_internal/compiler/implementation/dart2js.dart
|
| @@ -198,7 +198,7 @@ void compile(List<String> argv) {
|
| Map<String, SourceFile> sourceFiles = <String, SourceFile>{};
|
| int dartBytesRead = 0;
|
|
|
| - Future<String> provider(Uri uri) {
|
| + Future<String> inputProvider(Uri uri) {
|
| if (uri.scheme != 'file') {
|
| throw new ArgumentError(uri);
|
| }
|
| @@ -232,13 +232,6 @@ void compile(List<String> argv) {
|
|
|
| void handler(Uri uri, int begin, int end, String message,
|
| api.Diagnostic kind) {
|
| - if (identical(kind.name, 'source map')) {
|
| - // TODO(podivilov): We should find a better way to return source maps from
|
| - // emitter. Using diagnostic handler for that purpose is a temporary hack.
|
| - writeString(sourceMapOut, message);
|
| - return;
|
| - }
|
| -
|
| if (isAborting) return;
|
| isAborting = identical(kind, api.Diagnostic.CRASH);
|
| bool fatal = (kind.ordinal & FATAL) != 0;
|
| @@ -286,26 +279,60 @@ void compile(List<String> argv) {
|
|
|
| info('package root is $packageRoot');
|
|
|
| - // TODO(ahe): We expect the future to be complete and call value
|
| - // directly. In effect, we don't support truly asynchronous API.
|
| - String code = deprecatedFutureValue(
|
| - api.compile(uri, libraryRoot, packageRoot, provider, handler, options));
|
| - if (code == null) {
|
| - fail('Error: Compilation failed.');
|
| + compilationDone(String code) {
|
| + if (code == null) {
|
| + fail('Error: Compilation failed.');
|
| + }
|
| + writeString(new Uri.fromString('$out.deps'), getDepsOutput(sourceFiles));
|
| + int bytesWritten = code.length;
|
| + info('compiled $dartBytesRead bytes Dart -> $bytesWritten bytes '
|
| + '$outputLanguage in ${relativize(cwd, out, isWindows)}');
|
| + if (!explicitOut) {
|
| + String input = uriPathToNative(arguments[0]);
|
| + String output = relativize(cwd, out, isWindows);
|
| + print('Dart file $input compiled to $outputLanguage: $output');
|
| + }
|
| }
|
| - String sourceMapFileName =
|
| - sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1);
|
| - code = '$code\n//@ sourceMappingURL=${sourceMapFileName}';
|
| - writeString(out, code);
|
| - writeString(new Uri.fromString('$out.deps'), getDepsOutput(sourceFiles));
|
| - int bytesWritten = code.length;
|
| - info('compiled $dartBytesRead bytes Dart -> $bytesWritten bytes '
|
| - '$outputLanguage in ${relativize(cwd, out, isWindows)}');
|
| - if (!explicitOut) {
|
| - String input = uriPathToNative(arguments[0]);
|
| - String output = relativize(cwd, out, isWindows);
|
| - print('Dart file $input compiled to $outputLanguage: $output');
|
| +
|
| + Sink<String> outputProvider(String name, String extension) {
|
| + Uri uri;
|
| + String sourceMapFileName;
|
| + if (name == '') {
|
| + if (extension == 'js' || extension == 'dart') {
|
| + uri = out;
|
| + sourceMapFileName =
|
| + sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1);
|
| + } else if (extension == 'js.map' || extension == 'dart.map') {
|
| + uri = sourceMapOut;
|
| + } else {
|
| + fail('Error: Unknown extension: $extension');
|
| + }
|
| + } else {
|
| + uri = out.resolve('$name.$extension');
|
| + }
|
| +
|
| + if (uri.scheme != 'file') {
|
| + fail('Error: Unhandled scheme ${uri.scheme} in $uri.');
|
| + }
|
| + var outputStream = new File(uriPathToNative(uri.path)).openOutputStream();
|
| +
|
| + onDone() {
|
| + if (sourceMapFileName != null) {
|
| + outputStream.writeString('//@ sourceMappingURL=');
|
| + outputStream.writeString(sourceMapFileName);
|
| + outputStream.writeString('\n');
|
| + }
|
| + outputStream.close();
|
| + }
|
| +
|
| + return new StreamController<String>()
|
| + ..listen(outputStream.writeString, onDone: onDone);
|
| }
|
| +
|
| + api.compile(uri, libraryRoot, packageRoot,
|
| + inputProvider, handler,
|
| + options, outputProvider)
|
| + .then(compilationDone);
|
| }
|
|
|
| class AbortLeg {
|
|
|