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

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

Issue 1022923005: bind to localhost instead of all interfaces, and fix closureWrap (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 | « lib/runtime/dart_runtime.js ('k') | test/codegen/expect/server_mode/html_input.html » ('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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 /// Whether to allow casts in constant contexts. 140 /// Whether to allow casts in constant contexts.
141 @override 141 @override
142 final bool allowConstCasts; 142 final bool allowConstCasts;
143 143
144 /// Whether to run as a development server. 144 /// Whether to run as a development server.
145 final bool serverMode; 145 final bool serverMode;
146 146
147 /// Port used for the HTTP server when [serverMode] is on. 147 /// Port used for the HTTP server when [serverMode] is on.
148 final int port; 148 final int port;
149 149
150 /// Host name or address for HTTP server when [serverMode] is on.
151 final String host;
152
150 /// Whether to use covariant generics 153 /// Whether to use covariant generics
151 @override 154 @override
152 final bool covariantGenerics; 155 final bool covariantGenerics;
153 156
154 /// Whether to inject casts between Dart assignable types. 157 /// Whether to inject casts between Dart assignable types.
155 @override 158 @override
156 final bool relaxedCasts; 159 final bool relaxedCasts;
157 160
158 /// Whether to resolve 'package:' uris using the multi-package resolver. 161 /// Whether to resolve 'package:' uris using the multi-package resolver.
159 @override 162 @override
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 this.outputDart: false, this.useColors: true, 208 this.outputDart: false, this.useColors: true,
206 this.covariantGenerics: true, this.relaxedCasts: true, 209 this.covariantGenerics: true, this.relaxedCasts: true,
207 this.useMultiPackage: false, this.packageRoot: 'packages/', 210 this.useMultiPackage: false, this.packageRoot: 'packages/',
208 this.packagePaths: const <String>[], 211 this.packagePaths: const <String>[],
209 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, 212 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
210 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, 213 this.inferTransitively: ResolverOptions.inferTransitivelyDefault,
211 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault, 214 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault,
212 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, 215 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false,
213 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, 216 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE,
214 this.emitSourceMaps: true, this.entryPointFile: null, 217 this.emitSourceMaps: true, this.entryPointFile: null,
215 this.serverMode: false, this.port: 8080, this.runtimeDir}); 218 this.serverMode: false, this.host: 'localhost', this.port: 8080,
219 this.runtimeDir});
216 } 220 }
217 221
218 /// Parses options from the command-line 222 /// Parses options from the command-line
219 CompilerOptions parseOptions(List<String> argv) { 223 CompilerOptions parseOptions(List<String> argv) {
220 ArgResults args = argParser.parse(argv); 224 ArgResults args = argParser.parse(argv);
221 var serverMode = args['server']; 225 var serverMode = args['server'];
222 var logLevel = serverMode ? Level.ALL : Level.SEVERE; 226 var logLevel = serverMode ? Level.ALL : Level.SEVERE;
223 var levelName = args['log']; 227 var levelName = args['log'];
224 if (levelName != null) { 228 if (levelName != null) {
225 levelName = levelName.toUpperCase(); 229 levelName = levelName.toUpperCase();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 onlyInferConstsAndFinalFields: args['infer-only-finals'], 268 onlyInferConstsAndFinalFields: args['infer-only-finals'],
265 nonnullableTypes: optionsToList(args['nonnullable'], 269 nonnullableTypes: optionsToList(args['nonnullable'],
266 defaultValue: TypeOptions.NONNULLABLE_TYPES), 270 defaultValue: TypeOptions.NONNULLABLE_TYPES),
267 help: args['help'], 271 help: args['help'],
268 useMockSdk: args['mock-sdk'], 272 useMockSdk: args['mock-sdk'],
269 dartSdkPath: sdkPath, 273 dartSdkPath: sdkPath,
270 logLevel: logLevel, 274 logLevel: logLevel,
271 emitSourceMaps: args['source-maps'], 275 emitSourceMaps: args['source-maps'],
272 entryPointFile: args.rest.length == 0 ? null : args.rest.first, 276 entryPointFile: args.rest.length == 0 ? null : args.rest.first,
273 serverMode: serverMode, 277 serverMode: serverMode,
278 host: args['host'],
274 port: int.parse(args['port']), 279 port: int.parse(args['port']),
275 runtimeDir: runtimeDir); 280 runtimeDir: runtimeDir);
276 } 281 }
277 282
278 final ArgParser argParser = new ArgParser() 283 final ArgParser argParser = new ArgParser()
279 // resolver/checker options 284 // resolver/checker options
280 ..addFlag('allow-const-casts', 285 ..addFlag('allow-const-casts',
281 help: 'Allow casts in const contexts', defaultsTo: true) 286 help: 'Allow casts in const contexts', defaultsTo: true)
282 ..addFlag('sdk-check', 287 ..addFlag('sdk-check',
283 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) 288 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false)
284 ..addFlag('mock-sdk', 289 ..addFlag('mock-sdk',
285 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false) 290 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false)
286 ..addFlag('covariant-generics', 291 ..addFlag('covariant-generics',
287 help: 'Use covariant generics', defaultsTo: true) 292 help: 'Use covariant generics', defaultsTo: true)
288 ..addFlag('ignore-types', 293 ..addFlag('ignore-types',
289 help: 'Ignore types during codegen', defaultsTo: false) 294 help: 'Ignore types during codegen', defaultsTo: false)
290 ..addFlag('relaxed-casts', 295 ..addFlag('relaxed-casts',
291 help: 'Cast between Dart assignable types', defaultsTo: true) 296 help: 'Cast between Dart assignable types', defaultsTo: true)
292 ..addOption('nonnullable', 297 ..addOption('nonnullable',
293 abbr: 'n', 298 abbr: 'n',
294 help: 'Comma separated string of non-nullable types', 299 help: 'Comma separated string of non-nullable types',
295 defaultsTo: null) 300 defaultsTo: null)
296 ..addFlag('infer-from-overrides', 301 ..addFlag('infer-from-overrides',
297 help: 'Infer unspecified types of fields and return types from ' 302 help: 'Infer unspecified types of fields and return types from\n'
298 'definitions in supertypes', 303 'definitions in supertypes',
299 defaultsTo: ResolverOptions.inferFromOverridesDefault) 304 defaultsTo: ResolverOptions.inferFromOverridesDefault)
300 ..addFlag('infer-transitively', 305 ..addFlag('infer-transitively',
301 help: 'Infer consts/fields from definitions in other libraries', 306 help: 'Infer consts/fields from definitions in other libraries',
302 defaultsTo: ResolverOptions.inferTransitivelyDefault) 307 defaultsTo: ResolverOptions.inferTransitivelyDefault)
303 ..addFlag('infer-only-finals', 308 ..addFlag('infer-only-finals',
304 help: 'Do not infer non-const or non-final fields', 309 help: 'Do not infer non-const or non-final fields',
305 defaultsTo: ResolverOptions.onlyInferConstAndFinalFieldsDefault) 310 defaultsTo: ResolverOptions.onlyInferConstAndFinalFieldsDefault)
306 311
307 // input/output options 312 // input/output options
308 ..addOption('out', abbr: 'o', help: 'Output directory', defaultsTo: null) 313 ..addOption('out', abbr: 'o', help: 'Output directory', defaultsTo: null)
309 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null) 314 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null)
310 ..addFlag('dart-gen', 315 ..addFlag('dart-gen',
311 abbr: 'd', help: 'Generate dart output', defaultsTo: false) 316 abbr: 'd', help: 'Generate dart output', defaultsTo: false)
312 ..addFlag('dart-gen-fmt', 317 ..addFlag('dart-gen-fmt',
313 help: 'Generate readable dart output', defaultsTo: true) 318 help: 'Generate readable dart output', defaultsTo: true)
314 ..addOption('dump-src-to', help: 'Dump dart src code', defaultsTo: null) 319 ..addOption('dump-src-to', help: 'Dump dart src code', defaultsTo: null)
315 ..addOption('package-root', 320 ..addOption('package-root',
316 abbr: 'p', 321 abbr: 'p',
317 help: 'Package root to resolve "package:" imports', 322 help: 'Package root to resolve "package:" imports',
318 defaultsTo: 'packages/') 323 defaultsTo: 'packages/')
319 ..addFlag('use-multi-package', 324 ..addFlag('use-multi-package',
320 help: 'Whether to use the multi-package resolver for "package:" imports', 325 help: 'Whether to use the multi-package resolver for "package:" imports',
321 defaultsTo: false) 326 defaultsTo: false)
322 ..addOption('package-paths', help: 'if using the multi-package resolver, ' 327 ..addOption('package-paths',
323 'the list of directories where to look for packages.', defaultsTo: '') 328 help: 'if using the multi-package resolver, the list of directories to\n'
329 'look for packages in.', defaultsTo: '')
324 ..addFlag('source-maps', 330 ..addFlag('source-maps',
325 help: 'Whether to emit source map files', defaultsTo: true) 331 help: 'Whether to emit source map files', defaultsTo: true)
326 ..addOption('runtime-dir', 332 ..addOption('runtime-dir',
327 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) 333 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null)
328 334
329 // general options 335 // general options
330 ..addFlag('help', abbr: 'h', help: 'Display this message') 336 ..addFlag('help', abbr: 'h', help: 'Display this message')
331 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) 337 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false)
338 ..addOption('host',
339 help: 'Host name or address to serve files from, e.g. --host=0.0.0.0\n'
340 'to listen on all interfaces (used only when --serve is on)',
341 defaultsTo: 'localhost')
332 ..addOption('port', 342 ..addOption('port',
333 help: 'Port where to serve files from (used only when --serve is on)', 343 help: 'Port to serve files from (used only when --serve is on)',
334 defaultsTo: '8080') 344 defaultsTo: '8080')
335 ..addFlag('force-compile', 345 ..addFlag('force-compile',
336 help: 'Compile code with static errors', defaultsTo: false) 346 help: 'Compile code with static errors', defaultsTo: false)
337 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to severe)') 347 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to severe)')
338 ..addFlag('dump-info', 348 ..addFlag('dump-info',
339 abbr: 'i', help: 'Dump summary information', defaultsTo: null) 349 abbr: 'i', help: 'Dump summary information', defaultsTo: null)
340 ..addOption('dump-info-file', 350 ..addOption('dump-info-file',
341 abbr: 'f', 351 abbr: 'f',
342 help: 'Dump info json file (requires dump-info)', 352 help: 'Dump info json file (requires dump-info)',
343 defaultsTo: null); 353 defaultsTo: null);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // The pub-cache directory is two levels up, but we verify that the layout 395 // The pub-cache directory is two levels up, but we verify that the layout
386 // looks correct. 396 // looks correct.
387 if (path.basename(dir) != 'dev_compiler') return null; 397 if (path.basename(dir) != 'dev_compiler') return null;
388 dir = path.dirname(dir); 398 dir = path.dirname(dir);
389 if (path.basename(dir) != 'global_packages') return null; 399 if (path.basename(dir) != 'global_packages') return null;
390 dir = path.dirname(dir); 400 dir = path.dirname(dir);
391 return path.join(dir, cacheDir, 'lib', 'runtime'); 401 return path.join(dir, cacheDir, 'lib', 'runtime');
392 } 402 }
393 return null; 403 return null;
394 } 404 }
OLDNEW
« no previous file with comments | « lib/runtime/dart_runtime.js ('k') | test/codegen/expect/server_mode/html_input.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698