| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // TODO(vsm): Merge RulesOptions and TypeOptions | 73 // TODO(vsm): Merge RulesOptions and TypeOptions |
| 74 /// Options used by our RestrictedRules. | 74 /// Options used by our RestrictedRules. |
| 75 class RulesOptions extends TypeOptions { | 75 class RulesOptions extends TypeOptions { |
| 76 /// Whether to infer types downwards from local context | 76 /// Whether to infer types downwards from local context |
| 77 final bool inferDownwards; | 77 final bool inferDownwards; |
| 78 static const inferDownwardsDefault = true; | 78 static const inferDownwardsDefault = true; |
| 79 | 79 |
| 80 /// Whether to inject casts between Dart assignable types. | 80 /// Whether to inject casts between Dart assignable types. |
| 81 final bool relaxedCasts; | 81 final bool relaxedCasts; |
| 82 | 82 |
| 83 /// Whether to use static types for code generation. | 83 RulesOptions( |
| 84 final bool ignoreTypes; | 84 {this.inferDownwards: inferDownwardsDefault, this.relaxedCasts: true}); |
| 85 | |
| 86 RulesOptions({this.inferDownwards: inferDownwardsDefault, | |
| 87 this.relaxedCasts: true, this.ignoreTypes: false}); | |
| 88 } | 85 } |
| 89 | 86 |
| 90 class JSCodeOptions { | 87 class JSCodeOptions { |
| 91 /// Whether to emit the source map files. | 88 /// Whether to emit the source map files. |
| 92 final bool emitSourceMaps; | 89 final bool emitSourceMaps; |
| 93 | 90 |
| 94 JSCodeOptions({this.emitSourceMaps: true}); | 91 JSCodeOptions({this.emitSourceMaps: true}); |
| 95 } | 92 } |
| 96 | 93 |
| 97 /// General options used by the dev compiler. | 94 /// General options used by the dev compiler. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 178 |
| 182 /// Restrict inference of fields and top-levels to those that are final and | 179 /// Restrict inference of fields and top-levels to those that are final and |
| 183 /// const. | 180 /// const. |
| 184 @override | 181 @override |
| 185 final bool onlyInferConstsAndFinalFields; | 182 final bool onlyInferConstsAndFinalFields; |
| 186 | 183 |
| 187 /// List of non-nullable types. | 184 /// List of non-nullable types. |
| 188 @override | 185 @override |
| 189 final List<String> nonnullableTypes; | 186 final List<String> nonnullableTypes; |
| 190 | 187 |
| 191 /// Whether to use static types for code generation. | |
| 192 @override | |
| 193 final bool ignoreTypes; | |
| 194 | |
| 195 /// Whether to emit the source map files. | 188 /// Whether to emit the source map files. |
| 196 @override | 189 @override |
| 197 final bool emitSourceMaps; | 190 final bool emitSourceMaps; |
| 198 | 191 |
| 199 /// Location for runtime files, such as `dart_runtime.js`. By default this is | 192 /// Location for runtime files, such as `dart_runtime.js`. By default this is |
| 200 /// inferred to be under `lib/runtime/` in the location of the `dev_compiler` | 193 /// inferred to be under `lib/runtime/` in the location of the `dev_compiler` |
| 201 /// package (if we can infer where that is located). | 194 /// package (if we can infer where that is located). |
| 202 final String runtimeDir; | 195 final String runtimeDir; |
| 203 | 196 |
| 204 /// Custom URI mappings, such as "dart:foo" -> "path/to/foo.dart" | 197 /// Custom URI mappings, such as "dart:foo" -> "path/to/foo.dart" |
| 205 final Map<String, String> customUrlMappings; | 198 final Map<String, String> customUrlMappings; |
| 206 | 199 |
| 207 CompilerOptions({this.checkSdk: false, this.dumpInfo: false, | 200 CompilerOptions({this.checkSdk: false, this.dumpInfo: false, |
| 208 this.dumpInfoFile, this.forceCompile: false, this.ignoreTypes: false, | 201 this.dumpInfoFile, this.forceCompile: false, this.outputDir, |
| 209 this.outputDir, this.useColors: true, this.relaxedCasts: true, | 202 this.useColors: true, this.relaxedCasts: true, |
| 210 this.useMultiPackage: false, this.packageRoot: 'packages/', | 203 this.useMultiPackage: false, this.packageRoot: 'packages/', |
| 211 this.packagePaths: const <String>[], this.resources: const <String>[], | 204 this.packagePaths: const <String>[], this.resources: const <String>[], |
| 212 this.inferDownwards: RulesOptions.inferDownwardsDefault, | 205 this.inferDownwards: RulesOptions.inferDownwardsDefault, |
| 213 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, | 206 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, |
| 214 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, | 207 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, |
| 215 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal
FieldsDefault, | 208 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal
FieldsDefault, |
| 216 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, | 209 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, |
| 217 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, | 210 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, |
| 218 this.emitSourceMaps: true, this.entryPointFile: null, | 211 this.emitSourceMaps: true, this.entryPointFile: null, |
| 219 this.serverMode: false, this.useImplicitHtml: false, | 212 this.serverMode: false, this.useImplicitHtml: false, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 customUrlMappings[splitMapping[0]] = splitMapping[1]; | 258 customUrlMappings[splitMapping[0]] = splitMapping[1]; |
| 266 } | 259 } |
| 267 | 260 |
| 268 var entryPointFile = args.rest.length == 0 ? null : args.rest.first; | 261 var entryPointFile = args.rest.length == 0 ? null : args.rest.first; |
| 269 | 262 |
| 270 return new CompilerOptions( | 263 return new CompilerOptions( |
| 271 checkSdk: args['sdk-check'], | 264 checkSdk: args['sdk-check'], |
| 272 dumpInfo: dumpInfo, | 265 dumpInfo: dumpInfo, |
| 273 dumpInfoFile: args['dump-info-file'], | 266 dumpInfoFile: args['dump-info-file'], |
| 274 forceCompile: args['force-compile'] || serverMode, | 267 forceCompile: args['force-compile'] || serverMode, |
| 275 ignoreTypes: args['ignore-types'], | |
| 276 outputDir: outputDir, | 268 outputDir: outputDir, |
| 277 relaxedCasts: args['relaxed-casts'], | 269 relaxedCasts: args['relaxed-casts'], |
| 278 useColors: useColors, | 270 useColors: useColors, |
| 279 customUrlMappings: customUrlMappings, | 271 customUrlMappings: customUrlMappings, |
| 280 useMultiPackage: args['use-multi-package'], | 272 useMultiPackage: args['use-multi-package'], |
| 281 packageRoot: args['package-root'], | 273 packageRoot: args['package-root'], |
| 282 packagePaths: args['package-paths'].split(','), | 274 packagePaths: args['package-paths'].split(','), |
| 283 resources: args['resources'] | 275 resources: args['resources'] |
| 284 .split(',') | 276 .split(',') |
| 285 .where((s) => s.isNotEmpty) | 277 .where((s) => s.isNotEmpty) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 303 port: int.parse(args['port']), | 295 port: int.parse(args['port']), |
| 304 runtimeDir: runtimeDir); | 296 runtimeDir: runtimeDir); |
| 305 } | 297 } |
| 306 | 298 |
| 307 final ArgParser argParser = new ArgParser() | 299 final ArgParser argParser = new ArgParser() |
| 308 // resolver/checker options | 300 // resolver/checker options |
| 309 ..addFlag('sdk-check', | 301 ..addFlag('sdk-check', |
| 310 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) | 302 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) |
| 311 ..addFlag('mock-sdk', | 303 ..addFlag('mock-sdk', |
| 312 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false) | 304 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false) |
| 313 ..addFlag('ignore-types', | |
| 314 help: 'Ignore types during codegen', defaultsTo: false) | |
| 315 ..addFlag('relaxed-casts', | 305 ..addFlag('relaxed-casts', |
| 316 help: 'Cast between Dart assignable types', defaultsTo: true) | 306 help: 'Cast between Dart assignable types', defaultsTo: true) |
| 317 ..addOption('nonnullable', | 307 ..addOption('nonnullable', |
| 318 abbr: 'n', | 308 abbr: 'n', |
| 319 help: 'Comma separated string of non-nullable types', | 309 help: 'Comma separated string of non-nullable types', |
| 320 defaultsTo: null) | 310 defaultsTo: null) |
| 321 ..addFlag('infer-downwards', | 311 ..addFlag('infer-downwards', |
| 322 help: 'Infer types downwards from local context', | 312 help: 'Infer types downwards from local context', |
| 323 defaultsTo: RulesOptions.inferDownwardsDefault) | 313 defaultsTo: RulesOptions.inferDownwardsDefault) |
| 324 ..addFlag('infer-from-overrides', | 314 ..addFlag('infer-from-overrides', |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // The pub-cache directory is two levels up, but we verify that the layout | 413 // The pub-cache directory is two levels up, but we verify that the layout |
| 424 // looks correct. | 414 // looks correct. |
| 425 if (path.basename(dir) != 'dev_compiler') return null; | 415 if (path.basename(dir) != 'dev_compiler') return null; |
| 426 dir = path.dirname(dir); | 416 dir = path.dirname(dir); |
| 427 if (path.basename(dir) != 'global_packages') return null; | 417 if (path.basename(dir) != 'global_packages') return null; |
| 428 dir = path.dirname(dir); | 418 dir = path.dirname(dir); |
| 429 return path.join(dir, cacheDir, 'lib', 'runtime'); | 419 return path.join(dir, cacheDir, 'lib', 'runtime'); |
| 430 } | 420 } |
| 431 return null; | 421 return null; |
| 432 } | 422 } |
| OLD | NEW |