Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/dart.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/dart.dart b/sdk/lib/_internal/pub/lib/src/dart.dart |
| index f6d8b11074aa9f71f942e6434db7b0e698f7aa2c..325f19f99d125b6bde1723ff67284a0964d70d7c 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/dart.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/dart.dart |
| @@ -21,24 +21,35 @@ import 'io.dart'; |
| import 'sdk.dart' as sdk; |
| import 'utils.dart'; |
| +/// Returns the path to the library directory. This corresponds to the "sdk" |
|
nweiz
2013/09/27 22:21:17
Paragraph break.
"Library directory" doesn't tell
Bob Nystrom
2013/09/28 00:56:11
Done.
|
| +/// directory in the repo and to the root of the compiled SDK. |
| +String get libraryPath { |
| + if (runningFromSdk) return sdk.rootDirectory; |
| + return path.join(repoRoot, 'sdk'); |
| +} |
| + |
| /// Returns [entrypoint] compiled to JavaScript (or to Dart if [toDart] is |
| /// true). |
| /// |
| /// By default, the package root is assumed to be adjacent to [entrypoint], but |
| -/// if [packageRoot] is passed that will be used instead. |
| +/// if [packageRoot] is passed that will be used instead. If [provider] is |
| +/// omitted, uses a default [SourceFileProvider]. |
|
nweiz
2013/09/27 22:21:17
"a default [SourceFileProvider] that loads files d
Bob Nystrom
2013/09/28 00:56:11
Done.
|
| Future<String> compile(String entrypoint, {String packageRoot, |
| - bool toDart: false}) { |
| + bool toDart: false, SourceFileProvider provider}) { |
| return new Future.sync(() { |
| - var provider = new SourceFileProvider(); |
| var options = <String>['--categories=Client,Server', '--minify']; |
| if (toDart) options.add('--output-type=dart'); |
| if (packageRoot == null) { |
| packageRoot = path.join(path.dirname(entrypoint), 'packages'); |
| } |
| + if (provider == null) { |
| + provider = new SourceFileProvider(); |
| + } |
| + |
| return compiler.compile( |
| path.toUri(entrypoint), |
| - path.toUri(appendSlash(_libPath)), |
| + path.toUri(appendSlash(libraryPath)), |
| path.toUri(appendSlash(packageRoot)), |
| provider.readStringFromUri, |
| new FormattingDiagnosticHandler(provider).diagnosticHandler, |
| @@ -49,13 +60,6 @@ Future<String> compile(String entrypoint, {String packageRoot, |
| }); |
| } |
| -/// Returns the path to the library directory. This corresponds to the "sdk" |
| -/// directory in the repo and to the root of the compiled SDK. |
| -String get _libPath { |
| - if (runningFromSdk) return sdk.rootDirectory; |
| - return path.join(repoRoot, 'sdk'); |
| -} |
| - |
| /// Returns whether [dart] looks like an entrypoint file. |
| bool isEntrypoint(CompilationUnit dart) { |
| // TODO(nweiz): this misses the case where a Dart file doesn't contain main(), |