Skip to content

Commit

Permalink
Add flag to disable hashing
Browse files Browse the repository at this point in the history
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1088703003
  • Loading branch information
vsmenon committed Apr 21, 2015
1 parent cafe427 commit b5e4a91
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/devc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Compiler {
return new Compiler._(options, resolver, reporter, rules, checker, graph,
entryNode, generators,
// TODO(sigmund): refactor to support hashing of the dart output?
options.serverMode && generators.length == 1 && !options.outputDart);
options.enableHashing && generators.length == 1 && !options.outputDart);
}

Compiler._(this._options, this._resolver, this._reporter, this._rules,
Expand Down
14 changes: 12 additions & 2 deletions pkg/dev_compiler/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class CompilerOptions implements RulesOptions, ResolverOptions, JSCodeOptions {
/// Whether to run as a development server.
final bool serverMode;

/// Whether to enable hash-based caching of files.
final bool enableHashing;

/// Port used for the HTTP server when [serverMode] is on.
final int port;

Expand Down Expand Up @@ -232,14 +235,18 @@ class CompilerOptions implements RulesOptions, ResolverOptions, JSCodeOptions {
this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false,
this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE,
this.emitSourceMaps: true, this.entryPointFile: null,
this.serverMode: false, this.host: 'localhost', this.port: 8080,
this.runtimeDir});
this.serverMode: false, this.enableHashing: false, this.host: 'localhost',
this.port: 8080, this.runtimeDir});
}

/// Parses options from the command-line
CompilerOptions parseOptions(List<String> argv) {
ArgResults args = argParser.parse(argv);
var serverMode = args['server'];
var enableHashing = args['hashing'];
if (enableHashing == null) {
enableHashing = serverMode;
}
var logLevel = serverMode ? Level.ALL : Level.SEVERE;
var levelName = args['log'];
if (levelName != null) {
Expand Down Expand Up @@ -294,6 +301,7 @@ CompilerOptions parseOptions(List<String> argv) {
emitSourceMaps: args['source-maps'],
entryPointFile: args.rest.length == 0 ? null : args.rest.first,
serverMode: serverMode,
enableHashing: enableHashing,
host: args['host'],
port: int.parse(args['port']),
runtimeDir: runtimeDir);
Expand Down Expand Up @@ -360,6 +368,8 @@ final ArgParser argParser = new ArgParser()
// general options
..addFlag('help', abbr: 'h', help: 'Display this message')
..addFlag('server', help: 'Run as a development server.', defaultsTo: false)
..addFlag('hashing',
help: 'Enable hash-based file caching.', defaultsTo: null)
..addOption('host',
help: 'Host name or address to serve files from, e.g. --host=0.0.0.0\n'
'to listen on all interfaces (used only when --serve is on)',
Expand Down
3 changes: 2 additions & 1 deletion pkg/dev_compiler/test/codegen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ main(arguments) {
entryPointFile: entryPoint,
dartSdkPath: sdkPath,
runtimeDir: runtimeDir,
serverMode: serverMode);
serverMode: serverMode,
enableHashing: serverMode);
return new Compiler(options).run();
}
var realSdk = getSdkDir(arguments).path;
Expand Down

0 comments on commit b5e4a91

Please sign in to comment.