| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'configuration.dart'; | 5 import 'configuration.dart'; |
| 6 | 6 |
| 7 typedef String _LookUpFunction(Configuration configuration); | 7 typedef String _LookUpFunction(Configuration configuration); |
| 8 typedef bool _BoolLookUpFunction(Configuration configuration); | 8 typedef bool _BoolLookUpFunction(Configuration configuration); |
| 9 | 9 |
| 10 // TODO(29756): Instead of synthesized negated variables like "unchecked", | 10 // TODO(29756): Instead of synthesized negated variables like "unchecked", |
| 11 // consider adding support for "!" to status expressions. | 11 // consider adding support for "!" to status expressions. |
| 12 final _variables = { | 12 final _variables = { |
| 13 "analyzer": new _Variable.bool((c) => c.compiler == Compiler.dart2analyzer), | 13 "analyzer": new _Variable.bool((c) => c.compiler == Compiler.dart2analyzer), |
| 14 "arch": new _Variable((c) => c.architecture.name, Architecture.names), | 14 "arch": new _Variable((c) => c.architecture.name, Architecture.names), |
| 15 "browser": new _Variable.bool((c) => c.runtime.isBrowser), | 15 "browser": new _Variable.bool((c) => c.runtime.isBrowser), |
| 16 "builder_tag": new _Variable((c) => c.builderTag ?? "", const []), | 16 "builder_tag": new _Variable((c) => c.builderTag ?? "", const []), |
| 17 "checked": new _Variable.bool((c) => c.isChecked), | 17 "checked": new _Variable.bool((c) => c.isChecked), |
| 18 "compiler": new _Variable((c) => c.compiler.name, Compiler.names), | 18 "compiler": new _Variable((c) => c.compiler.name, Compiler.names), |
| 19 "csp": new _Variable.bool((c) => c.isCsp), | 19 "csp": new _Variable.bool((c) => c.isCsp), |
| 20 "dart2js_with_kernel": new _Variable.bool((c) => c.useDart2JSWithKernel), | 20 "dart2js_with_kernel": new _Variable.bool((c) => c.useDart2JSWithKernel), |
| 21 "fast_startup": new _Variable.bool((c) => c.useFastStartup), | 21 "fast_startup": new _Variable.bool((c) => c.useFastStartup), |
| 22 "host_checked": new _Variable.bool((c) => c.isHostChecked), | 22 "host_checked": new _Variable.bool((c) => c.isHostChecked), |
| 23 "host_unchecked": new _Variable.bool((c) => !c.isHostChecked), | 23 "host_unchecked": new _Variable.bool((c) => !c.isHostChecked), |
| 24 "hot_reload": new _Variable.bool((c) => c.hotReload), | 24 "hot_reload": new _Variable.bool((c) => c.hotReload), |
| 25 "hot_reload_rollback": new _Variable.bool((c) => c.hotReloadRollback), | 25 "hot_reload_rollback": new _Variable.bool((c) => c.hotReloadRollback), |
| 26 "ie": new _Variable.bool((c) => c.runtime.isIE), | 26 "ie": new _Variable.bool((c) => c.runtime.isIE), |
| 27 "jscl": new _Variable.bool((c) => c.runtime.isJSCommandLine), | 27 "jscl": new _Variable.bool((c) => c.runtime.isJSCommandLine), |
| 28 "minified": new _Variable.bool((c) => c.isMinified), | 28 "minified": new _Variable.bool((c) => c.isMinified), |
| 29 "mode": new _Variable((c) => c.mode.name, Mode.names), | 29 "mode": new _Variable((c) => c.mode.name, Mode.names), |
| 30 "runtime": new _Variable((c) => c.runtime.name, Runtime.names), | 30 "runtime": new _Variable(_runtimeName, Runtime.names), |
| 31 "strong": new _Variable.bool((c) => c.isStrong), | 31 "strong": new _Variable.bool((c) => c.isStrong), |
| 32 "system": new _Variable((c) => c.system.name, System.names), | 32 "system": new _Variable((c) => c.system.name, System.names), |
| 33 "unchecked": new _Variable.bool((c) => !c.isChecked), | 33 "unchecked": new _Variable.bool((c) => !c.isChecked), |
| 34 "unminified": new _Variable.bool((c) => !c.isMinified), | 34 "unminified": new _Variable.bool((c) => !c.isMinified), |
| 35 "use_sdk": new _Variable.bool((c) => c.useSdk) | 35 "use_sdk": new _Variable.bool((c) => c.useSdk) |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 /// Gets the name of the runtime as it appears in status files. |
| 39 String _runtimeName(Configuration configuration) { |
| 40 // TODO(rnystrom): Handle "ff" being used as the name for firefox. We don't |
| 41 // want to make the Runtime itself use that as the name because it appears |
| 42 // elsewhere in test.dart and we want those other places to show "firefox". |
| 43 if (configuration.runtime == Runtime.firefox) return 'ff'; |
| 44 |
| 45 return configuration.runtime.name; |
| 46 } |
| 47 |
| 38 /// Defines the variables that are available for use inside a status file | 48 /// Defines the variables that are available for use inside a status file |
| 39 /// section header. | 49 /// section header. |
| 40 /// | 50 /// |
| 41 /// These mostly map to command line arguments with the same name, though this | 51 /// These mostly map to command line arguments with the same name, though this |
| 42 /// is only a subset of the full set of command line arguments. | 52 /// is only a subset of the full set of command line arguments. |
| 43 class Environment { | 53 class Environment { |
| 44 /// Validates that the variable with [name] exists and can be compared | 54 /// Validates that the variable with [name] exists and can be compared |
| 45 /// against [value]. | 55 /// against [value]. |
| 46 /// | 56 /// |
| 47 /// If any errors are found, adds them to [errors]. | 57 /// If any errors are found, adds them to [errors]. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 _Variable(this._lookUp, Iterable<String> allowed) | 106 _Variable(this._lookUp, Iterable<String> allowed) |
| 97 : allowedValues = allowed.toList(); | 107 : allowedValues = allowed.toList(); |
| 98 | 108 |
| 99 /// Creates a Boolean variable with allowed values "true" and "false". | 109 /// Creates a Boolean variable with allowed values "true" and "false". |
| 100 _Variable.bool(_BoolLookUpFunction lookUp) | 110 _Variable.bool(_BoolLookUpFunction lookUp) |
| 101 : _lookUp = ((configuration) => lookUp(configuration).toString()), | 111 : _lookUp = ((configuration) => lookUp(configuration).toString()), |
| 102 allowedValues = const ["true", "false"]; | 112 allowedValues = const ["true", "false"]; |
| 103 | 113 |
| 104 String lookUp(Configuration configuration) => _lookUp(configuration); | 114 String lookUp(Configuration configuration) => _lookUp(configuration); |
| 105 } | 115 } |
| OLD | NEW |