| 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 dev_compiler.src.options; | 6 library dev_compiler.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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 static const inferDownwardsDefault = true; | 72 static const inferDownwardsDefault = true; |
| 73 | 73 |
| 74 /// Whether to inject casts between Dart assignable types. | 74 /// Whether to inject casts between Dart assignable types. |
| 75 final bool relaxedCasts; | 75 final bool relaxedCasts; |
| 76 | 76 |
| 77 /// Whether to use static types for code generation. | 77 /// Whether to use static types for code generation. |
| 78 final bool ignoreTypes; | 78 final bool ignoreTypes; |
| 79 | 79 |
| 80 /// Whether to wrap closures for compatibility. | 80 /// Whether to wrap closures for compatibility. |
| 81 final bool wrapClosures; | 81 final bool wrapClosures; |
| 82 static const wrapClosuresDefault = true; |
| 82 | 83 |
| 83 RulesOptions({this.allowConstCasts: true, this.covariantGenerics: true, | 84 RulesOptions({this.allowConstCasts: true, this.covariantGenerics: true, |
| 84 this.inferDownwards: inferDownwardsDefault, this.relaxedCasts: true, | 85 this.inferDownwards: inferDownwardsDefault, this.relaxedCasts: true, |
| 85 this.ignoreTypes: false, this.wrapClosures: true}); | 86 this.ignoreTypes: false, this.wrapClosures: wrapClosuresDefault}); |
| 86 } | 87 } |
| 87 | 88 |
| 88 class JSCodeOptions { | 89 class JSCodeOptions { |
| 89 /// Whether to emit the source map files. | 90 /// Whether to emit the source map files. |
| 90 final bool emitSourceMaps; | 91 final bool emitSourceMaps; |
| 91 | 92 |
| 92 JSCodeOptions({this.emitSourceMaps: true}); | 93 JSCodeOptions({this.emitSourceMaps: true}); |
| 93 } | 94 } |
| 94 | 95 |
| 95 /// General options used by the dev compiler. | 96 /// General options used by the dev compiler. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 213 |
| 213 /// Location for runtime files, such as `dart_runtime.js`. By default this is | 214 /// Location for runtime files, such as `dart_runtime.js`. By default this is |
| 214 /// inferred to be under `lib/runtime/` in the location of the `dev_compiler` | 215 /// inferred to be under `lib/runtime/` in the location of the `dev_compiler` |
| 215 /// package (if we can infer where that is located). | 216 /// package (if we can infer where that is located). |
| 216 final String runtimeDir; | 217 final String runtimeDir; |
| 217 | 218 |
| 218 CompilerOptions({this.allowConstCasts: true, this.checkSdk: false, | 219 CompilerOptions({this.allowConstCasts: true, this.checkSdk: false, |
| 219 this.dumpInfo: false, this.dumpInfoFile, this.dumpSrcDir, | 220 this.dumpInfo: false, this.dumpInfoFile, this.dumpSrcDir, |
| 220 this.forceCompile: false, this.formatOutput: false, | 221 this.forceCompile: false, this.formatOutput: false, |
| 221 this.cheapTestFormat: false, this.ignoreTypes: false, | 222 this.cheapTestFormat: false, this.ignoreTypes: false, |
| 222 this.wrapClosures: true, this.outputDir, this.outputDart: false, | 223 this.wrapClosures: RulesOptions.wrapClosuresDefault, this.outputDir, |
| 223 this.useColors: true, this.covariantGenerics: true, | 224 this.outputDart: false, this.useColors: true, |
| 224 this.relaxedCasts: true, this.useMultiPackage: false, | 225 this.covariantGenerics: true, this.relaxedCasts: true, |
| 225 this.packageRoot: 'packages/', this.packagePaths: const <String>[], | 226 this.useMultiPackage: false, this.packageRoot: 'packages/', |
| 227 this.packagePaths: const <String>[], |
| 226 this.inferDownwards: RulesOptions.inferDownwardsDefault, | 228 this.inferDownwards: RulesOptions.inferDownwardsDefault, |
| 227 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, | 229 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, |
| 228 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, | 230 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, |
| 229 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal
FieldsDefault, | 231 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal
FieldsDefault, |
| 230 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, | 232 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, |
| 231 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, | 233 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, |
| 232 this.emitSourceMaps: true, this.entryPointFile: null, | 234 this.emitSourceMaps: true, this.entryPointFile: null, |
| 233 this.serverMode: false, this.host: 'localhost', this.port: 8080, | 235 this.serverMode: false, this.host: 'localhost', this.port: 8080, |
| 234 this.runtimeDir}); | 236 this.runtimeDir}); |
| 235 } | 237 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 ..addFlag('allow-const-casts', | 304 ..addFlag('allow-const-casts', |
| 303 help: 'Allow casts in const contexts', defaultsTo: true) | 305 help: 'Allow casts in const contexts', defaultsTo: true) |
| 304 ..addFlag('sdk-check', | 306 ..addFlag('sdk-check', |
| 305 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) | 307 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) |
| 306 ..addFlag('mock-sdk', | 308 ..addFlag('mock-sdk', |
| 307 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false) | 309 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false) |
| 308 ..addFlag('covariant-generics', | 310 ..addFlag('covariant-generics', |
| 309 help: 'Use covariant generics', defaultsTo: true) | 311 help: 'Use covariant generics', defaultsTo: true) |
| 310 ..addFlag('ignore-types', | 312 ..addFlag('ignore-types', |
| 311 help: 'Ignore types during codegen', defaultsTo: false) | 313 help: 'Ignore types during codegen', defaultsTo: false) |
| 312 ..addFlag('wrap-closures', help: 'wrap closures implicitly', defaultsTo: true) | 314 ..addFlag('wrap-closures', |
| 315 help: 'wrap closures implicitly', |
| 316 defaultsTo: RulesOptions.wrapClosuresDefault) |
| 313 ..addFlag('relaxed-casts', | 317 ..addFlag('relaxed-casts', |
| 314 help: 'Cast between Dart assignable types', defaultsTo: true) | 318 help: 'Cast between Dart assignable types', defaultsTo: true) |
| 315 ..addOption('nonnullable', | 319 ..addOption('nonnullable', |
| 316 abbr: 'n', | 320 abbr: 'n', |
| 317 help: 'Comma separated string of non-nullable types', | 321 help: 'Comma separated string of non-nullable types', |
| 318 defaultsTo: null) | 322 defaultsTo: null) |
| 319 ..addFlag('infer-downwards', | 323 ..addFlag('infer-downwards', |
| 320 help: 'Infer types downwards from local context', | 324 help: 'Infer types downwards from local context', |
| 321 defaultsTo: RulesOptions.inferDownwardsDefault) | 325 defaultsTo: RulesOptions.inferDownwardsDefault) |
| 322 ..addFlag('infer-from-overrides', | 326 ..addFlag('infer-from-overrides', |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 // The pub-cache directory is two levels up, but we verify that the layout | 420 // The pub-cache directory is two levels up, but we verify that the layout |
| 417 // looks correct. | 421 // looks correct. |
| 418 if (path.basename(dir) != 'dev_compiler') return null; | 422 if (path.basename(dir) != 'dev_compiler') return null; |
| 419 dir = path.dirname(dir); | 423 dir = path.dirname(dir); |
| 420 if (path.basename(dir) != 'global_packages') return null; | 424 if (path.basename(dir) != 'global_packages') return null; |
| 421 dir = path.dirname(dir); | 425 dir = path.dirname(dir); |
| 422 return path.join(dir, cacheDir, 'lib', 'runtime'); | 426 return path.join(dir, cacheDir, 'lib', 'runtime'); |
| 423 } | 427 } |
| 424 return null; | 428 return null; |
| 425 } | 429 } |
| OLD | NEW |