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

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

Issue 1266483003: format with dart_style 0.2.0-rc.3 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 4 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/src/info.dart ('k') | lib/src/server/dependency_graph.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 25 matching lines...) Expand all
36 final bool useImplicitHtml; 36 final bool useImplicitHtml;
37 static const String implicitHtmlFile = 'index.html'; 37 static const String implicitHtmlFile = 'index.html';
38 38
39 /// Whether to use a mock-sdk during compilation. 39 /// Whether to use a mock-sdk during compilation.
40 final bool useMockSdk; 40 final bool useMockSdk;
41 41
42 /// Path to the dart-sdk. Null if `useMockSdk` is true or if the path couldn't 42 /// Path to the dart-sdk. Null if `useMockSdk` is true or if the path couldn't
43 /// be determined 43 /// be determined
44 final String dartSdkPath; 44 final String dartSdkPath;
45 45
46 const SourceResolverOptions({this.useMockSdk: false, this.dartSdkPath, 46 const SourceResolverOptions(
47 this.useMultiPackage: false, this.customUrlMappings: const {}, 47 {this.useMockSdk: false,
48 this.packageRoot: 'packages/', this.packagePaths: const <String>[], 48 this.dartSdkPath,
49 this.resources: const <String>[], this.useImplicitHtml: false}); 49 this.useMultiPackage: false,
50 this.customUrlMappings: const {},
51 this.packageRoot: 'packages/',
52 this.packagePaths: const <String>[],
53 this.resources: const <String>[],
54 this.useImplicitHtml: false});
50 } 55 }
51 56
52 // TODO(jmesserly): refactor all codegen options here. 57 // TODO(jmesserly): refactor all codegen options here.
53 class CodegenOptions { 58 class CodegenOptions {
54 /// Whether to emit the source map files. 59 /// Whether to emit the source map files.
55 final bool emitSourceMaps; 60 final bool emitSourceMaps;
56 61
57 /// Whether to force compilation of code with static errors. 62 /// Whether to force compilation of code with static errors.
58 final bool forceCompile; 63 final bool forceCompile;
59 64
60 /// Output directory for generated code. 65 /// Output directory for generated code.
61 final String outputDir; 66 final String outputDir;
62 67
63 /// Whether to emit a workaround for missing arrow function bind-this in 68 /// Whether to emit a workaround for missing arrow function bind-this in
64 /// other V8 builds 69 /// other V8 builds
65 final bool arrowFnBindThisWorkaround; 70 final bool arrowFnBindThisWorkaround;
66 71
67 const CodegenOptions({this.emitSourceMaps: true, this.forceCompile: false, 72 const CodegenOptions(
68 this.outputDir, this.arrowFnBindThisWorkaround: false}); 73 {this.emitSourceMaps: true,
74 this.forceCompile: false,
75 this.outputDir,
76 this.arrowFnBindThisWorkaround: false});
69 } 77 }
70 78
71 /// General options used by the dev compiler and server. 79 /// General options used by the dev compiler and server.
72 class CompilerOptions { 80 class CompilerOptions {
73 final StrongModeOptions strongOptions; 81 final StrongModeOptions strongOptions;
74 final SourceResolverOptions sourceOptions; 82 final SourceResolverOptions sourceOptions;
75 final CodegenOptions codegenOptions; 83 final CodegenOptions codegenOptions;
76 84
77 /// Whether to check the sdk libraries. 85 /// Whether to check the sdk libraries.
78 final bool checkSdk; 86 final bool checkSdk;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 /// package (if we can infer where that is located). 121 /// package (if we can infer where that is located).
114 final String runtimeDir; 122 final String runtimeDir;
115 123
116 /// The files to compile. 124 /// The files to compile.
117 final List<String> inputs; 125 final List<String> inputs;
118 126
119 /// The base directory for [inputs]. Module imports will be generated relative 127 /// The base directory for [inputs]. Module imports will be generated relative
120 /// to this directory. 128 /// to this directory.
121 final String inputBaseDir; 129 final String inputBaseDir;
122 130
123 CompilerOptions({this.strongOptions: const StrongModeOptions(), 131 CompilerOptions(
132 {this.strongOptions: const StrongModeOptions(),
124 this.sourceOptions: const SourceResolverOptions(), 133 this.sourceOptions: const SourceResolverOptions(),
125 this.codegenOptions: const CodegenOptions(), this.checkSdk: false, 134 this.codegenOptions: const CodegenOptions(),
126 this.dumpInfo: false, this.dumpInfoFile, this.useColors: true, 135 this.checkSdk: false,
127 this.help: false, this.logLevel: Level.SEVERE, this.serverMode: false, 136 this.dumpInfo: false,
128 this.enableHashing: false, this.widget: true, this.host: 'localhost', 137 this.dumpInfoFile,
129 this.port: 8080, this.runtimeDir, this.inputs, this.inputBaseDir}); 138 this.useColors: true,
139 this.help: false,
140 this.logLevel: Level.SEVERE,
141 this.serverMode: false,
142 this.enableHashing: false,
143 this.widget: true,
144 this.host: 'localhost',
145 this.port: 8080,
146 this.runtimeDir,
147 this.inputs,
148 this.inputBaseDir});
130 } 149 }
131 150
132 /// Parses options from the command-line 151 /// Parses options from the command-line
133 CompilerOptions parseOptions(List<String> argv) { 152 CompilerOptions parseOptions(List<String> argv) {
134 ArgResults args = argParser.parse(argv); 153 ArgResults args = argParser.parse(argv);
135 bool showUsage = args['help']; 154 bool showUsage = args['help'];
136 155
137 var serverMode = args['server']; 156 var serverMode = args['server'];
138 var enableHashing = args['hashing']; 157 var enableHashing = args['hashing'];
139 if (enableHashing == null) { 158 if (enableHashing == null) {
140 enableHashing = serverMode; 159 enableHashing = serverMode;
141 } 160 }
142 // TODO(jmesserly): shouldn't level always default to warning? 161 // TODO(jmesserly): shouldn't level always default to warning?
143 var logLevel = serverMode ? Level.WARNING : Level.SEVERE; 162 var logLevel = serverMode ? Level.WARNING : Level.SEVERE;
144 var levelName = args['log']; 163 var levelName = args['log'];
145 if (levelName != null) { 164 if (levelName != null) {
146 levelName = levelName.toUpperCase(); 165 levelName = levelName.toUpperCase();
147 logLevel = Level.LEVELS.firstWhere((l) => l.name == levelName, 166 logLevel = Level.LEVELS
148 orElse: () => logLevel); 167 .firstWhere((l) => l.name == levelName, orElse: () => logLevel);
149 } 168 }
150 var useColors = stdioType(stdout) == StdioType.TERMINAL; 169 var useColors = stdioType(stdout) == StdioType.TERMINAL;
151 var sdkPath = args['dart-sdk']; 170 var sdkPath = args['dart-sdk'];
152 if (sdkPath == null && !args['mock-sdk']) { 171 if (sdkPath == null && !args['mock-sdk']) {
153 sdkPath = getSdkDir(argv).path; 172 sdkPath = getSdkDir(argv).path;
154 } 173 }
155 var runtimeDir = args['runtime-dir']; 174 var runtimeDir = args['runtime-dir'];
156 if (runtimeDir == null) { 175 if (runtimeDir == null) {
157 runtimeDir = _computeRuntimeDir(); 176 runtimeDir = _computeRuntimeDir();
158 } 177 }
(...skipping 25 matching lines...) Expand all
184 sourceOptions: new SourceResolverOptions( 203 sourceOptions: new SourceResolverOptions(
185 useMockSdk: args['mock-sdk'], 204 useMockSdk: args['mock-sdk'],
186 dartSdkPath: sdkPath, 205 dartSdkPath: sdkPath,
187 useImplicitHtml: serverMode && 206 useImplicitHtml: serverMode &&
188 args.rest.length == 1 && 207 args.rest.length == 1 &&
189 args.rest[0].endsWith('.dart'), 208 args.rest[0].endsWith('.dart'),
190 customUrlMappings: customUrlMappings, 209 customUrlMappings: customUrlMappings,
191 useMultiPackage: args['use-multi-package'], 210 useMultiPackage: args['use-multi-package'],
192 packageRoot: args['package-root'], 211 packageRoot: args['package-root'],
193 packagePaths: args['package-paths'].split(','), 212 packagePaths: args['package-paths'].split(','),
194 resources: args['resources'] 213 resources:
195 .split(',') 214 args['resources'].split(',').where((s) => s.isNotEmpty).toList()),
196 .where((s) => s.isNotEmpty)
197 .toList()),
198 strongOptions: new StrongModeOptions.fromArguments(args), 215 strongOptions: new StrongModeOptions.fromArguments(args),
199 checkSdk: args['sdk-check'], 216 checkSdk: args['sdk-check'],
200 dumpInfo: dumpInfo, 217 dumpInfo: dumpInfo,
201 dumpInfoFile: args['dump-info-file'], 218 dumpInfoFile: args['dump-info-file'],
202 useColors: useColors, 219 useColors: useColors,
203 help: showUsage, 220 help: showUsage,
204 logLevel: logLevel, 221 logLevel: logLevel,
205 serverMode: serverMode, 222 serverMode: serverMode,
206 enableHashing: enableHashing, 223 enableHashing: enableHashing,
207 widget: args['widget'], 224 widget: args['widget'],
(...skipping 12 matching lines...) Expand all
220 // input/output options 237 // input/output options
221 ..addOption('out', abbr: 'o', help: 'Output directory', defaultsTo: null) 238 ..addOption('out', abbr: 'o', help: 'Output directory', defaultsTo: null)
222 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null) 239 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null)
223 ..addOption('dump-src-to', help: 'Dump dart src code', defaultsTo: null) 240 ..addOption('dump-src-to', help: 'Dump dart src code', defaultsTo: null)
224 ..addOption('package-root', 241 ..addOption('package-root',
225 abbr: 'p', 242 abbr: 'p',
226 help: 'Package root to resolve "package:" imports', 243 help: 'Package root to resolve "package:" imports',
227 defaultsTo: 'packages/') 244 defaultsTo: 'packages/')
228 ..addOption('url-mapping', 245 ..addOption('url-mapping',
229 help: '--url-mapping=libraryUri,/path/to/library.dart uses library.dart\n' 246 help: '--url-mapping=libraryUri,/path/to/library.dart uses library.dart\n'
230 'as the source for an import of of "libraryUri".', 247 'as the source for an import of of "libraryUri".',
231 allowMultiple: true, 248 allowMultiple: true,
232 splitCommas: false) 249 splitCommas: false)
233 ..addFlag('use-multi-package', 250 ..addFlag('use-multi-package',
234 help: 'Whether to use the multi-package resolver for "package:" imports', 251 help: 'Whether to use the multi-package resolver for "package:" imports',
235 defaultsTo: false) 252 defaultsTo: false)
236 ..addOption('package-paths', 253 ..addOption('package-paths',
237 help: 'if using the multi-package resolver, the list of directories to\n' 254 help: 'if using the multi-package resolver, the list of directories to\n'
238 'look for packages in.', defaultsTo: '') 255 'look for packages in.',
256 defaultsTo: '')
239 ..addOption('resources', 257 ..addOption('resources',
240 help: 'Additional resources to serve', defaultsTo: '') 258 help: 'Additional resources to serve', defaultsTo: '')
241 ..addFlag('source-maps', 259 ..addFlag('source-maps',
242 help: 'Whether to emit source map files', defaultsTo: true) 260 help: 'Whether to emit source map files', defaultsTo: true)
243 ..addOption('runtime-dir', 261 ..addOption('runtime-dir',
244 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) 262 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null)
245 ..addFlag('arrow-fn-bind-this', 263 ..addFlag('arrow-fn-bind-this',
246 help: 'Work around `this` binding in => functions') 264 help: 'Work around `this` binding in => functions')
247 265
248 // general options 266 // general options
249 ..addFlag('help', abbr: 'h', help: 'Display this message') 267 ..addFlag('help', abbr: 'h', help: 'Display this message')
250 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) 268 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false)
251 ..addFlag('hashing', 269 ..addFlag('hashing',
252 help: 'Enable hash-based file caching.', defaultsTo: null) 270 help: 'Enable hash-based file caching.', defaultsTo: null)
253 ..addFlag('widget', 271 ..addFlag('widget',
254 help: 'Serve embedded widget with static errors and warnings.', 272 help: 'Serve embedded widget with static errors and warnings.',
255 defaultsTo: true) 273 defaultsTo: true)
256 ..addOption('host', 274 ..addOption('host',
257 help: 'Host name or address to serve files from, e.g. --host=0.0.0.0\n' 275 help: 'Host name or address to serve files from, e.g. --host=0.0.0.0\n'
258 'to listen on all interfaces (used only when --serve is on)', 276 'to listen on all interfaces (used only when --serve is on)',
259 defaultsTo: 'localhost') 277 defaultsTo: 'localhost')
260 ..addOption('port', 278 ..addOption('port',
261 help: 'Port to serve files from (used only when --serve is on)', 279 help: 'Port to serve files from (used only when --serve is on)',
262 defaultsTo: '8080') 280 defaultsTo: '8080')
263 ..addFlag('force-compile', 281 ..addFlag('force-compile',
264 help: 'Compile code with static errors', defaultsTo: false) 282 help: 'Compile code with static errors', defaultsTo: false)
265 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to severe)') 283 ..addOption('log', abbr: 'l', help: 'Logging level (defaults to severe)')
266 ..addFlag('dump-info', 284 ..addFlag('dump-info',
267 abbr: 'i', help: 'Dump summary information', defaultsTo: null) 285 abbr: 'i', help: 'Dump summary information', defaultsTo: null)
268 ..addOption('dump-info-file', 286 ..addOption('dump-info-file',
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // The pub-cache directory is two levels up, but we verify that the layout 331 // The pub-cache directory is two levels up, but we verify that the layout
314 // looks correct. 332 // looks correct.
315 if (path.basename(dir) != 'dev_compiler') return null; 333 if (path.basename(dir) != 'dev_compiler') return null;
316 dir = path.dirname(dir); 334 dir = path.dirname(dir);
317 if (path.basename(dir) != 'global_packages') return null; 335 if (path.basename(dir) != 'global_packages') return null;
318 dir = path.dirname(dir); 336 dir = path.dirname(dir);
319 return path.join(dir, cacheDir, 'lib', 'runtime'); 337 return path.join(dir, cacheDir, 'lib', 'runtime');
320 } 338 }
321 return null; 339 return null;
322 } 340 }
OLDNEW
« no previous file with comments | « lib/src/info.dart ('k') | lib/src/server/dependency_graph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698