| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Set of flags and options passed to the compiler | 5 /// Set of flags and options passed to the compiler |
| 6 library ddc.src.options; | 6 library ddc.src.options; |
| 7 | 7 |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 /// Minimum log-level reported on the command-line. | 134 /// Minimum log-level reported on the command-line. |
| 135 final Level logLevel; | 135 final Level logLevel; |
| 136 | 136 |
| 137 /// File where to start compilation from. | 137 /// File where to start compilation from. |
| 138 final String entryPointFile; | 138 final String entryPointFile; |
| 139 | 139 |
| 140 /// Whether to allow casts in constant contexts. | 140 /// Whether to allow casts in constant contexts. |
| 141 @override | 141 @override |
| 142 final bool allowConstCasts; | 142 final bool allowConstCasts; |
| 143 | 143 |
| 144 /// Whether to run as a development server. |
| 145 final bool serverMode; |
| 146 |
| 147 /// Port used for the HTTP server when [serverMode] is on. |
| 148 final int port; |
| 149 |
| 144 /// Whether to use covariant generics | 150 /// Whether to use covariant generics |
| 145 @override | 151 @override |
| 146 final bool covariantGenerics; | 152 final bool covariantGenerics; |
| 147 | 153 |
| 148 /// Whether to inject casts between Dart assignable types. | 154 /// Whether to inject casts between Dart assignable types. |
| 149 @override | 155 @override |
| 150 final bool relaxedCasts; | 156 final bool relaxedCasts; |
| 151 | 157 |
| 152 /// Whether to resolve 'package:' uris using the multi-package resolver. | 158 /// Whether to resolve 'package:' uris using the multi-package resolver. |
| 153 @override | 159 @override |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 this.cheapTestFormat: false, this.ignoreTypes: false, this.outputDir, | 203 this.cheapTestFormat: false, this.ignoreTypes: false, this.outputDir, |
| 198 this.outputDart: false, this.useColors: true, | 204 this.outputDart: false, this.useColors: true, |
| 199 this.covariantGenerics: true, this.relaxedCasts: true, | 205 this.covariantGenerics: true, this.relaxedCasts: true, |
| 200 this.useMultiPackage: false, this.packageRoot: 'packages/', | 206 this.useMultiPackage: false, this.packageRoot: 'packages/', |
| 201 this.packagePaths: const <String>[], this.inferFromOverrides: true, | 207 this.packagePaths: const <String>[], this.inferFromOverrides: true, |
| 202 this.inferStaticsFromIdentifiers: false, | 208 this.inferStaticsFromIdentifiers: false, |
| 203 this.inferInNonStableOrder: false, | 209 this.inferInNonStableOrder: false, |
| 204 this.onlyInferConstsAndFinalFields: false, | 210 this.onlyInferConstsAndFinalFields: false, |
| 205 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, | 211 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, |
| 206 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, | 212 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, |
| 207 this.emitSourceMaps: true, this.entryPointFile: null}); | 213 this.emitSourceMaps: true, this.entryPointFile: null, |
| 214 this.serverMode: false, this.port: 8080}); |
| 208 } | 215 } |
| 209 | 216 |
| 210 /// Parses options from the command-line | 217 /// Parses options from the command-line |
| 211 CompilerOptions parseOptions(List<String> argv) { | 218 CompilerOptions parseOptions(List<String> argv) { |
| 212 ArgResults args = argParser.parse(argv); | 219 ArgResults args = argParser.parse(argv); |
| 213 var levelName = args['log'].toUpperCase(); | 220 var levelName = args['log'].toUpperCase(); |
| 214 var useColors = stdioType(stdout) == StdioType.TERMINAL; | 221 var useColors = stdioType(stdout) == StdioType.TERMINAL; |
| 215 var sdkPath = args['dart-sdk']; | 222 var sdkPath = args['dart-sdk']; |
| 216 if (sdkPath == null && !args['mock-sdk']) { | 223 if (sdkPath == null && !args['mock-sdk']) { |
| 217 sdkPath = getSdkDir(argv).path; | 224 sdkPath = getSdkDir(argv).path; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 238 inferInNonStableOrder: args['infer-eagerly'], | 245 inferInNonStableOrder: args['infer-eagerly'], |
| 239 onlyInferConstsAndFinalFields: args['infer-only-finals'], | 246 onlyInferConstsAndFinalFields: args['infer-only-finals'], |
| 240 nonnullableTypes: optionsToList(args['nonnullable'], | 247 nonnullableTypes: optionsToList(args['nonnullable'], |
| 241 defaultValue: TypeOptions.NONNULLABLE_TYPES), | 248 defaultValue: TypeOptions.NONNULLABLE_TYPES), |
| 242 help: args['help'], | 249 help: args['help'], |
| 243 useMockSdk: args['mock-sdk'], | 250 useMockSdk: args['mock-sdk'], |
| 244 dartSdkPath: sdkPath, | 251 dartSdkPath: sdkPath, |
| 245 logLevel: Level.LEVELS.firstWhere((Level l) => l.name == levelName, | 252 logLevel: Level.LEVELS.firstWhere((Level l) => l.name == levelName, |
| 246 orElse: () => Level.SEVERE), | 253 orElse: () => Level.SEVERE), |
| 247 emitSourceMaps: args['source-maps'], | 254 emitSourceMaps: args['source-maps'], |
| 248 entryPointFile: args.rest.length == 0 ? null : args.rest.first); | 255 entryPointFile: args.rest.length == 0 ? null : args.rest.first, |
| 256 serverMode: args['server'], |
| 257 port: int.parse(args['port'])); |
| 249 } | 258 } |
| 250 | 259 |
| 251 final ArgParser argParser = new ArgParser() | 260 final ArgParser argParser = new ArgParser() |
| 252 // resolver/checker options | 261 // resolver/checker options |
| 253 ..addFlag('allow-const-casts', | 262 ..addFlag('allow-const-casts', |
| 254 help: 'Allow casts in const contexts', defaultsTo: true) | 263 help: 'Allow casts in const contexts', defaultsTo: true) |
| 255 ..addFlag('sdk-check', | 264 ..addFlag('sdk-check', |
| 256 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) | 265 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) |
| 257 ..addFlag('mock-sdk', | 266 ..addFlag('mock-sdk', |
| 258 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false) | 267 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 ..addFlag('use-multi-package', | 303 ..addFlag('use-multi-package', |
| 295 help: 'Whether to use the multi-package resolver for "package:" imports', | 304 help: 'Whether to use the multi-package resolver for "package:" imports', |
| 296 defaultsTo: false) | 305 defaultsTo: false) |
| 297 ..addOption('package-paths', help: 'if using the multi-package resolver, ' | 306 ..addOption('package-paths', help: 'if using the multi-package resolver, ' |
| 298 'the list of directories where to look for packages.', defaultsTo: '') | 307 'the list of directories where to look for packages.', defaultsTo: '') |
| 299 ..addFlag('source-maps', | 308 ..addFlag('source-maps', |
| 300 help: 'Whether to emit source map files', defaultsTo: true) | 309 help: 'Whether to emit source map files', defaultsTo: true) |
| 301 | 310 |
| 302 // general options | 311 // general options |
| 303 ..addFlag('help', abbr: 'h', help: 'Display this message') | 312 ..addFlag('help', abbr: 'h', help: 'Display this message') |
| 313 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) |
| 314 ..addOption('port', |
| 315 help: 'Port where to serve files from (used only when --serve is on)', |
| 316 defaultsTo: '8080') |
| 304 ..addFlag('force-compile', | 317 ..addFlag('force-compile', |
| 305 help: 'Compile code with static errors', defaultsTo: false) | 318 help: 'Compile code with static errors', defaultsTo: false) |
| 306 ..addOption('log', abbr: 'l', help: 'Logging level', defaultsTo: 'severe') | 319 ..addOption('log', abbr: 'l', help: 'Logging level', defaultsTo: 'severe') |
| 307 ..addFlag('dump-info', | 320 ..addFlag('dump-info', |
| 308 abbr: 'i', help: 'Dump summary information', defaultsTo: false) | 321 abbr: 'i', help: 'Dump summary information', defaultsTo: false) |
| 309 ..addOption('dump-info-file', | 322 ..addOption('dump-info-file', |
| 310 abbr: 'f', | 323 abbr: 'f', |
| 311 help: 'Dump info json file (requires dump-info)', | 324 help: 'Dump info json file (requires dump-info)', |
| 312 defaultsTo: null); | 325 defaultsTo: null); |
| OLD | NEW |