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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 class CodegenOptions { | 53 class CodegenOptions { |
54 /// Whether to emit the source map files. | 54 /// Whether to emit the source map files. |
55 final bool emitSourceMaps; | 55 final bool emitSourceMaps; |
56 | 56 |
57 /// Whether to force compilation of code with static errors. | 57 /// Whether to force compilation of code with static errors. |
58 final bool forceCompile; | 58 final bool forceCompile; |
59 | 59 |
60 /// Output directory for generated code. | 60 /// Output directory for generated code. |
61 final String outputDir; | 61 final String outputDir; |
62 | 62 |
63 const CodegenOptions( | 63 /// Whether to emit a workaround for missing arrow function bind-this in |
64 {this.emitSourceMaps: true, this.forceCompile: false, this.outputDir}); | 64 /// other V8 builds |
| 65 final bool arrowFnBindThisWorkaround; |
| 66 |
| 67 const CodegenOptions({this.emitSourceMaps: true, this.forceCompile: false, |
| 68 this.outputDir, this.arrowFnBindThisWorkaround: false}); |
65 } | 69 } |
66 | 70 |
67 /// General options used by the dev compiler and server. | 71 /// General options used by the dev compiler and server. |
68 class CompilerOptions { | 72 class CompilerOptions { |
69 final StrongModeOptions strongOptions; | 73 final StrongModeOptions strongOptions; |
70 final SourceResolverOptions sourceOptions; | 74 final SourceResolverOptions sourceOptions; |
71 final CodegenOptions codegenOptions; | 75 final CodegenOptions codegenOptions; |
72 | 76 |
73 /// Whether to check the sdk libraries. | 77 /// Whether to check the sdk libraries. |
74 final bool checkSdk; | 78 final bool checkSdk; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 172 } |
169 customUrlMappings[splitMapping[0]] = splitMapping[1]; | 173 customUrlMappings[splitMapping[0]] = splitMapping[1]; |
170 } | 174 } |
171 | 175 |
172 if (serverMode && args.rest.length != 1) showUsage = true; | 176 if (serverMode && args.rest.length != 1) showUsage = true; |
173 | 177 |
174 return new CompilerOptions( | 178 return new CompilerOptions( |
175 codegenOptions: new CodegenOptions( | 179 codegenOptions: new CodegenOptions( |
176 emitSourceMaps: args['source-maps'], | 180 emitSourceMaps: args['source-maps'], |
177 forceCompile: args['force-compile'] || serverMode, | 181 forceCompile: args['force-compile'] || serverMode, |
178 outputDir: outputDir), | 182 outputDir: outputDir, |
| 183 arrowFnBindThisWorkaround: args['arrow-fn-bind-this']), |
179 sourceOptions: new SourceResolverOptions( | 184 sourceOptions: new SourceResolverOptions( |
180 useMockSdk: args['mock-sdk'], | 185 useMockSdk: args['mock-sdk'], |
181 dartSdkPath: sdkPath, | 186 dartSdkPath: sdkPath, |
182 useImplicitHtml: serverMode && | 187 useImplicitHtml: serverMode && |
183 args.rest.length == 1 && | 188 args.rest.length == 1 && |
184 args.rest[0].endsWith('.dart'), | 189 args.rest[0].endsWith('.dart'), |
185 customUrlMappings: customUrlMappings, | 190 customUrlMappings: customUrlMappings, |
186 useMultiPackage: args['use-multi-package'], | 191 useMultiPackage: args['use-multi-package'], |
187 packageRoot: args['package-root'], | 192 packageRoot: args['package-root'], |
188 packagePaths: args['package-paths'].split(','), | 193 packagePaths: args['package-paths'].split(','), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 defaultsTo: false) | 235 defaultsTo: false) |
231 ..addOption('package-paths', | 236 ..addOption('package-paths', |
232 help: 'if using the multi-package resolver, the list of directories to\n' | 237 help: 'if using the multi-package resolver, the list of directories to\n' |
233 'look for packages in.', defaultsTo: '') | 238 'look for packages in.', defaultsTo: '') |
234 ..addOption('resources', | 239 ..addOption('resources', |
235 help: 'Additional resources to serve', defaultsTo: '') | 240 help: 'Additional resources to serve', defaultsTo: '') |
236 ..addFlag('source-maps', | 241 ..addFlag('source-maps', |
237 help: 'Whether to emit source map files', defaultsTo: true) | 242 help: 'Whether to emit source map files', defaultsTo: true) |
238 ..addOption('runtime-dir', | 243 ..addOption('runtime-dir', |
239 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) | 244 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) |
| 245 ..addFlag('arrow-fn-bind-this', |
| 246 help: 'Work around `this` binding in => functions') |
240 | 247 |
241 // general options | 248 // general options |
242 ..addFlag('help', abbr: 'h', help: 'Display this message') | 249 ..addFlag('help', abbr: 'h', help: 'Display this message') |
243 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) | 250 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) |
244 ..addFlag('hashing', | 251 ..addFlag('hashing', |
245 help: 'Enable hash-based file caching.', defaultsTo: null) | 252 help: 'Enable hash-based file caching.', defaultsTo: null) |
246 ..addFlag('widget', | 253 ..addFlag('widget', |
247 help: 'Serve embedded widget with static errors and warnings.', | 254 help: 'Serve embedded widget with static errors and warnings.', |
248 defaultsTo: true) | 255 defaultsTo: true) |
249 ..addOption('host', | 256 ..addOption('host', |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // The pub-cache directory is two levels up, but we verify that the layout | 313 // The pub-cache directory is two levels up, but we verify that the layout |
307 // looks correct. | 314 // looks correct. |
308 if (path.basename(dir) != 'dev_compiler') return null; | 315 if (path.basename(dir) != 'dev_compiler') return null; |
309 dir = path.dirname(dir); | 316 dir = path.dirname(dir); |
310 if (path.basename(dir) != 'global_packages') return null; | 317 if (path.basename(dir) != 'global_packages') return null; |
311 dir = path.dirname(dir); | 318 dir = path.dirname(dir); |
312 return path.join(dir, cacheDir, 'lib', 'runtime'); | 319 return path.join(dir, cacheDir, 'lib', 'runtime'); |
313 } | 320 } |
314 return null; | 321 return null; |
315 } | 322 } |
OLD | NEW |