Chromium Code Reviews

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

Issue 1106713003: Support defining environment constants for dart2js via the command-line. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 8 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
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.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/barback/asset_environment.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart b/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
index c07d8600244d3ae048ae7aa933d5e6ceea805b75..e3c8d26d9b590f8338d912d17e7567da1b4a803d 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
@@ -60,15 +60,19 @@ class AssetEnvironment {
/// entrypoints are loaded. Each entrypoint is expected to refer to a Dart
/// library.
///
+ /// If [environmentConstants] is passed, the constants it defines are passed
+ /// on to the built-in dart2js transformer.
+ ///
/// Returns a [Future] that completes to the environment once the inputs,
/// transformers, and server are loaded and ready.
static Future<AssetEnvironment> create(Entrypoint entrypoint,
BarbackMode mode, {WatcherType watcherType, String hostname, int basePort,
Iterable<String> packages, Iterable<AssetId> entrypoints,
- bool useDart2JS: true}) {
+ Map<String, String> environmentConstants, bool useDart2JS: true}) {
if (watcherType == null) watcherType = WatcherType.NONE;
if (hostname == null) hostname = "localhost";
if (basePort == null) basePort = 0;
+ if (environmentConstants == null) environmentConstants = {};
return log.progress("Loading asset environment", () async {
var graph = await entrypoint.loadPackageGraph();
@@ -77,7 +81,7 @@ class AssetEnvironment {
barback.log.listen(_log);
var environment = new AssetEnvironment._(graph, barback, mode,
- watcherType, hostname, basePort);
+ watcherType, hostname, basePort, environmentConstants);
await environment._load(entrypoints: entrypoints, useDart2JS: useDart2JS);
return environment;
@@ -125,6 +129,9 @@ class AssetEnvironment {
/// The mode to run the transformers in.
final BarbackMode mode;
+ /// Constants to passed to the built-in dart2js transformer.
+ final Map<String, String> environmentConstants;
+
/// The [Transformer]s that should be appended by default to the root
/// package's transformer cascade. Will be empty if there are none.
final _builtInTransformers = <Transformer>[];
@@ -158,7 +165,8 @@ class AssetEnvironment {
Set<AssetId> _modifiedSources;
AssetEnvironment._(this.graph, this.barback, this.mode,
- this._watcherType, this._hostname, this._basePort);
+ this._watcherType, this._hostname, this._basePort,
+ this.environmentConstants);
/// Gets the built-in [Transformer]s that should be added to [package].
///
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine