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

Unified Diff: sdk/lib/_internal/pub/lib/src/executable.dart

Issue 599993004: Don't load transformers that aren't going to be used for an executable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 3 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 | « sdk/lib/_internal/pub/lib/src/entrypoint.dart ('k') | sdk/lib/_internal/pub/lib/src/global_packages.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/executable.dart
diff --git a/sdk/lib/_internal/pub/lib/src/executable.dart b/sdk/lib/_internal/pub/lib/src/executable.dart
index 2becb86920e12dc18f4914507da7c87b77d5cbef..f689572268dc81e794e3945aee2d16a9c85974ea 100644
--- a/sdk/lib/_internal/pub/lib/src/executable.dart
+++ b/sdk/lib/_internal/pub/lib/src/executable.dart
@@ -36,6 +36,21 @@ Future<int> runExecutable(Entrypoint entrypoint, String package,
BarbackMode mode}) async {
if (mode == null) mode = BarbackMode.RELEASE;
+ // Make sure the package is an immediate dependency of the entrypoint or the
+ // entrypoint itself.
+ if (entrypoint.root.name != package &&
+ !entrypoint.root.immediateDependencies
+ .any((dep) => dep.name == package)) {
+ var graph = await entrypoint.loadPackageGraph();
+ if (graph.packages.containsKey(package)) {
+ dataError('Package "$package" is not an immediate dependency.\n'
+ 'Cannot run executables in transitive dependencies.');
+ } else {
+ dataError('Could not find package "$package". Did you forget to add a '
+ 'dependency?');
+ }
+ }
+
// Unless the user overrides the verbosity, we want to filter out the
// normal pub output shown while loading the environment.
if (log.verbosity == log.Verbosity.NORMAL) {
@@ -69,10 +84,13 @@ Future<int> runExecutable(Entrypoint entrypoint, String package,
executable = p.join("bin", executable);
}
+ var assetPath = "${p.url.joinAll(p.split(executable))}.dart";
+ var id = new AssetId(package, assetPath);
+
// TODO(nweiz): Use [packages] to only load assets from packages that the
// executable might load.
var environment = await AssetEnvironment.create(entrypoint, mode,
- useDart2JS: false);
+ useDart2JS: false, entrypoints: [id]);
environment.barback.errors.listen((error) {
log.error(log.red("Build error:\n$error"));
});
@@ -84,27 +102,10 @@ Future<int> runExecutable(Entrypoint entrypoint, String package,
// will work from within some deeply nested script.
server = await environment.serveDirectory(rootDir);
} else {
- // Make sure the dependency exists.
- var dep = entrypoint.root.immediateDependencies.firstWhere(
- (dep) => dep.name == package, orElse: () => null);
- if (dep == null) {
- if (environment.graph.packages.containsKey(package)) {
- dataError('Package "$package" is not an immediate dependency.\n'
- 'Cannot run executables in transitive dependencies.');
- } else {
- dataError('Could not find package "$package". Did you forget to '
- 'add a dependency?');
- }
- }
-
// For other packages, always use the "bin" directory.
server = await environment.servePackageBinDirectory(package);
}
- // Try to make sure the entrypoint script exists (or is generated) before
- // we spawn the process to run it.
- var assetPath = "${p.url.joinAll(p.split(executable))}.dart";
- var id = new AssetId(server.package, assetPath);
// TODO(rnystrom): Use try/catch here when
// https://github.com/dart-lang/async_await/issues/4 is fixed.
return environment.barback.getAssetById(id).then((_) async {
@@ -117,7 +118,7 @@ Future<int> runExecutable(Entrypoint entrypoint, String package,
// Get the URL of the executable, relative to the server's root directory.
var relativePath = p.url.relative(assetPath,
from: p.url.joinAll(p.split(server.rootDirectory)));
- vmArgs.add(server.url.resolve(relativePath).toString());
+ vmArgs.add('bin/css.dart');
vmArgs.addAll(args);
var process = await Process.start(Platform.executable, vmArgs);
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/entrypoint.dart ('k') | sdk/lib/_internal/pub/lib/src/global_packages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698