Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/dart2js.dart |
| =================================================================== |
| --- sdk/lib/_internal/compiler/implementation/dart2js.dart (revision 29517) |
| +++ sdk/lib/_internal/compiler/implementation/dart2js.dart (working copy) |
| @@ -112,6 +112,7 @@ |
| // TODO(johnniwinther): Measure time for reading files. |
| SourceFileProvider inputProvider = new CompilerSourceFileProvider(); |
| diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); |
| + Map<String, dynamic> environment = new Map<String, dynamic>(); |
| passThrough(String argument) => options.add(argument); |
| @@ -174,6 +175,24 @@ |
| passThrough('--verbose'); |
| } |
| + addInEnvironment(String argument) { |
| + Match m = new RegExp('^-D(.+)=(.+)').firstMatch(argument); |
|
ahe
2013/10/30 13:03:09
Terminate with $.
Lasse Reichstein Nielsen
2013/10/30 13:34:48
Terminating isn't necessary. The last capture is g
ngeoffray
2013/10/30 15:13:59
Done.
|
| + String name = m[1]; |
| + String value = m[2]; |
| + if (value == 'true') { |
| + environment[name] = true; |
|
Lasse Reichstein Nielsen
2013/10/30 13:34:48
Why parse the arguments here?
Even if the value is
kasperl
2013/10/30 13:49:56
I agree with Lasse here. It seems cleaner to do th
ngeoffray
2013/10/30 15:13:59
Done.
|
| + } else if (value == 'false') { |
| + environment[name] = false; |
| + } else { |
| + int number = int.parse(value, onError: (_) => null); |
| + if (number == null) { |
| + environment[name] = value; |
| + } else { |
| + environment[name] = number; |
| + } |
| + } |
| + } |
| + |
| setCategories(String argument) { |
| List<String> categories = extractParameter(argument).split(','); |
| Set<String> allowedCategories = |
| @@ -275,6 +294,7 @@ |
| new OptionHandler('--terse', passThrough), |
| new OptionHandler('--disallow-unsafe-eval', |
| (_) => hasDisallowUnsafeEval = true), |
| + new OptionHandler('-D.+=.+', addInEnvironment), |
| // The following two options must come last. |
| new OptionHandler('-.*', (String argument) { |
| @@ -411,7 +431,7 @@ |
| return api.compile(uri, libraryRoot, packageRoot, |
| inputProvider, diagnosticHandler, |
| - options, outputProvider) |
| + options, outputProvider, environment) |
| .then(compilationDone); |
| } |