| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 final SourceResolverOptions sourceOptions; | 95 final SourceResolverOptions sourceOptions; |
| 96 final CodegenOptions codegenOptions; | 96 final CodegenOptions codegenOptions; |
| 97 final RunnerOptions runnerOptions; | 97 final RunnerOptions runnerOptions; |
| 98 | 98 |
| 99 /// Whether to check the sdk libraries. | 99 /// Whether to check the sdk libraries. |
| 100 final bool checkSdk; | 100 final bool checkSdk; |
| 101 | 101 |
| 102 /// Whether to dump summary information on the console. | 102 /// Whether to dump summary information on the console. |
| 103 final bool dumpInfo; | 103 final bool dumpInfo; |
| 104 | 104 |
| 105 final bool htmlReport; |
| 106 |
| 105 /// If not null, path to a file that will store a json representation of the | 107 /// If not null, path to a file that will store a json representation of the |
| 106 /// summary information (only used if [dumpInfo] is true). | 108 /// summary information (only used if [dumpInfo] is true). |
| 107 final String dumpInfoFile; | 109 final String dumpInfoFile; |
| 108 | 110 |
| 109 /// Whether to use colors when interacting on the console. | 111 /// Whether to use colors when interacting on the console. |
| 110 final bool useColors; | 112 final bool useColors; |
| 111 | 113 |
| 112 /// Whether the user asked for help. | 114 /// Whether the user asked for help. |
| 113 final bool help; | 115 final bool help; |
| 114 | 116 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 144 /// The base directory for [inputs]. Module imports will be generated relative | 146 /// The base directory for [inputs]. Module imports will be generated relative |
| 145 /// to this directory. | 147 /// to this directory. |
| 146 final String inputBaseDir; | 148 final String inputBaseDir; |
| 147 | 149 |
| 148 CompilerOptions( | 150 CompilerOptions( |
| 149 {this.sourceOptions: const SourceResolverOptions(), | 151 {this.sourceOptions: const SourceResolverOptions(), |
| 150 this.codegenOptions: const CodegenOptions(), | 152 this.codegenOptions: const CodegenOptions(), |
| 151 this.runnerOptions: const RunnerOptions(), | 153 this.runnerOptions: const RunnerOptions(), |
| 152 this.checkSdk: false, | 154 this.checkSdk: false, |
| 153 this.dumpInfo: false, | 155 this.dumpInfo: false, |
| 156 this.htmlReport: false, |
| 154 this.dumpInfoFile, | 157 this.dumpInfoFile, |
| 155 this.useColors: true, | 158 this.useColors: true, |
| 156 this.help: false, | 159 this.help: false, |
| 157 this.version: false, | 160 this.version: false, |
| 158 this.logLevel: Level.WARNING, | 161 this.logLevel: Level.WARNING, |
| 159 this.serverMode: false, | 162 this.serverMode: false, |
| 160 this.enableHashing: false, | 163 this.enableHashing: false, |
| 161 this.widget: true, | 164 this.widget: true, |
| 162 this.host: 'localhost', | 165 this.host: 'localhost', |
| 163 this.port: 8080, | 166 this.port: 8080, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 193 if (runtimeDir == null) { | 196 if (runtimeDir == null) { |
| 194 runtimeDir = _computeRuntimeDir(); | 197 runtimeDir = _computeRuntimeDir(); |
| 195 } | 198 } |
| 196 var outputDir = args['out']; | 199 var outputDir = args['out']; |
| 197 if (outputDir == null && (serverMode || forceOutDir)) { | 200 if (outputDir == null && (serverMode || forceOutDir)) { |
| 198 outputDir = Directory.systemTemp.createTempSync("dev_compiler_out_").path; | 201 outputDir = Directory.systemTemp.createTempSync("dev_compiler_out_").path; |
| 199 } | 202 } |
| 200 var dumpInfo = args['dump-info']; | 203 var dumpInfo = args['dump-info']; |
| 201 if (dumpInfo == null) dumpInfo = serverMode; | 204 if (dumpInfo == null) dumpInfo = serverMode; |
| 202 | 205 |
| 206 var htmlReport = args['html-report']; |
| 207 |
| 203 var v8Binary = args['v8-binary']; | 208 var v8Binary = args['v8-binary']; |
| 204 if (v8Binary == null) v8Binary = 'iojs'; | 209 if (v8Binary == null) v8Binary = 'iojs'; |
| 205 | 210 |
| 206 var customUrlMappings = <String, String>{}; | 211 var customUrlMappings = <String, String>{}; |
| 207 for (var mapping in args['url-mapping']) { | 212 for (var mapping in args['url-mapping']) { |
| 208 var splitMapping = mapping.split(','); | 213 var splitMapping = mapping.split(','); |
| 209 if (splitMapping.length != 2) { | 214 if (splitMapping.length != 2) { |
| 210 showUsage = true; | 215 showUsage = true; |
| 211 continue; | 216 continue; |
| 212 } | 217 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 230 args.rest[0].endsWith('.dart'), | 235 args.rest[0].endsWith('.dart'), |
| 231 customUrlMappings: customUrlMappings, | 236 customUrlMappings: customUrlMappings, |
| 232 useMultiPackage: args['use-multi-package'], | 237 useMultiPackage: args['use-multi-package'], |
| 233 packageRoot: args['package-root'], | 238 packageRoot: args['package-root'], |
| 234 packagePaths: args['package-paths'].split(','), | 239 packagePaths: args['package-paths'].split(','), |
| 235 resources: | 240 resources: |
| 236 args['resources'].split(',').where((s) => s.isNotEmpty).toList()), | 241 args['resources'].split(',').where((s) => s.isNotEmpty).toList()), |
| 237 runnerOptions: new RunnerOptions(v8Binary: v8Binary), | 242 runnerOptions: new RunnerOptions(v8Binary: v8Binary), |
| 238 checkSdk: args['sdk-check'], | 243 checkSdk: args['sdk-check'], |
| 239 dumpInfo: dumpInfo, | 244 dumpInfo: dumpInfo, |
| 245 htmlReport: htmlReport, |
| 240 dumpInfoFile: args['dump-info-file'], | 246 dumpInfoFile: args['dump-info-file'], |
| 241 useColors: useColors, | 247 useColors: useColors, |
| 242 help: showUsage, | 248 help: showUsage, |
| 243 version: showVersion, | 249 version: showVersion, |
| 244 logLevel: logLevel, | 250 logLevel: logLevel, |
| 245 serverMode: serverMode, | 251 serverMode: serverMode, |
| 246 enableHashing: enableHashing, | 252 enableHashing: enableHashing, |
| 247 widget: args['widget'], | 253 widget: args['widget'], |
| 248 host: args['host'], | 254 host: args['host'], |
| 249 port: int.parse(args['port']), | 255 port: int.parse(args['port']), |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 help: 'Port to serve files from (used only when --serve is on)', | 310 help: 'Port to serve files from (used only when --serve is on)', |
| 305 defaultsTo: '8080') | 311 defaultsTo: '8080') |
| 306 ..addFlag('closure', | 312 ..addFlag('closure', |
| 307 help: 'Emit Closure Compiler-friendly code (experimental)', | 313 help: 'Emit Closure Compiler-friendly code (experimental)', |
| 308 defaultsTo: _CLOSURE_DEFAULT) | 314 defaultsTo: _CLOSURE_DEFAULT) |
| 309 ..addFlag('force-compile', | 315 ..addFlag('force-compile', |
| 310 help: 'Compile code with static errors', defaultsTo: false) | 316 help: 'Compile code with static errors', defaultsTo: false) |
| 311 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to warning)') | 317 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to warning)') |
| 312 ..addFlag('dump-info', | 318 ..addFlag('dump-info', |
| 313 abbr: 'i', help: 'Dump summary information', defaultsTo: null) | 319 abbr: 'i', help: 'Dump summary information', defaultsTo: null) |
| 320 ..addFlag('html-report', |
| 321 help: 'Output compilation results to html', defaultsTo: null) |
| 314 ..addOption('v8-binary', | 322 ..addOption('v8-binary', |
| 315 help: 'V8-based binary to run JavaScript output with (iojs, node, d8)', | 323 help: 'V8-based binary to run JavaScript output with (iojs, node, d8)', |
| 316 defaultsTo: 'iojs') | 324 defaultsTo: 'iojs') |
| 317 ..addOption('dump-info-file', | 325 ..addOption('dump-info-file', |
| 318 abbr: 'f', | 326 abbr: 'f', |
| 319 help: 'Dump info json file (requires dump-info)', | 327 help: 'Dump info json file (requires dump-info)', |
| 320 defaultsTo: null); | 328 defaultsTo: null); |
| 321 | 329 |
| 322 // TODO: Switch over to the `pub_cache` package (or the Resource API)? | 330 // TODO: Switch over to the `pub_cache` package (or the Resource API)? |
| 323 | 331 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 // The pub-cache directory is two levels up, but we verify that the layout | 376 // The pub-cache directory is two levels up, but we verify that the layout |
| 369 // looks correct. | 377 // looks correct. |
| 370 if (path.basename(dir) != 'dev_compiler') return null; | 378 if (path.basename(dir) != 'dev_compiler') return null; |
| 371 dir = path.dirname(dir); | 379 dir = path.dirname(dir); |
| 372 if (path.basename(dir) != 'global_packages') return null; | 380 if (path.basename(dir) != 'global_packages') return null; |
| 373 dir = path.dirname(dir); | 381 dir = path.dirname(dir); |
| 374 return path.join(dir, cacheDir, 'lib', 'runtime'); | 382 return path.join(dir, cacheDir, 'lib', 'runtime'); |
| 375 } | 383 } |
| 376 return null; | 384 return null; |
| 377 } | 385 } |
| OLD | NEW |