Chromium Code Reviews

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/build_environment.dart

Issue 207423003: Support Dart core libraries in source maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart b/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
index f155374d7bf82e536e4d270da6a1223cda9cdfea..7aa5eac1b673b860c10c823dc955670e0f9df3cd 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
@@ -17,6 +17,7 @@ import '../io.dart';
import '../log.dart' as log;
import '../package.dart';
import '../package_graph.dart';
+import '../sdk.dart' as sdk;
import 'admin_server.dart';
import 'build_directory.dart';
import 'dart_forwarding_transformer.dart';
@@ -205,6 +206,16 @@ class BuildEnvironment {
}).then((_) => url);
}
+ /// Gets the build directory that contains [assetPath] within the entrypoint
+ /// package.
+ ///
+ /// If [assetPath] is not contained within a build directory, this will
+ /// throw an exception.
+ String getBuildDirectoryContaining(String assetPath) =>
+ _directories.values
+ .firstWhere((dir) => path.isWithin(dir.directory, assetPath))
+ .directory;
+
/// Return all URLs serving [assetPath] in this environment.
List<Uri> getUrlsForAssetPath(String assetPath) {
// Check the three (mutually-exclusive) places the path could be pointing.
@@ -339,6 +350,15 @@ class BuildEnvironment {
path.join('lib', path.relative(library, from: dartPath)));
});
+ // "$sdk" is a pseudo-package that allows the dart2js transformer to find
+ // the Dart core libraries without hitting the file system directly. This
+ // ensures they work with source maps.
+ var libPath = path.join(sdk.rootDirectory, "lib");
+ var sdkSources = listDir(libPath, recursive: true)
+ .where((file) => path.extension(file) == ".dart")
+ .map((file) => new AssetId('\$sdk',
+ path.join("lib", path.relative(file, from: sdk.rootDirectory))));
+
// Bind a server that we can use to load the transformers.
var transformerServer;
return BarbackServer.bind(this, _hostname, 0, null).then((server) {
@@ -346,6 +366,7 @@ class BuildEnvironment {
return log.progress("Loading source assets", () {
barback.updateSources(pubSources);
+ barback.updateSources(sdkSources);
return _provideSources();
});
}).then((_) {

Powered by Google App Engine