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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 {this.strongOptions: const StrongModeOptions(), | 152 {this.strongOptions: const StrongModeOptions(), |
153 this.sourceOptions: const SourceResolverOptions(), | 153 this.sourceOptions: const SourceResolverOptions(), |
154 this.codegenOptions: const CodegenOptions(), | 154 this.codegenOptions: const CodegenOptions(), |
155 this.runnerOptions: const RunnerOptions(), | 155 this.runnerOptions: const RunnerOptions(), |
156 this.checkSdk: false, | 156 this.checkSdk: false, |
157 this.dumpInfo: false, | 157 this.dumpInfo: false, |
158 this.dumpInfoFile, | 158 this.dumpInfoFile, |
159 this.useColors: true, | 159 this.useColors: true, |
160 this.help: false, | 160 this.help: false, |
161 this.version: false, | 161 this.version: false, |
162 this.logLevel: Level.SEVERE, | 162 this.logLevel: Level.WARNING, |
163 this.serverMode: false, | 163 this.serverMode: false, |
164 this.enableHashing: false, | 164 this.enableHashing: false, |
165 this.widget: true, | 165 this.widget: true, |
166 this.host: 'localhost', | 166 this.host: 'localhost', |
167 this.port: 8080, | 167 this.port: 8080, |
168 this.runtimeDir, | 168 this.runtimeDir, |
169 this.inputs, | 169 this.inputs, |
170 this.inputBaseDir}); | 170 this.inputBaseDir}); |
171 } | 171 } |
172 | 172 |
173 /// Parses options from the command-line | 173 /// Parses options from the command-line |
174 CompilerOptions parseOptions(List<String> argv, {bool forceOutDir: false}) { | 174 CompilerOptions parseOptions(List<String> argv, {bool forceOutDir: false}) { |
175 ArgResults args = argParser.parse(argv); | 175 ArgResults args = argParser.parse(argv); |
176 bool showUsage = args['help']; | 176 bool showUsage = args['help']; |
177 bool showVersion = args['version']; | 177 bool showVersion = args['version']; |
178 | 178 |
179 var serverMode = args['server']; | 179 var serverMode = args['server']; |
180 var enableHashing = args['hashing']; | 180 var enableHashing = args['hashing']; |
181 if (enableHashing == null) { | 181 if (enableHashing == null) { |
182 enableHashing = serverMode; | 182 enableHashing = serverMode; |
183 } | 183 } |
184 // TODO(jmesserly): shouldn't level always default to warning? | 184 var logLevel = Level.WARNING; |
185 var logLevel = serverMode ? Level.WARNING : Level.SEVERE; | |
186 var levelName = args['log']; | 185 var levelName = args['log']; |
187 if (levelName != null) { | 186 if (levelName != null) { |
188 levelName = levelName.toUpperCase(); | 187 levelName = levelName.toUpperCase(); |
189 logLevel = Level.LEVELS | 188 logLevel = Level.LEVELS |
190 .firstWhere((l) => l.name == levelName, orElse: () => logLevel); | 189 .firstWhere((l) => l.name == levelName, orElse: () => logLevel); |
191 } | 190 } |
192 var useColors = stdioType(stdout) == StdioType.TERMINAL; | 191 var useColors = stdioType(stdout) == StdioType.TERMINAL; |
193 var sdkPath = args['dart-sdk']; | 192 var sdkPath = args['dart-sdk']; |
194 if (sdkPath == null && !args['mock-sdk']) { | 193 if (sdkPath == null && !args['mock-sdk']) { |
195 sdkPath = getSdkDir(argv).path; | 194 sdkPath = getSdkDir(argv).path; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 'to listen on all interfaces (used only when --serve is on)', | 305 'to listen on all interfaces (used only when --serve is on)', |
307 defaultsTo: 'localhost') | 306 defaultsTo: 'localhost') |
308 ..addOption('port', | 307 ..addOption('port', |
309 help: 'Port to serve files from (used only when --serve is on)', | 308 help: 'Port to serve files from (used only when --serve is on)', |
310 defaultsTo: '8080') | 309 defaultsTo: '8080') |
311 ..addFlag('closure', | 310 ..addFlag('closure', |
312 help: 'Emit Closure Compiler-friendly code (experimental)', | 311 help: 'Emit Closure Compiler-friendly code (experimental)', |
313 defaultsTo: _CLOSURE_DEFAULT) | 312 defaultsTo: _CLOSURE_DEFAULT) |
314 ..addFlag('force-compile', | 313 ..addFlag('force-compile', |
315 help: 'Compile code with static errors', defaultsTo: false) | 314 help: 'Compile code with static errors', defaultsTo: false) |
316 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to severe)') | 315 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to warning)') |
317 ..addFlag('dump-info', | 316 ..addFlag('dump-info', |
318 abbr: 'i', help: 'Dump summary information', defaultsTo: null) | 317 abbr: 'i', help: 'Dump summary information', defaultsTo: null) |
319 ..addOption('v8-binary', | 318 ..addOption('v8-binary', |
320 help: 'V8-based binary to run JavaScript output with (iojs, node, d8)', | 319 help: 'V8-based binary to run JavaScript output with (iojs, node, d8)', |
321 defaultsTo: 'iojs') | 320 defaultsTo: 'iojs') |
322 ..addOption('dump-info-file', | 321 ..addOption('dump-info-file', |
323 abbr: 'f', | 322 abbr: 'f', |
324 help: 'Dump info json file (requires dump-info)', | 323 help: 'Dump info json file (requires dump-info)', |
325 defaultsTo: null)); | 324 defaultsTo: null)); |
326 | 325 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // The pub-cache directory is two levels up, but we verify that the layout | 372 // The pub-cache directory is two levels up, but we verify that the layout |
374 // looks correct. | 373 // looks correct. |
375 if (path.basename(dir) != 'dev_compiler') return null; | 374 if (path.basename(dir) != 'dev_compiler') return null; |
376 dir = path.dirname(dir); | 375 dir = path.dirname(dir); |
377 if (path.basename(dir) != 'global_packages') return null; | 376 if (path.basename(dir) != 'global_packages') return null; |
378 dir = path.dirname(dir); | 377 dir = path.dirname(dir); |
379 return path.join(dir, cacheDir, 'lib', 'runtime'); | 378 return path.join(dir, cacheDir, 'lib', 'runtime'); |
380 } | 379 } |
381 return null; | 380 return null; |
382 } | 381 } |
OLD | NEW |