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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 {this.useMockSdk: false, | 51 {this.useMockSdk: false, |
52 this.dartSdkPath, | 52 this.dartSdkPath, |
53 this.useMultiPackage: false, | 53 this.useMultiPackage: false, |
54 this.customUrlMappings: const {}, | 54 this.customUrlMappings: const {}, |
55 this.packageRoot: 'packages/', | 55 this.packageRoot: 'packages/', |
56 this.packagePaths: const <String>[], | 56 this.packagePaths: const <String>[], |
57 this.resources: const <String>[], | 57 this.resources: const <String>[], |
58 this.useImplicitHtml: false}); | 58 this.useImplicitHtml: false}); |
59 } | 59 } |
60 | 60 |
61 enum ModuleFormat { es6, legacy } | 61 enum ModuleFormat { es6, legacy, node } |
62 ModuleFormat parseModuleFormat(String s) => parseEnum(s, ModuleFormat.values); | 62 ModuleFormat parseModuleFormat(String s) => parseEnum(s, ModuleFormat.values); |
63 | 63 |
64 // TODO(jmesserly): refactor all codegen options here. | 64 // TODO(jmesserly): refactor all codegen options here. |
65 class CodegenOptions { | 65 class CodegenOptions { |
66 /// Whether to emit the source map files. | 66 /// Whether to emit the source map files. |
67 final bool emitSourceMaps; | 67 final bool emitSourceMaps; |
68 | 68 |
69 /// Whether to force compilation of code with static errors. | 69 /// Whether to force compilation of code with static errors. |
70 final bool forceCompile; | 70 final bool forceCompile; |
71 | 71 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 ..addOption('runtime-dir', | 308 ..addOption('runtime-dir', |
309 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) | 309 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) |
310 ..addFlag('arrow-fn-bind-this', | 310 ..addFlag('arrow-fn-bind-this', |
311 help: 'Work around `this` binding in => functions') | 311 help: 'Work around `this` binding in => functions') |
312 ..addOption('modules', | 312 ..addOption('modules', |
313 help: 'Which module pattern to emit', | 313 help: 'Which module pattern to emit', |
314 allowed: ModuleFormat.values.map(getEnumName).toList(), | 314 allowed: ModuleFormat.values.map(getEnumName).toList(), |
315 allowedHelp: { | 315 allowedHelp: { |
316 getEnumName(ModuleFormat.es6): 'es6 modules', | 316 getEnumName(ModuleFormat.es6): 'es6 modules', |
317 getEnumName(ModuleFormat.legacy): | 317 getEnumName(ModuleFormat.legacy): |
318 'a custom format used by dartdevc, similar to AMD' | 318 'a custom format used by dartdevc, similar to AMD', |
319 getEnumName(ModuleFormat.node): 'node.js modules' | |
Jennifer Messerly
2016/01/29 00:32:32
https://nodejs.org/api/modules.html
is a good lin
ochafik
2016/01/29 09:38:17
Thanks!
| |
319 }, | 320 }, |
320 defaultsTo: getEnumName(ModuleFormat.legacy)) | 321 defaultsTo: getEnumName(ModuleFormat.legacy)) |
321 | 322 |
322 // general options | 323 // general options |
323 ..addFlag('help', abbr: 'h', help: 'Display this message') | 324 ..addFlag('help', abbr: 'h', help: 'Display this message') |
324 ..addFlag('version', | 325 ..addFlag('version', |
325 negatable: false, help: 'Display the Dev Compiler verion') | 326 negatable: false, help: 'Display the Dev Compiler verion') |
326 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) | 327 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) |
327 ..addFlag('hashing', | 328 ..addFlag('hashing', |
328 help: 'Enable hash-based file caching.', defaultsTo: null) | 329 help: 'Enable hash-based file caching.', defaultsTo: null) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 // The pub-cache directory is two levels up, but we verify that the layout | 410 // The pub-cache directory is two levels up, but we verify that the layout |
410 // looks correct. | 411 // looks correct. |
411 if (path.basename(dir) != 'dev_compiler') return null; | 412 if (path.basename(dir) != 'dev_compiler') return null; |
412 dir = path.dirname(dir); | 413 dir = path.dirname(dir); |
413 if (path.basename(dir) != 'global_packages') return null; | 414 if (path.basename(dir) != 'global_packages') return null; |
414 dir = path.dirname(dir); | 415 dir = path.dirname(dir); |
415 return path.join(dir, cacheDir, 'lib', 'runtime'); | 416 return path.join(dir, cacheDir, 'lib', 'runtime'); |
416 } | 417 } |
417 return null; | 418 return null; |
418 } | 419 } |
OLD | NEW |