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

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

Issue 1088703003: Add flag to disable hashing (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 | « lib/devc.dart ('k') | test/codegen_test.dart » ('j') | 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 /// File where to start compilation from. 144 /// File where to start compilation from.
145 final String entryPointFile; 145 final String entryPointFile;
146 146
147 /// Whether to allow casts in constant contexts. 147 /// Whether to allow casts in constant contexts.
148 @override 148 @override
149 final bool allowConstCasts; 149 final bool allowConstCasts;
150 150
151 /// Whether to run as a development server. 151 /// Whether to run as a development server.
152 final bool serverMode; 152 final bool serverMode;
153 153
154 /// Whether to enable hash-based caching of files.
155 final bool enableHashing;
156
154 /// Port used for the HTTP server when [serverMode] is on. 157 /// Port used for the HTTP server when [serverMode] is on.
155 final int port; 158 final int port;
156 159
157 /// Host name or address for HTTP server when [serverMode] is on. 160 /// Host name or address for HTTP server when [serverMode] is on.
158 final String host; 161 final String host;
159 162
160 /// Whether to use covariant generics 163 /// Whether to use covariant generics
161 @override 164 @override
162 final bool covariantGenerics; 165 final bool covariantGenerics;
163 166
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 this.covariantGenerics: true, this.relaxedCasts: true, 228 this.covariantGenerics: true, this.relaxedCasts: true,
226 this.useMultiPackage: false, this.packageRoot: 'packages/', 229 this.useMultiPackage: false, this.packageRoot: 'packages/',
227 this.packagePaths: const <String>[], 230 this.packagePaths: const <String>[],
228 this.inferDownwards: RulesOptions.inferDownwardsDefault, 231 this.inferDownwards: RulesOptions.inferDownwardsDefault,
229 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, 232 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
230 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, 233 this.inferTransitively: ResolverOptions.inferTransitivelyDefault,
231 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault, 234 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault,
232 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, 235 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false,
233 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, 236 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE,
234 this.emitSourceMaps: true, this.entryPointFile: null, 237 this.emitSourceMaps: true, this.entryPointFile: null,
235 this.serverMode: false, this.host: 'localhost', this.port: 8080, 238 this.serverMode: false, this.enableHashing: false, this.host: 'localhost',
236 this.runtimeDir}); 239 this.port: 8080, this.runtimeDir});
237 } 240 }
238 241
239 /// Parses options from the command-line 242 /// Parses options from the command-line
240 CompilerOptions parseOptions(List<String> argv) { 243 CompilerOptions parseOptions(List<String> argv) {
241 ArgResults args = argParser.parse(argv); 244 ArgResults args = argParser.parse(argv);
242 var serverMode = args['server']; 245 var serverMode = args['server'];
246 var enableHashing = args['hashing'];
247 if (enableHashing == null) {
248 enableHashing = serverMode;
249 }
243 var logLevel = serverMode ? Level.ALL : Level.SEVERE; 250 var logLevel = serverMode ? Level.ALL : Level.SEVERE;
244 var levelName = args['log']; 251 var levelName = args['log'];
245 if (levelName != null) { 252 if (levelName != null) {
246 levelName = levelName.toUpperCase(); 253 levelName = levelName.toUpperCase();
247 logLevel = Level.LEVELS.firstWhere((l) => l.name == levelName, 254 logLevel = Level.LEVELS.firstWhere((l) => l.name == levelName,
248 orElse: () => logLevel); 255 orElse: () => logLevel);
249 } 256 }
250 var useColors = stdioType(stdout) == StdioType.TERMINAL; 257 var useColors = stdioType(stdout) == StdioType.TERMINAL;
251 var sdkPath = args['dart-sdk']; 258 var sdkPath = args['dart-sdk'];
252 if (sdkPath == null && !args['mock-sdk']) { 259 if (sdkPath == null && !args['mock-sdk']) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 onlyInferConstsAndFinalFields: args['infer-only-finals'], 294 onlyInferConstsAndFinalFields: args['infer-only-finals'],
288 nonnullableTypes: optionsToList(args['nonnullable'], 295 nonnullableTypes: optionsToList(args['nonnullable'],
289 defaultValue: TypeOptions.NONNULLABLE_TYPES), 296 defaultValue: TypeOptions.NONNULLABLE_TYPES),
290 help: args['help'], 297 help: args['help'],
291 useMockSdk: args['mock-sdk'], 298 useMockSdk: args['mock-sdk'],
292 dartSdkPath: sdkPath, 299 dartSdkPath: sdkPath,
293 logLevel: logLevel, 300 logLevel: logLevel,
294 emitSourceMaps: args['source-maps'], 301 emitSourceMaps: args['source-maps'],
295 entryPointFile: args.rest.length == 0 ? null : args.rest.first, 302 entryPointFile: args.rest.length == 0 ? null : args.rest.first,
296 serverMode: serverMode, 303 serverMode: serverMode,
304 enableHashing: enableHashing,
297 host: args['host'], 305 host: args['host'],
298 port: int.parse(args['port']), 306 port: int.parse(args['port']),
299 runtimeDir: runtimeDir); 307 runtimeDir: runtimeDir);
300 } 308 }
301 309
302 final ArgParser argParser = new ArgParser() 310 final ArgParser argParser = new ArgParser()
303 // resolver/checker options 311 // resolver/checker options
304 ..addFlag('allow-const-casts', 312 ..addFlag('allow-const-casts',
305 help: 'Allow casts in const contexts', defaultsTo: true) 313 help: 'Allow casts in const contexts', defaultsTo: true)
306 ..addFlag('sdk-check', 314 ..addFlag('sdk-check',
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 help: 'if using the multi-package resolver, the list of directories to\n' 361 help: 'if using the multi-package resolver, the list of directories to\n'
354 'look for packages in.', defaultsTo: '') 362 'look for packages in.', defaultsTo: '')
355 ..addFlag('source-maps', 363 ..addFlag('source-maps',
356 help: 'Whether to emit source map files', defaultsTo: true) 364 help: 'Whether to emit source map files', defaultsTo: true)
357 ..addOption('runtime-dir', 365 ..addOption('runtime-dir',
358 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) 366 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null)
359 367
360 // general options 368 // general options
361 ..addFlag('help', abbr: 'h', help: 'Display this message') 369 ..addFlag('help', abbr: 'h', help: 'Display this message')
362 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) 370 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false)
371 ..addFlag('hashing',
372 help: 'Enable hash-based file caching.', defaultsTo: null)
363 ..addOption('host', 373 ..addOption('host',
364 help: 'Host name or address to serve files from, e.g. --host=0.0.0.0\n' 374 help: 'Host name or address to serve files from, e.g. --host=0.0.0.0\n'
365 'to listen on all interfaces (used only when --serve is on)', 375 'to listen on all interfaces (used only when --serve is on)',
366 defaultsTo: 'localhost') 376 defaultsTo: 'localhost')
367 ..addOption('port', 377 ..addOption('port',
368 help: 'Port to serve files from (used only when --serve is on)', 378 help: 'Port to serve files from (used only when --serve is on)',
369 defaultsTo: '8080') 379 defaultsTo: '8080')
370 ..addFlag('force-compile', 380 ..addFlag('force-compile',
371 help: 'Compile code with static errors', defaultsTo: false) 381 help: 'Compile code with static errors', defaultsTo: false)
372 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to severe)') 382 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to severe)')
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // The pub-cache directory is two levels up, but we verify that the layout 430 // The pub-cache directory is two levels up, but we verify that the layout
421 // looks correct. 431 // looks correct.
422 if (path.basename(dir) != 'dev_compiler') return null; 432 if (path.basename(dir) != 'dev_compiler') return null;
423 dir = path.dirname(dir); 433 dir = path.dirname(dir);
424 if (path.basename(dir) != 'global_packages') return null; 434 if (path.basename(dir) != 'global_packages') return null;
425 dir = path.dirname(dir); 435 dir = path.dirname(dir);
426 return path.join(dir, cacheDir, 'lib', 'runtime'); 436 return path.join(dir, cacheDir, 'lib', 'runtime');
427 } 437 }
428 return null; 438 return null;
429 } 439 }
OLDNEW
« no previous file with comments | « lib/devc.dart ('k') | test/codegen_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698