Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: lib/src/options.dart

Issue 1007703004: Change defaults in server mode (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault, 211 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault,
212 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, 212 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false,
213 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, 213 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE,
214 this.emitSourceMaps: true, this.entryPointFile: null, 214 this.emitSourceMaps: true, this.entryPointFile: null,
215 this.serverMode: false, this.port: 8080, this.runtimeDir}); 215 this.serverMode: false, this.port: 8080, this.runtimeDir});
216 } 216 }
217 217
218 /// Parses options from the command-line 218 /// Parses options from the command-line
219 CompilerOptions parseOptions(List<String> argv) { 219 CompilerOptions parseOptions(List<String> argv) {
220 ArgResults args = argParser.parse(argv); 220 ArgResults args = argParser.parse(argv);
221 var levelName = args['log'].toUpperCase(); 221 var serverMode = args['server'];
222 var logLevel = serverMode ? Level.ALL : Level.SEVERE;
223 var levelName = args['log'];
224 if (levelName != null) {
225 levelName = levelName.toUpperCase();
226 logLevel = Level.LEVELS.firstWhere((l) => l.name == levelName,
227 orElse: () => logLevel);
228 }
222 var useColors = stdioType(stdout) == StdioType.TERMINAL; 229 var useColors = stdioType(stdout) == StdioType.TERMINAL;
223 var sdkPath = args['dart-sdk']; 230 var sdkPath = args['dart-sdk'];
224 if (sdkPath == null && !args['mock-sdk']) { 231 if (sdkPath == null && !args['mock-sdk']) {
225 sdkPath = getSdkDir(argv).path; 232 sdkPath = getSdkDir(argv).path;
226 } 233 }
227 var runtimeDir = args['runtime-dir']; 234 var runtimeDir = args['runtime-dir'];
228 if (runtimeDir == null) { 235 if (runtimeDir == null) {
229 runtimeDir = _computeRuntimeDir(); 236 runtimeDir = _computeRuntimeDir();
230 } 237 }
238 var outputDir = args['out'];
239 if (outputDir == null && serverMode) {
240 outputDir = Directory.systemTemp.createTempSync("dev_compiler_out_").path;
241 }
242 var dumpInfo = args['dump-info'];
243 if (dumpInfo == null) dumpInfo = serverMode;
244
231 return new CompilerOptions( 245 return new CompilerOptions(
232 allowConstCasts: args['allow-const-casts'], 246 allowConstCasts: args['allow-const-casts'],
233 checkSdk: args['sdk-check'], 247 checkSdk: args['sdk-check'],
234 dumpInfo: args['dump-info'], 248 dumpInfo: dumpInfo,
235 dumpInfoFile: args['dump-info-file'], 249 dumpInfoFile: args['dump-info-file'],
236 dumpSrcDir: args['dump-src-to'], 250 dumpSrcDir: args['dump-src-to'],
237 forceCompile: args['force-compile'], 251 forceCompile: args['force-compile'] || serverMode,
238 formatOutput: args['dart-gen-fmt'], 252 formatOutput: args['dart-gen-fmt'],
239 ignoreTypes: args['ignore-types'], 253 ignoreTypes: args['ignore-types'],
240 outputDart: args['dart-gen'], 254 outputDart: args['dart-gen'],
241 outputDir: args['out'], 255 outputDir: outputDir,
242 covariantGenerics: args['covariant-generics'], 256 covariantGenerics: args['covariant-generics'],
243 relaxedCasts: args['relaxed-casts'], 257 relaxedCasts: args['relaxed-casts'],
244 useColors: useColors, 258 useColors: useColors,
245 useMultiPackage: args['use-multi-package'], 259 useMultiPackage: args['use-multi-package'],
246 packageRoot: args['package-root'], 260 packageRoot: args['package-root'],
247 packagePaths: args['package-paths'].split(','), 261 packagePaths: args['package-paths'].split(','),
248 inferFromOverrides: args['infer-from-overrides'], 262 inferFromOverrides: args['infer-from-overrides'],
249 inferTransitively: args['infer-transitively'], 263 inferTransitively: args['infer-transitively'],
250 onlyInferConstsAndFinalFields: args['infer-only-finals'], 264 onlyInferConstsAndFinalFields: args['infer-only-finals'],
251 nonnullableTypes: optionsToList(args['nonnullable'], 265 nonnullableTypes: optionsToList(args['nonnullable'],
252 defaultValue: TypeOptions.NONNULLABLE_TYPES), 266 defaultValue: TypeOptions.NONNULLABLE_TYPES),
253 help: args['help'], 267 help: args['help'],
254 useMockSdk: args['mock-sdk'], 268 useMockSdk: args['mock-sdk'],
255 dartSdkPath: sdkPath, 269 dartSdkPath: sdkPath,
256 logLevel: Level.LEVELS.firstWhere((Level l) => l.name == levelName, 270 logLevel: logLevel,
257 orElse: () => Level.SEVERE),
258 emitSourceMaps: args['source-maps'], 271 emitSourceMaps: args['source-maps'],
259 entryPointFile: args.rest.length == 0 ? null : args.rest.first, 272 entryPointFile: args.rest.length == 0 ? null : args.rest.first,
260 serverMode: args['server'], 273 serverMode: serverMode,
261 port: int.parse(args['port']), 274 port: int.parse(args['port']),
262 runtimeDir: runtimeDir); 275 runtimeDir: runtimeDir);
263 } 276 }
264 277
265 final ArgParser argParser = new ArgParser() 278 final ArgParser argParser = new ArgParser()
266 // resolver/checker options 279 // resolver/checker options
267 ..addFlag('allow-const-casts', 280 ..addFlag('allow-const-casts',
268 help: 'Allow casts in const contexts', defaultsTo: true) 281 help: 'Allow casts in const contexts', defaultsTo: true)
269 ..addFlag('sdk-check', 282 ..addFlag('sdk-check',
270 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) 283 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) 327 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null)
315 328
316 // general options 329 // general options
317 ..addFlag('help', abbr: 'h', help: 'Display this message') 330 ..addFlag('help', abbr: 'h', help: 'Display this message')
318 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) 331 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false)
319 ..addOption('port', 332 ..addOption('port',
320 help: 'Port where to serve files from (used only when --serve is on)', 333 help: 'Port where to serve files from (used only when --serve is on)',
321 defaultsTo: '8080') 334 defaultsTo: '8080')
322 ..addFlag('force-compile', 335 ..addFlag('force-compile',
323 help: 'Compile code with static errors', defaultsTo: false) 336 help: 'Compile code with static errors', defaultsTo: false)
324 ..addOption('log', abbr: 'l', help: 'Logging level', defaultsTo: 'severe') 337 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to severe)')
325 ..addFlag('dump-info', 338 ..addFlag('dump-info',
326 abbr: 'i', help: 'Dump summary information', defaultsTo: false) 339 abbr: 'i', help: 'Dump summary information', defaultsTo: null)
327 ..addOption('dump-info-file', 340 ..addOption('dump-info-file',
328 abbr: 'f', 341 abbr: 'f',
329 help: 'Dump info json file (requires dump-info)', 342 help: 'Dump info json file (requires dump-info)',
330 defaultsTo: null); 343 defaultsTo: null);
331 344
332 /// Tries to find the `lib/runtime/` directory of the dev_compiler package. This 345 /// Tries to find the `lib/runtime/` directory of the dev_compiler package. This
333 /// works when running devc from it's sources or from a snapshot that is 346 /// works when running devc from it's sources or from a snapshot that is
334 /// activated via `pub global activate`. 347 /// activated via `pub global activate`.
335 String _computeRuntimeDir() { 348 String _computeRuntimeDir() {
336 var scriptUri = Platform.script; 349 var scriptUri = Platform.script;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // The pub-cache directory is two levels up, but we verify that the layout 385 // The pub-cache directory is two levels up, but we verify that the layout
373 // looks correct. 386 // looks correct.
374 if (path.basename(dir) != 'dev_compiler') return null; 387 if (path.basename(dir) != 'dev_compiler') return null;
375 dir = path.dirname(dir); 388 dir = path.dirname(dir);
376 if (path.basename(dir) != 'global_packages') return null; 389 if (path.basename(dir) != 'global_packages') return null;
377 dir = path.dirname(dir); 390 dir = path.dirname(dir);
378 return path.join(dir, cacheDir, 'lib', 'runtime'); 391 return path.join(dir, cacheDir, 'lib', 'runtime');
379 } 392 }
380 return null; 393 return null;
381 } 394 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698