OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 import 'dart:async'; | |
6 import 'dart:convert'; | |
7 import 'dart:io'; | |
8 | |
9 import 'compiler_configuration.dart'; | |
10 import 'http_server.dart'; | |
11 import 'path.dart'; | |
12 import 'runtime_configuration.dart'; | |
13 import 'test_suite.dart'; | |
14 | |
15 /// All of the contextual information to determine how a test suite should be | |
16 /// run. | |
17 /// | |
18 /// Includes the compiler used to compile the code, the runtime the result is | |
19 /// executed on, etc. | |
20 class Configuration { | |
21 Configuration( | |
22 {this.architecture, | |
23 this.compiler, | |
24 this.mode, | |
25 this.progress, | |
26 this.runtime, | |
27 this.system, | |
28 this.selectors, | |
29 this.appendLogs, | |
30 this.batch, | |
31 this.batchDart2JS, | |
32 this.copyCoreDumps, | |
33 this.hotReload, | |
34 this.hotReloadRollback, | |
35 this.isChecked, | |
36 this.isStrong, | |
37 this.isHostChecked, | |
38 this.isCsp, | |
39 this.isMinified, | |
40 this.isVerbose, | |
41 this.listTests, | |
42 this.printTiming, | |
43 this.printReport, | |
44 this.reportInJson, | |
45 this.resetBrowser, | |
46 this.skipCompilation, | |
47 this.useBlobs, | |
48 this.useSdk, | |
49 this.useCpsIR, | |
50 this.useFastStartup, | |
51 this.useDart2JSWithKernel, | |
52 this.writeDebugLog, | |
53 this.writeTestOutcomeLog, | |
54 this.drtPath, | |
55 this.dartiumPath, | |
56 this.chromePath, | |
57 this.safariPath, | |
58 this.firefoxPath, | |
59 this.dartPath, | |
60 this.dartPrecompiledPath, | |
61 this.flutterPath, | |
62 this.recordingPath, | |
63 this.replayPath, | |
64 this.taskCount, | |
65 int timeout, | |
66 this.shardCount, | |
67 this.shard, | |
68 this.stepName, | |
69 this.testServerPort, | |
70 this.testServerCrossOriginPort, | |
71 this.testDriverErrorPort, | |
72 this.localIP, | |
73 this.dart2jsOptions, | |
74 this.vmOptions, | |
75 String packages, | |
76 this.packageRoot, | |
77 this.suiteDirectory, | |
78 this.builderTag, | |
79 this.reproducingArguments}) | |
80 : _packages = packages, | |
81 _timeout = timeout; | |
82 | |
83 final Architecture architecture; | |
84 final Compiler compiler; | |
85 final Mode mode; | |
86 final Progress progress; | |
87 final Runtime runtime; | |
88 final System system; | |
89 | |
90 final Map<String, RegExp> selectors; | |
91 | |
92 // Boolean flags. | |
93 | |
94 final bool appendLogs; | |
95 final bool batch; | |
96 final bool batchDart2JS; | |
97 final bool copyCoreDumps; | |
98 final bool hotReload; | |
99 final bool hotReloadRollback; | |
100 final bool isChecked; | |
101 final bool isStrong; | |
102 final bool isHostChecked; | |
103 final bool isCsp; | |
104 final bool isMinified; | |
105 final bool isVerbose; | |
106 final bool listTests; | |
107 final bool printTiming; | |
108 final bool printReport; | |
109 final bool reportInJson; | |
110 final bool resetBrowser; | |
111 final bool skipCompilation; | |
112 final bool useBlobs; | |
113 final bool useSdk; | |
114 final bool useCpsIR; | |
115 final bool useFastStartup; | |
116 final bool useDart2JSWithKernel; | |
117 final bool writeDebugLog; | |
118 final bool writeTestOutcomeLog; | |
119 | |
120 // Various file paths. | |
121 | |
122 final String drtPath; | |
123 final String dartiumPath; | |
124 final String chromePath; | |
125 final String safariPath; | |
126 final String firefoxPath; | |
127 final String dartPath; | |
128 final String dartPrecompiledPath; | |
129 final String flutterPath; | |
130 final String recordingPath; | |
131 final String replayPath; | |
132 | |
133 final int taskCount; | |
134 final int shardCount; | |
135 final int shard; | |
136 final String stepName; | |
137 | |
138 final int testServerPort; | |
139 final int testServerCrossOriginPort; | |
140 final int testDriverErrorPort; | |
141 final String localIP; | |
142 | |
143 /// Extra dart2js options passed to the testing script. | |
144 final List<String> dart2jsOptions; | |
145 | |
146 /// Extra VM options passed to the testing script. | |
147 final List<String> vmOptions; | |
148 | |
149 String _packages; | |
150 String get packages { | |
151 // If the .packages file path wasn't given, find it. | |
152 if (packageRoot == null && _packages == null) { | |
153 _packages = TestUtils.dartDirUri.resolve('.packages').toFilePath(); | |
154 } | |
155 | |
156 return _packages; | |
157 } | |
158 | |
159 final String packageRoot; | |
160 final String suiteDirectory; | |
161 final String builderTag; | |
162 final List<String> reproducingArguments; | |
163 | |
164 TestingServers _servers; | |
165 TestingServers get servers { | |
166 if (_servers == null) { | |
167 throw new StateError("Servers have not been started yet."); | |
168 } | |
169 return _servers; | |
170 } | |
171 | |
172 /// The base directory named for this configuration, like: | |
173 /// | |
174 /// none_vm_release_x64 | |
175 String _configurationDirectory; | |
176 String get configurationDirectory { | |
177 // Lazy initialize and cache since it requires hitting the file system. | |
178 if (_configurationDirectory == null) { | |
179 _configurationDirectory = _calculateDirectory(); | |
180 } | |
181 | |
182 return _configurationDirectory; | |
183 } | |
184 | |
185 /// The build directory path for this configuration, like: | |
186 /// | |
187 /// build/none_vm_release_x64 | |
188 String get buildDirectory => system.outputDirectory + configurationDirectory; | |
189 | |
190 int _timeout; | |
191 int get timeout { | |
192 if (_timeout == null) { | |
193 var isReload = hotReload || hotReloadRollback; | |
194 | |
195 var compilerMulitiplier = compilerConfiguration.timeoutMultiplier; | |
196 var runtimeMultiplier = runtimeConfiguration.timeoutMultiplier( | |
197 mode: mode, | |
198 isChecked: isChecked, | |
199 isReload: isReload, | |
200 arch: architecture); | |
201 | |
202 _timeout = 60 * compilerMulitiplier * runtimeMultiplier; | |
203 } | |
204 | |
205 return _timeout; | |
206 } | |
207 | |
208 List<String> get standardOptions { | |
209 if (compiler != Compiler.dart2js) { | |
210 return const ["--ignore-unrecognized-flags"]; | |
211 } | |
212 | |
213 var args = ['--generate-code-with-compile-time-errors', '--test-mode']; | |
214 if (isChecked) args.add('--enable-checked-mode'); | |
215 | |
216 // args.add("--verbose"); | |
Bill Hesse
2017/05/29 13:08:28
Remove commented code.
Bob Nystrom
2017/05/30 23:29:31
Done.
| |
217 if (!runtime.isBrowser) { | |
218 args.add("--allow-mock-compilation"); | |
219 args.add("--categories=all"); | |
220 } | |
221 | |
222 if (isMinified) args.add("--minify"); | |
223 if (isCsp) args.add("--csp"); | |
224 if (useCpsIR) args.add("--use-cps-ir"); | |
225 if (useFastStartup) args.add("--fast-startup"); | |
226 if (useDart2JSWithKernel) args.add("--use-kernel"); | |
227 return args; | |
228 } | |
229 | |
230 String _windowsSdkPath; | |
231 String get windowsSdkPath { | |
232 if (!Platform.isWindows) { | |
233 throw new StateError( | |
234 "Should not use windowsSdkPath when not running on Windows."); | |
235 } | |
236 | |
237 if (_windowsSdkPath == null) { | |
238 // When running tests on Windows, use cdb from depot_tools to dump | |
239 // stack traces of tests timing out. | |
240 try { | |
241 var path = new Path("build/win_toolchain.json").toNativePath(); | |
242 var text = new File(path).readAsStringSync(); | |
243 _windowsSdkPath = JSON.decode(text)['win_sdk'] as String; | |
244 } on dynamic { | |
245 // Ignore errors here. If win_sdk is not found, stack trace dumping | |
246 // for timeouts won't work. | |
247 } | |
248 } | |
249 | |
250 return _windowsSdkPath; | |
251 } | |
252 | |
253 /// Gets the local file path to the browser executable for this configuration. | |
Bill Hesse
2017/05/29 13:08:28
I think this would go better in runtime_configurat
Bob Nystrom
2017/05/30 23:29:31
This relies on chromePath, dartiumPath, et al., wh
| |
254 String get browserLocation { | |
255 // If the user has explicitly configured a browser path, use it. | |
256 String location; | |
257 switch (runtime) { | |
258 case Runtime.chrome: | |
259 location = chromePath; | |
260 break; | |
261 case Runtime.dartium: | |
262 location = dartiumPath; | |
263 break; | |
264 case Runtime.drt: | |
265 location = drtPath; | |
266 break; | |
267 case Runtime.firefox: | |
268 location = firefoxPath; | |
269 break; | |
270 case Runtime.flutter: | |
271 location = flutterPath; | |
272 break; | |
273 case Runtime.safari: | |
274 location = safariPath; | |
275 break; | |
276 } | |
277 | |
278 if (location != null) return location; | |
279 | |
280 const locations = const { | |
281 Runtime.firefox: const { | |
282 System.windows: 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe', | |
283 System.linux: 'firefox', | |
284 System.macos: '/Applications/Firefox.app/Contents/MacOS/firefox' | |
285 }, | |
286 Runtime.chrome: const { | |
287 System.windows: | |
288 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', | |
289 System.macos: | |
290 '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', | |
291 System.linux: 'google-chrome' | |
292 }, | |
293 Runtime.dartium: const { | |
294 System.windows: 'client\\tests\\dartium\\chrome.exe', | |
295 System.macos: | |
296 'client/tests/dartium/Chromium.app/Contents/MacOS/Chromium', | |
297 System.linux: 'client/tests/dartium/chrome' | |
298 }, | |
299 Runtime.safari: const { | |
300 System.macos: '/Applications/Safari.app/Contents/MacOS/Safari' | |
301 }, | |
302 Runtime.safariMobileSim: const { | |
303 System.macos: '/Applications/Xcode.app/Contents/Developer/Platforms/' | |
304 'iPhoneSimulator.platform/Developer/Applications/' | |
305 'iPhone Simulator.app/Contents/MacOS/iPhone Simulator' | |
306 }, | |
307 Runtime.ie9: const { | |
308 System.windows: 'C:\\Program Files\\Internet Explorer\\iexplore.exe' | |
309 }, | |
310 Runtime.ie10: const { | |
311 System.windows: 'C:\\Program Files\\Internet Explorer\\iexplore.exe' | |
312 }, | |
313 Runtime.ie11: const { | |
314 System.windows: 'C:\\Program Files\\Internet Explorer\\iexplore.exe' | |
315 } | |
316 }; | |
317 | |
318 location = locations[runtime][System.find(Platform.operatingSystem)]; | |
319 | |
320 if (location == null) { | |
321 throw "${runtime.name} is not supported on ${Platform.operatingSystem}"; | |
322 } | |
323 | |
324 return location; | |
325 } | |
326 | |
327 RuntimeConfiguration _runtimeConfiguration; | |
Bill Hesse
2017/05/29 13:08:28
Same here - couldn't the function go in runtime_co
Bob Nystrom
2017/05/30 23:29:31
My goal was to get rid of all of the "configuratio
| |
328 RuntimeConfiguration get runtimeConfiguration { | |
329 if (_runtimeConfiguration == null) { | |
330 switch (runtime) { | |
331 case Runtime.contentShellOnAndroid: | |
332 case Runtime.dartiumOnAndroid: | |
333 case Runtime.chrome: | |
334 case Runtime.chromeOnAndroid: | |
335 case Runtime.dartium: | |
336 case Runtime.firefox: | |
337 case Runtime.ie11: | |
338 case Runtime.ie10: | |
339 case Runtime.ie9: | |
340 case Runtime.opera: | |
341 case Runtime.safari: | |
342 case Runtime.safariMobileSim: | |
343 // TODO(ahe): Replace this with one or more browser runtimes. | |
344 _runtimeConfiguration = new DummyRuntimeConfiguration(); | |
345 break; | |
346 | |
347 case Runtime.jsshell: | |
348 _runtimeConfiguration = new JsshellRuntimeConfiguration(); | |
349 break; | |
350 | |
351 case Runtime.d8: | |
352 _runtimeConfiguration = new D8RuntimeConfiguration(); | |
353 break; | |
354 | |
355 case Runtime.none: | |
356 _runtimeConfiguration = new NoneRuntimeConfiguration(); | |
357 break; | |
358 | |
359 case Runtime.vm: | |
360 _runtimeConfiguration = new StandaloneDartRuntimeConfiguration(); | |
361 break; | |
362 | |
363 case Runtime.flutter: | |
364 _runtimeConfiguration = new StandaloneFlutterEngineConfiguration(); | |
365 break; | |
366 | |
367 case Runtime.dartPrecompiled: | |
368 if (system == System.android) { | |
369 _runtimeConfiguration = | |
370 new DartPrecompiledAdbRuntimeConfiguration(useBlobs: useBlobs); | |
371 } else { | |
372 _runtimeConfiguration = | |
373 new DartPrecompiledRuntimeConfiguration(useBlobs: useBlobs); | |
374 } | |
375 break; | |
376 | |
377 case Runtime.drt: | |
378 _runtimeConfiguration = new DrtRuntimeConfiguration(); | |
379 break; | |
380 | |
381 case Runtime.selfCheck: | |
382 _runtimeConfiguration = new SelfCheckRuntimeConfiguration(); | |
383 break; | |
384 | |
385 default: | |
386 assert(false); | |
387 } | |
388 } | |
389 | |
390 return _runtimeConfiguration; | |
391 } | |
392 | |
393 CompilerConfiguration _compilerConfiguration; | |
394 CompilerConfiguration get compilerConfiguration { | |
395 if (_compilerConfiguration == null) { | |
396 switch (compiler) { | |
397 case Compiler.dart2analyzer: | |
398 _compilerConfiguration = new AnalyzerCompilerConfiguration( | |
399 isDebug: mode.isDebug, | |
400 isChecked: isChecked, | |
401 isStrong: isStrong, | |
402 isHostChecked: isHostChecked, | |
403 useSdk: useSdk); | |
404 break; | |
405 | |
406 case Compiler.dart2js: | |
407 _compilerConfiguration = new Dart2jsCompilerConfiguration( | |
408 isDebug: mode.isDebug, | |
409 isChecked: isChecked, | |
410 isHostChecked: isHostChecked, | |
411 useCps: useCpsIR, | |
412 useSdk: useSdk, | |
413 isCsp: isCsp, | |
414 useFastStartup: useFastStartup, | |
415 useKernel: useDart2JSWithKernel, | |
416 extraDart2jsOptions: dart2jsOptions); | |
417 break; | |
418 | |
419 case Compiler.appJit: | |
420 _compilerConfiguration = new AppJitCompilerConfiguration( | |
421 isDebug: mode.isDebug, isChecked: isChecked); | |
422 break; | |
423 | |
424 case Compiler.precompiler: | |
425 _compilerConfiguration = new PrecompilerCompilerConfiguration( | |
426 isDebug: mode.isDebug, | |
427 isChecked: isChecked, | |
428 arch: architecture, | |
429 useBlobs: useBlobs, | |
430 isAndroid: system == System.android); | |
431 break; | |
432 | |
433 case Compiler.dartk: | |
434 _compilerConfiguration = new NoneCompilerConfiguration( | |
435 isDebug: mode.isDebug, | |
436 isChecked: isChecked, | |
437 isHostChecked: isHostChecked, | |
438 useSdk: useSdk, | |
439 hotReload: hotReload, | |
440 hotReloadRollback: hotReloadRollback, | |
441 useDFE: true); | |
442 break; | |
443 | |
444 case Compiler.dartkp: | |
445 _compilerConfiguration = new PrecompilerCompilerConfiguration( | |
446 isDebug: mode.isDebug, | |
447 isChecked: isChecked, | |
448 arch: architecture, | |
449 useBlobs: useBlobs, | |
450 isAndroid: system == System.android, | |
451 useDFE: true); | |
452 break; | |
453 | |
454 case Compiler.none: | |
455 _compilerConfiguration = new NoneCompilerConfiguration( | |
456 isDebug: mode.isDebug, | |
457 isChecked: isChecked, | |
458 isHostChecked: isHostChecked, | |
459 useSdk: useSdk, | |
460 hotReload: hotReload, | |
461 hotReloadRollback: hotReloadRollback); | |
462 break; | |
463 | |
464 default: | |
465 assert(false); | |
466 } | |
467 } | |
468 | |
469 return _compilerConfiguration; | |
470 } | |
471 | |
472 /// Determines if this configuration has a compatible compiler and runtime | |
473 /// and other valid fields. | |
474 /// | |
475 /// Prints a warning if the configuration isn't valid. Returns whether or not | |
476 /// it is. | |
477 bool validate() { | |
478 var isValid = true; | |
479 var validRuntimes = compiler.supportedRuntimes; | |
480 | |
481 if (!validRuntimes.contains(runtime)) { | |
482 print("Warning: combination of compiler '${compiler.name}' and " | |
483 "runtime '${runtime.name}' is invalid. Skipping this combination."); | |
484 isValid = false; | |
485 } | |
486 | |
487 if (runtime.isIE && Platform.operatingSystem != 'windows') { | |
488 print("Warning: cannot run Internet Explorer on non-Windows operating" | |
489 " system."); | |
490 isValid = false; | |
491 } | |
492 | |
493 if (shard < 1 || shard > shardCount) { | |
494 print("Error: shard index is $shard out of $shardCount shards"); | |
495 isValid = false; | |
496 } | |
497 | |
498 if (runtime == Runtime.flutter && flutterPath == null) { | |
499 print("-rflutter requires the flutter engine executable to " | |
500 "be specified using --flutter"); | |
501 isValid = false; | |
502 } | |
503 | |
504 if (runtime == Runtime.flutter && architecture != Architecture.x64) { | |
505 isValid = false; | |
506 print("-rflutter is applicable only for --arch=x64"); | |
507 } | |
508 | |
509 return isValid; | |
510 } | |
511 | |
512 /// Starts global HTTP servers that serve the entire dart repo. | |
513 /// | |
514 /// The HTTP server is available on `window.location.port`, and a second | |
515 /// server for cross-domain tests can be found by calling | |
516 /// `getCrossOriginPortNumber()`. | |
517 Future startServers() { | |
518 _servers = new TestingServers( | |
519 buildDirectory, isCsp, runtime, null, packageRoot, packages); | |
520 var future = servers.startServers(localIP, | |
521 port: testServerPort, crossOriginPort: testServerCrossOriginPort); | |
522 | |
523 if (isVerbose) { | |
524 future = future.then((_) { | |
525 print('Started HttpServers: ${servers.httpServerCommandLine()}'); | |
526 }); | |
527 } | |
528 | |
529 return future; | |
530 } | |
531 | |
532 void stopServers() { | |
533 if (_servers != null) _servers.stopServers(); | |
534 } | |
535 | |
536 /// Returns the correct configuration directory (the last component of the | |
537 /// output directory path) for regular dart checkouts. | |
538 /// | |
539 /// Dartium checkouts use the `--build-directory` option to pass in the | |
540 /// correct build directory explicitly. We allow our code to have been cross | |
541 /// compiled, i.e., that there is an X in front of the arch. We don't allow | |
542 /// both a cross compiled and a normal version to be present (except if you | |
543 /// specifically pass in the build_directory). | |
544 String _calculateDirectory() { | |
545 // Capitalize the mode name. | |
546 var modeName = | |
547 mode.name.substring(0, 1).toUpperCase() + mode.name.substring(1); | |
548 | |
549 var os = ''; | |
550 if (system == System.android) os = "Android"; | |
551 | |
552 var arch = architecture.name.toUpperCase(); | |
553 var normal = '$modeName$os$arch'; | |
554 var cross = '$modeName${os}X$arch'; | |
555 var outDir = system.outputDirectory; | |
556 var normalDir = new Directory(new Path('$outDir$normal').toNativePath()); | |
557 var crossDir = new Directory(new Path('$outDir$cross').toNativePath()); | |
558 | |
559 if (normalDir.existsSync() && crossDir.existsSync()) { | |
560 throw "You can't have both $normalDir and $crossDir. We don't know which" | |
561 " binary to use."; | |
562 } | |
563 | |
564 if (crossDir.existsSync()) return cross; | |
565 | |
566 return normal; | |
567 } | |
568 } | |
569 | |
570 class Architecture { | |
571 static const ia32 = const Architecture._('ia32'); | |
572 static const x64 = const Architecture._('x64'); | |
573 static const arm = const Architecture._('arm'); | |
574 static const armv6 = const Architecture._('armv6'); | |
575 static const armv5te = const Architecture._('armv5te'); | |
576 static const arm64 = const Architecture._('arm64'); | |
577 static const simarm = const Architecture._('simarm'); | |
578 static const simarmv6 = const Architecture._('simarmv6'); | |
579 static const simarmv5te = const Architecture._('simarmv5te'); | |
580 static const simarm64 = const Architecture._('simarm64'); | |
581 static const mips = const Architecture._('mips'); | |
582 static const simmips = const Architecture._('simmips'); | |
583 static const simdbc = const Architecture._('simdbc'); | |
584 static const simdbc64 = const Architecture._('simdbc64'); | |
585 | |
586 static final List<String> names = _all.keys.toList(); | |
587 | |
588 static final _all = new Map<String, Architecture>.fromIterable([ | |
589 ia32, | |
590 x64, | |
591 arm, | |
592 armv6, | |
593 armv5te, | |
594 arm64, | |
595 simarm, | |
596 simarmv6, | |
597 simarmv5te, | |
598 simarm64, | |
599 mips, | |
600 simmips, | |
601 simdbc, | |
602 simdbc64 | |
603 ], key: (Architecture architecture) => architecture.name); | |
604 | |
605 static Architecture find(String name) { | |
606 var architecture = _all[name]; | |
607 if (architecture != null) return architecture; | |
608 | |
609 throw new ArgumentError('Unknown architecture "$name".'); | |
610 } | |
611 | |
612 final String name; | |
613 | |
614 const Architecture._(this.name); | |
615 | |
616 String toString() => "Architecture($name)"; | |
617 } | |
618 | |
619 class Compiler { | |
620 static const none = const Compiler._('none'); | |
621 static const precompiler = const Compiler._('precompiler'); | |
622 static const dart2js = const Compiler._('dart2js'); | |
623 static const dart2analyzer = const Compiler._('dart2analyzer'); | |
624 static const appJit = const Compiler._('app_jit'); | |
625 static const dartk = const Compiler._('dartk'); | |
626 static const dartkp = const Compiler._('dartkp'); | |
627 | |
628 static final List<String> names = _all.keys.toList(); | |
629 | |
630 static final _all = new Map<String, Compiler>.fromIterable( | |
631 [none, precompiler, dart2js, dart2analyzer, appJit, dartk, dartkp], | |
632 key: (Compiler compiler) => compiler.name); | |
633 | |
634 static Compiler find(String name) { | |
635 var compiler = _all[name]; | |
636 if (compiler != null) return compiler; | |
637 | |
638 throw new ArgumentError('Unknown compiler "$name".'); | |
639 } | |
640 | |
641 final String name; | |
642 | |
643 const Compiler._(this.name); | |
644 | |
645 /// Gets the runtimes this compiler can target. | |
646 List<Runtime> get supportedRuntimes { | |
647 switch (this) { | |
Bill Hesse
2017/05/29 13:08:28
Could these be on the compiler configurations, or
Bob Nystrom
2017/05/30 23:29:31
They could, yes. But they don't rely on any of the
| |
648 case Compiler.dart2js: | |
649 // Note: by adding 'none' as a configuration, if the user | |
650 // runs test.py -c dart2js -r drt,none the dart2js_none and | |
651 // dart2js_drt will be duplicating work. If later we don't need 'none' | |
652 // with dart2js, we should remove it from here. | |
653 return const [ | |
654 Runtime.d8, | |
655 Runtime.jsshell, | |
656 Runtime.drt, | |
657 Runtime.none, | |
658 Runtime.dartium, | |
659 Runtime.firefox, | |
660 Runtime.chrome, | |
661 Runtime.safari, | |
662 Runtime.ie9, | |
663 Runtime.ie10, | |
664 Runtime.ie11, | |
665 Runtime.opera, | |
666 Runtime.chromeOnAndroid, | |
667 Runtime.safariMobileSim | |
668 ]; | |
669 | |
670 case Compiler.dart2analyzer: | |
671 return const [Runtime.none]; | |
672 case Compiler.appJit: | |
673 case Compiler.dartk: | |
674 return const [Runtime.vm, Runtime.selfCheck, Runtime.none]; | |
675 case Compiler.precompiler: | |
676 case Compiler.dartkp: | |
677 return const [Runtime.dartPrecompiled]; | |
678 case Compiler.none: | |
679 return const [ | |
680 Runtime.vm, | |
681 Runtime.flutter, | |
682 Runtime.drt, | |
683 Runtime.dartium, | |
684 Runtime.contentShellOnAndroid, | |
685 Runtime.dartiumOnAndroid | |
686 ]; | |
687 } | |
688 | |
689 throw "unreachable"; | |
690 } | |
691 | |
692 String toString() => "Compiler($name)"; | |
693 } | |
694 | |
695 class Mode { | |
696 static const debug = const Mode._('debug'); | |
697 static const product = const Mode._('product'); | |
698 static const release = const Mode._('release'); | |
699 | |
700 static final List<String> names = _all.keys.toList(); | |
701 | |
702 static final _all = new Map<String, Mode>.fromIterable( | |
703 [debug, product, release], | |
704 key: (Mode mode) => mode.name); | |
705 | |
706 static Mode find(String name) { | |
707 var mode = _all[name]; | |
708 if (mode != null) return mode; | |
709 | |
710 throw new ArgumentError('Unknown mode "$name".'); | |
711 } | |
712 | |
713 final String name; | |
714 | |
715 const Mode._(this.name); | |
716 | |
717 bool get isDebug => this == debug; | |
718 | |
719 String toString() => "Mode($name)"; | |
720 } | |
721 | |
722 class Progress { | |
723 static const compact = const Progress._('compact'); | |
724 static const color = const Progress._('color'); | |
725 static const line = const Progress._('line'); | |
726 static const verbose = const Progress._('verbose'); | |
727 static const silent = const Progress._('silent'); | |
728 static const status = const Progress._('status'); | |
729 static const buildbot = const Progress._('buildbot'); | |
730 static const diff = const Progress._('diff'); | |
731 | |
732 static final List<String> names = _all.keys.toList(); | |
733 | |
734 static final _all = new Map<String, Progress>.fromIterable( | |
735 [compact, color, line, verbose, silent, status, buildbot, diff], | |
736 key: (Progress progress) => progress.name); | |
737 | |
738 static Progress find(String name) { | |
739 var progress = _all[name]; | |
740 if (progress != null) return progress; | |
741 | |
742 throw new ArgumentError('Unknown progress type "$name".'); | |
743 } | |
744 | |
745 final String name; | |
746 | |
747 const Progress._(this.name); | |
748 | |
749 String toString() => "Progress($name)"; | |
750 } | |
751 | |
752 class Runtime { | |
753 static const vm = const Runtime._('vm'); | |
754 static const flutter = const Runtime._('flutter'); | |
755 static const dartPrecompiled = const Runtime._('dart_precompiled'); | |
756 static const d8 = const Runtime._('d8'); | |
757 static const jsshell = const Runtime._('jsshell'); | |
758 static const drt = const Runtime._('drt'); | |
759 static const dartium = const Runtime._('dartium'); | |
760 static const firefox = const Runtime._('firefox'); | |
761 static const chrome = const Runtime._('chrome'); | |
762 static const safari = const Runtime._('safari'); | |
763 static const ie9 = const Runtime._('ie9'); | |
764 static const ie10 = const Runtime._('ie10'); | |
765 static const ie11 = const Runtime._('ie11'); | |
766 static const opera = const Runtime._('opera'); | |
767 static const chromeOnAndroid = const Runtime._('chromeOnAndroid'); | |
768 static const safariMobileSim = const Runtime._('safarimobilesim'); | |
769 static const contentShellOnAndroid = const Runtime._('ContentShellOnAndroid'); | |
770 static const dartiumOnAndroid = const Runtime._('DartiumOnAndroid'); | |
771 static const selfCheck = const Runtime._('self_check'); | |
772 static const none = const Runtime._('none'); | |
773 | |
774 static final List<String> names = _all.keys.toList()..add("ff"); | |
775 | |
776 static final _all = new Map<String, Runtime>.fromIterable([ | |
777 vm, | |
778 flutter, | |
779 dartPrecompiled, | |
780 d8, | |
781 jsshell, | |
782 drt, | |
783 dartium, | |
784 firefox, | |
785 chrome, | |
786 safari, | |
787 ie9, | |
788 ie10, | |
789 ie11, | |
790 opera, | |
791 chromeOnAndroid, | |
792 safariMobileSim, | |
793 contentShellOnAndroid, | |
794 dartiumOnAndroid, | |
795 selfCheck, | |
796 none | |
797 ], key: (Runtime runtime) => runtime.name); | |
798 | |
799 static Runtime find(String name) { | |
800 // Allow "ff" as a synonym for Firefox. | |
801 if (name == "ff") return firefox; | |
802 | |
803 var runtime = _all[name]; | |
804 if (runtime != null) return runtime; | |
805 | |
806 throw new ArgumentError('Unknown runtime "$name".'); | |
807 } | |
808 | |
809 final String name; | |
810 | |
811 const Runtime._(this.name); | |
812 | |
813 bool get isBrowser => const [ | |
814 drt, | |
815 dartium, | |
816 ie9, | |
817 ie10, | |
818 ie11, | |
819 safari, | |
820 opera, | |
821 chrome, | |
822 firefox, | |
823 chromeOnAndroid, | |
824 safariMobileSim, | |
825 contentShellOnAndroid, | |
826 dartiumOnAndroid, | |
827 ].contains(this); | |
828 | |
829 bool get isIE => name.startsWith("ie"); | |
830 bool get isSafari => name.startsWith("safari"); | |
831 | |
832 /// Whether this runtime is a command-line JavaScript environment. | |
833 bool get isJSCommandLine => const [d8, jsshell].contains(this); | |
834 | |
835 /// If the runtime doesn't support `Window.open`, we use iframes instead. | |
836 bool get requiresIFrame => !const [ie11, ie10].contains(this); | |
837 | |
838 String toString() => "Runtime($name)"; | |
839 } | |
840 | |
841 class System { | |
842 static const android = const System._('android'); | |
843 static const fuchsia = const System._('fuchsia'); | |
844 static const linux = const System._('linux'); | |
845 static const macos = const System._('macos'); | |
846 static const windows = const System._('windows'); | |
847 | |
848 static final List<String> names = _all.keys.toList(); | |
849 | |
850 static final _all = new Map<String, System>.fromIterable( | |
851 [android, fuchsia, linux, macos, windows], | |
852 key: (System system) => system.name); | |
853 | |
854 static System find(String name) { | |
855 var system = _all[name]; | |
856 if (system != null) return system; | |
857 | |
858 throw new ArgumentError('Unknown operating system "$name".'); | |
859 } | |
860 | |
861 final String name; | |
862 | |
863 const System._(this.name); | |
864 | |
865 /// The root directory name for build outputs on this system. | |
866 String get outputDirectory { | |
867 switch (this) { | |
868 case android: | |
869 case fuchsia: | |
870 case linux: | |
871 case windows: | |
872 return 'out/'; | |
873 | |
874 case macos: | |
875 return 'xcodebuild/'; | |
876 } | |
877 | |
878 throw "unreachable"; | |
879 } | |
880 | |
881 String toString() => "System($name)"; | |
882 } | |
OLD | NEW |