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

Side by Side Diff: tools/testing/dart/compiler_configuration.dart

Issue 2954113002: Rebased simplify CompilerConfiguration (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | no next file » | 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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'command.dart'; 7 import 'command.dart';
8 import 'configuration.dart'; 8 import 'configuration.dart';
9 import 'path.dart'; 9 import 'path.dart';
10 import 'runtime_configuration.dart'; 10 import 'runtime_configuration.dart';
11 import 'test_suite.dart'; 11 import 'test_suite.dart';
12 import 'utils.dart'; 12 import 'utils.dart';
13 13
14 List<String> replaceDartFileWith(List<String> list, String replacement) { 14 List<String> _replaceDartFiles(List<String> list, String replacement) {
15 var copy = new List<String>.from(list); 15 return list
16 for (var i = 0; i < copy.length; i++) { 16 .map((file) => file.endsWith(".dart") ? replacement : file)
17 if (copy[i].endsWith(".dart")) { 17 .toList();
18 copy[i] = replacement; 18 }
19 } 19
20 } 20 Uri _nativeDirectoryToUri(String nativePath) {
21 return copy; 21 var uri = new Uri.file(nativePath);
Bill Hesse 2017/06/23 12:01:35 New Uri.directory(nativePath) does what we are doi
Bill Hesse 2017/06/23 12:06:42 Done.
22 var path = uri.path;
23 return (path == '' || path.endsWith('/')) ? uri : Uri.parse('$uri/');
22 } 24 }
23 25
24 /// Grouping of a command with its expected result. 26 /// Grouping of a command with its expected result.
25 class CommandArtifact { 27 class CommandArtifact {
26 final List<Command> commands; 28 final List<Command> commands;
27 29
28 /// Expected result of running [command]. 30 /// Expected result of running [command].
29 final String filename; 31 final String filename;
30 32
31 /// MIME type of [filename]. 33 /// MIME type of [filename].
32 final String mimeType; 34 final String mimeType;
33 35
34 CommandArtifact(this.commands, this.filename, this.mimeType); 36 CommandArtifact(this.commands, this.filename, this.mimeType);
35 } 37 }
36 38
37 Uri nativeDirectoryToUri(String nativePath) { 39 abstract class CompilerConfiguration {
38 Uri uri = new Uri.file(nativePath); 40 final Configuration _configuration;
39 String path = uri.path;
40 return (path == '' || path.endsWith('/')) ? uri : Uri.parse('$uri/');
41 }
42 41
43 abstract class CompilerConfiguration { 42 bool get _isDebug => _configuration.mode.isDebug;
44 final bool isDebug; 43 bool get _isChecked => _configuration.isChecked;
45 final bool isChecked; 44 bool get _isStrong => _configuration.isStrong;
46 final bool isStrong; 45 bool get _isHostChecked => _configuration.isHostChecked;
47 final bool isHostChecked; 46 bool get _useSdk => _configuration.useSdk;
48 final bool useSdk;
49 47
50 /// Only some subclasses support this check, but we statically allow calling 48 /// Only some subclasses support this check, but we statically allow calling
51 /// it on [CompilerConfiguration]. 49 /// it on [CompilerConfiguration].
52 bool get useDfe { 50 bool get useDfe {
53 throw new UnsupportedError("This compiler does not support DFE."); 51 throw new UnsupportedError("This compiler does not support DFE.");
54 } 52 }
55 53
56 factory CompilerConfiguration(Configuration configuration) { 54 factory CompilerConfiguration(Configuration configuration) {
57 switch (configuration.compiler) { 55 switch (configuration.compiler) {
58 case Compiler.dart2analyzer: 56 case Compiler.dart2analyzer:
59 return new AnalyzerCompilerConfiguration( 57 return new AnalyzerCompilerConfiguration(configuration);
60 isDebug: configuration.mode.isDebug,
61 isChecked: configuration.isChecked,
62 isStrong: configuration.isStrong,
63 isHostChecked: configuration.isHostChecked,
64 useSdk: configuration.useSdk);
65 58
66 case Compiler.dart2js: 59 case Compiler.dart2js:
67 return new Dart2jsCompilerConfiguration( 60 return new Dart2jsCompilerConfiguration(configuration);
68 isDebug: configuration.mode.isDebug, 61
69 isChecked: configuration.isChecked, 62 case Compiler.dartdevc:
70 isHostChecked: configuration.isHostChecked, 63 return new DartdevcCompilerConfiguration(configuration);
71 useSdk: configuration.useSdk,
72 isCsp: configuration.isCsp,
73 useFastStartup: configuration.useFastStartup,
74 useKernel: configuration.useDart2JSWithKernel,
75 extraDart2jsOptions: configuration.dart2jsOptions);
76 64
77 case Compiler.dartdevc: 65 case Compiler.dartdevc:
Bill Hesse 2017/06/23 12:01:35 This needs deleting. Bad merge.
Bill Hesse 2017/06/23 12:06:42 Done.
78 return new DartdevcCompilerConfiguration( 66 return new DartdevcCompilerConfiguration(
79 isDebug: configuration.mode.isDebug, 67 isDebug: configuration.mode.isDebug,
80 isChecked: configuration.isChecked, 68 isChecked: configuration.isChecked,
81 isHostChecked: configuration.isHostChecked); 69 isHostChecked: configuration.isHostChecked);
82 break; 70 break;
83 71
84 case Compiler.appJit: 72 case Compiler.appJit:
85 return new AppJitCompilerConfiguration( 73 return new AppJitCompilerConfiguration(configuration);
86 isDebug: configuration.mode.isDebug,
87 isChecked: configuration.isChecked);
88 74
89 case Compiler.precompiler: 75 case Compiler.precompiler:
90 return new PrecompilerCompilerConfiguration( 76 return new PrecompilerCompilerConfiguration(configuration);
91 isDebug: configuration.mode.isDebug,
92 isChecked: configuration.isChecked,
93 arch: configuration.architecture,
94 useBlobs: configuration.useBlobs,
95 isAndroid: configuration.system == System.android);
96 77
97 case Compiler.dartk: 78 case Compiler.dartk:
98 return new NoneCompilerConfiguration( 79 return new NoneCompilerConfiguration(configuration, useDfe: true);
99 isDebug: configuration.mode.isDebug,
100 isChecked: configuration.isChecked,
101 isHostChecked: configuration.isHostChecked,
102 useSdk: configuration.useSdk,
103 hotReload: configuration.hotReload,
104 hotReloadRollback: configuration.hotReloadRollback,
105 useDfe: true);
106 80
107 case Compiler.dartkp: 81 case Compiler.dartkp:
108 return new PrecompilerCompilerConfiguration( 82 return new PrecompilerCompilerConfiguration(configuration,
109 isDebug: configuration.mode.isDebug,
110 isChecked: configuration.isChecked,
111 arch: configuration.architecture,
112 useBlobs: configuration.useBlobs,
113 isAndroid: configuration.system == System.android,
114 useDfe: true); 83 useDfe: true);
115 84
116 case Compiler.none: 85 case Compiler.none:
117 return new NoneCompilerConfiguration( 86 return new NoneCompilerConfiguration(configuration);
118 isDebug: configuration.mode.isDebug,
119 isChecked: configuration.isChecked,
120 isHostChecked: configuration.isHostChecked,
121 useSdk: configuration.useSdk,
122 hotReload: configuration.hotReload,
123 hotReloadRollback: configuration.hotReloadRollback);
124 } 87 }
125 88
126 throw "unreachable"; 89 throw "unreachable";
127 } 90 }
128 91
129 CompilerConfiguration._subclass( 92 CompilerConfiguration._subclass(this._configuration);
130 {this.isDebug: false,
131 this.isChecked: false,
132 this.isStrong: false,
133 this.isHostChecked: false,
134 this.useSdk: false});
135 93
136 /// A multiplier used to give tests longer time to run. 94 /// A multiplier used to give tests longer time to run.
137 int get timeoutMultiplier => 1; 95 int get timeoutMultiplier => 1;
138 96
139 // TODO(ahe): It shouldn't be necessary to pass [buildDir] to any of these 97 // TODO(ahe): It shouldn't be necessary to pass [buildDir] to any of these
140 // functions. It is fixed for a given configuration. 98 // functions. It is fixed for a given configuration.
141 String computeCompilerPath(String buildDir) { 99 String computeCompilerPath(String buildDir) {
142 throw "Unknown compiler for: $runtimeType"; 100 throw "Unknown compiler for: $runtimeType";
143 } 101 }
144 102
145 bool get hasCompiler => true; 103 bool get hasCompiler => true;
146 104
147 String get executableScriptSuffix => Platform.isWindows ? '.bat' : ''; 105 String get executableScriptSuffix => Platform.isWindows ? '.bat' : '';
148 106
149 // TODO(ahe): Remove this.
150 bool get isCsp => false;
151
152 List<Uri> bootstrapDependencies(String buildDir) => const <Uri>[]; 107 List<Uri> bootstrapDependencies(String buildDir) => const <Uri>[];
153 108
154 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, 109 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
155 List<String> arguments, Map<String, String> environmentOverrides) { 110 List<String> arguments, Map<String, String> environmentOverrides) {
156 return new CommandArtifact([], null, null); 111 return new CommandArtifact([], null, null);
157 } 112 }
158 113
159 List<String> computeCompilerArguments( 114 List<String> computeCompilerArguments(
160 List<String> vmOptions, List<String> sharedOptions, List<String> args) { 115 List<String> vmOptions, List<String> sharedOptions, List<String> args) {
161 return sharedOptions.toList()..addAll(args); 116 return sharedOptions.toList()..addAll(args);
162 } 117 }
163 118
164 List<String> computeRuntimeArguments( 119 List<String> computeRuntimeArguments(
165 RuntimeConfiguration runtimeConfiguration, 120 RuntimeConfiguration runtimeConfiguration,
166 String buildDir, 121 String buildDir,
167 TestInformation info, 122 TestInformation info,
168 List<String> vmOptions, 123 List<String> vmOptions,
169 List<String> sharedOptions, 124 List<String> sharedOptions,
170 List<String> originalArguments, 125 List<String> originalArguments,
171 CommandArtifact artifact) { 126 CommandArtifact artifact) {
172 return [artifact.filename]; 127 return [artifact.filename];
173 } 128 }
174 } 129 }
175 130
176 /// The "none" compiler. 131 /// The "none" compiler.
177 class NoneCompilerConfiguration extends CompilerConfiguration { 132 class NoneCompilerConfiguration extends CompilerConfiguration {
178 final bool hotReload;
179 final bool hotReloadRollback;
180 final bool useDfe; 133 final bool useDfe;
181 134
182 NoneCompilerConfiguration( 135 NoneCompilerConfiguration(Configuration configuration, {this.useDfe: false})
183 {bool isDebug, 136 : super._subclass(configuration);
184 bool isChecked,
185 bool isHostChecked,
186 bool useSdk,
187 bool this.hotReload,
188 bool this.hotReloadRollback,
189 this.useDfe: false})
190 : super._subclass(
191 isDebug: isDebug,
192 isChecked: isChecked,
193 isHostChecked: isHostChecked,
194 useSdk: useSdk);
195 137
196 bool get hasCompiler => false; 138 bool get hasCompiler => false;
197 139
198 List<String> computeRuntimeArguments( 140 List<String> computeRuntimeArguments(
199 RuntimeConfiguration runtimeConfiguration, 141 RuntimeConfiguration runtimeConfiguration,
200 String buildDir, 142 String buildDir,
201 TestInformation info, 143 TestInformation info,
202 List<String> vmOptions, 144 List<String> vmOptions,
203 List<String> sharedOptions, 145 List<String> sharedOptions,
204 List<String> originalArguments, 146 List<String> originalArguments,
205 CommandArtifact artifact) { 147 CommandArtifact artifact) {
206 List<String> args = []; 148 var args = <String>[];
207 if (useDfe) { 149 if (useDfe) {
208 args.add('--dfe=${buildDir}/gen/kernel-service.dart.snapshot'); 150 args.add('--dfe=${buildDir}/gen/kernel-service.dart.snapshot');
209 args.add('--kernel-binaries=${buildDir}/patched_sdk'); 151 args.add('--kernel-binaries=${buildDir}/patched_sdk');
210 } 152 }
211 if (isChecked) { 153 if (_isChecked) {
212 args.add('--enable_asserts'); 154 args.add('--enable_asserts');
213 args.add('--enable_type_checks'); 155 args.add('--enable_type_checks');
214 } 156 }
215 if (hotReload) { 157 if (_configuration.hotReload) {
216 args.add('--hot-reload-test-mode'); 158 args.add('--hot-reload-test-mode');
217 } else if (hotReloadRollback) { 159 } else if (_configuration.hotReloadRollback) {
218 args.add('--hot-reload-rollback-test-mode'); 160 args.add('--hot-reload-rollback-test-mode');
219 } 161 }
220 return args 162 return args
221 ..addAll(vmOptions) 163 ..addAll(vmOptions)
222 ..addAll(sharedOptions) 164 ..addAll(sharedOptions)
223 ..addAll(originalArguments); 165 ..addAll(originalArguments);
224 } 166 }
225 } 167 }
226 168
227 /// The "dartk" compiler.
228 class DartKCompilerConfiguration extends CompilerConfiguration {
229 final bool verify, strong, treeShake;
230
231 DartKCompilerConfiguration(
232 {bool isChecked,
233 bool isHostChecked,
234 bool useSdk,
235 this.verify,
236 this.strong,
237 this.treeShake})
238 : super._subclass(
239 isChecked: isChecked, isHostChecked: isHostChecked, useSdk: useSdk);
240
241 @override
242 String computeCompilerPath(String buildDir) {
243 return 'tools/dartk_wrappers/dartk$executableScriptSuffix';
244 }
245
246 Command computeCompilationCommand(String outputFileName, String buildDir,
247 List<String> arguments, Map<String, String> environmentOverrides) {
248 Iterable<String> extraArguments = [
249 '--sdk',
250 '$buildDir/patched_sdk',
251 '--link',
252 '--target=vm',
253 treeShake ? '--tree-shake' : null,
254 strong ? '--strong' : null,
255 verify ? '--verify-ir' : null,
256 '--out',
257 outputFileName
258 ].where((x) => x != null);
259 return Command.kernelCompilation(
260 outputFileName,
261 true,
262 bootstrapDependencies(buildDir),
263 computeCompilerPath(buildDir),
264 <String>[]..addAll(arguments)..addAll(extraArguments),
265 environmentOverrides);
266 }
267
268 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
269 List<String> arguments, Map<String, String> environmentOverrides) {
270 return new CommandArtifact([
271 computeCompilationCommand(
272 '$tempDir/out.dill', buildDir, arguments, environmentOverrides)
273 ], '$tempDir/out.dill', 'application/dart');
274 }
275
276 List<String> computeRuntimeArguments(
277 RuntimeConfiguration runtimeConfiguration,
278 String buildDir,
279 TestInformation info,
280 List<String> vmOptions,
281 List<String> sharedOptions,
282 List<String> originalArguments,
283 CommandArtifact artifact) {
284 List<String> args = [];
285 if (isChecked) {
286 args.add('--enable_asserts');
287 args.add('--enable_type_checks');
288 }
289
290 var newOriginalArguments =
291 replaceDartFileWith(originalArguments, artifact.filename);
292
293 return args
294 ..addAll(vmOptions)
295 ..addAll(sharedOptions)
296 ..addAll(newOriginalArguments);
297 }
298 }
299
300 typedef List<String> CompilerArgumentsFunction( 169 typedef List<String> CompilerArgumentsFunction(
301 List<String> globalArguments, String previousCompilerOutput); 170 List<String> globalArguments, String previousCompilerOutput);
302 171
303 class PipelineCommand { 172 class PipelineCommand {
304 final CompilerConfiguration compilerConfiguration; 173 final CompilerConfiguration compilerConfiguration;
305 final CompilerArgumentsFunction _argumentsFunction; 174 final CompilerArgumentsFunction _argumentsFunction;
306 175
307 PipelineCommand._(this.compilerConfiguration, this._argumentsFunction); 176 PipelineCommand._(this.compilerConfiguration, this._argumentsFunction);
308 177
309 factory PipelineCommand.runWithGlobalArguments(CompilerConfiguration conf) { 178 factory PipelineCommand.runWithGlobalArguments(
310 return new PipelineCommand._(conf, 179 CompilerConfiguration configuration) {
180 return new PipelineCommand._(configuration,
311 (List<String> globalArguments, String previousOutput) { 181 (List<String> globalArguments, String previousOutput) {
312 assert(previousOutput == null); 182 assert(previousOutput == null);
313 return globalArguments; 183 return globalArguments;
314 }); 184 });
315 } 185 }
316 186
317 factory PipelineCommand.runWithDartOrKernelFile(CompilerConfiguration conf) { 187 factory PipelineCommand.runWithDartOrKernelFile(
318 return new PipelineCommand._(conf, 188 CompilerConfiguration configuration) {
189 return new PipelineCommand._(configuration,
319 (List<String> globalArguments, String previousOutput) { 190 (List<String> globalArguments, String previousOutput) {
320 var filtered = globalArguments 191 var filtered = globalArguments
321 .where( 192 .where((name) => name.endsWith('.dart') || name.endsWith('.dill'))
322 (String name) => name.endsWith('.dart') || name.endsWith('.dill'))
323 .toList(); 193 .toList();
324 assert(filtered.length == 1); 194 assert(filtered.length == 1);
325 return filtered; 195 return filtered;
326 }); 196 });
327 } 197 }
328 198
329 factory PipelineCommand.runWithPreviousKernelOutput( 199 factory PipelineCommand.runWithPreviousKernelOutput(
330 CompilerConfiguration conf) { 200 CompilerConfiguration configuration) {
331 return new PipelineCommand._(conf, 201 return new PipelineCommand._(configuration,
332 (List<String> globalArguments, String previousOutput) { 202 (List<String> globalArguments, String previousOutput) {
333 assert(previousOutput.endsWith('.dill')); 203 assert(previousOutput.endsWith('.dill'));
334 return replaceDartFileWith(globalArguments, previousOutput); 204 return _replaceDartFiles(globalArguments, previousOutput);
335 }); 205 });
336 } 206 }
337 207
338 List<String> extractArguments( 208 List<String> extractArguments(
339 List<String> globalArguments, String previousOutput) { 209 List<String> globalArguments, String previousOutput) {
340 return _argumentsFunction(globalArguments, previousOutput); 210 return _argumentsFunction(globalArguments, previousOutput);
341 } 211 }
342 } 212 }
343 213
344 class ComposedCompilerConfiguration extends CompilerConfiguration { 214 class ComposedCompilerConfiguration extends CompilerConfiguration {
345 final List<PipelineCommand> pipelineCommands; 215 final List<PipelineCommand> pipelineCommands;
346 216
347 ComposedCompilerConfiguration(this.pipelineCommands) : super._subclass(); 217 ComposedCompilerConfiguration(
218 Configuration configuration, this.pipelineCommands)
219 : super._subclass(configuration);
348 220
349 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, 221 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
350 List<String> globalArguments, Map<String, String> environmentOverrides) { 222 List<String> globalArguments, Map<String, String> environmentOverrides) {
351 List<Command> allCommands = []; 223 var allCommands = <Command>[];
352 224
353 // The first compilation command is as usual. 225 // The first compilation command is as usual.
354 var arguments = pipelineCommands[0].extractArguments(globalArguments, null); 226 var arguments = pipelineCommands[0].extractArguments(globalArguments, null);
355 CommandArtifact artifact = pipelineCommands[0] 227 CommandArtifact artifact = pipelineCommands[0]
356 .compilerConfiguration 228 .compilerConfiguration
357 .computeCompilationArtifact( 229 .computeCompilationArtifact(
358 buildDir, tempDir, arguments, environmentOverrides); 230 buildDir, tempDir, arguments, environmentOverrides);
359 allCommands.addAll(artifact.commands); 231 allCommands.addAll(artifact.commands);
360 232
361 // The following compilation commands are based on the output of the 233 // The following compilation commands are based on the output of the
362 // previous one. 234 // previous one.
363 for (int i = 1; i < pipelineCommands.length; i++) { 235 for (var i = 1; i < pipelineCommands.length; i++) {
364 PipelineCommand pc = pipelineCommands[i]; 236 PipelineCommand command = pipelineCommands[i];
365 237
366 arguments = pc.extractArguments(globalArguments, artifact.filename); 238 arguments = command.extractArguments(globalArguments, artifact.filename);
367 artifact = pc.compilerConfiguration.computeCompilationArtifact( 239 artifact = command.compilerConfiguration.computeCompilationArtifact(
368 buildDir, tempDir, arguments, environmentOverrides); 240 buildDir, tempDir, arguments, environmentOverrides);
369 241
370 allCommands.addAll(artifact.commands); 242 allCommands.addAll(artifact.commands);
371 } 243 }
372 244
373 return new CommandArtifact( 245 return new CommandArtifact(
374 allCommands, artifact.filename, artifact.mimeType); 246 allCommands, artifact.filename, artifact.mimeType);
375 } 247 }
376 248
377 List<String> computeCompilerArguments(vmOptions, sharedOptions, args) { 249 List<String> computeCompilerArguments(vmOptions, sharedOptions, args) {
(...skipping 14 matching lines...) Expand all
392 pipelineCommands.last.compilerConfiguration; 264 pipelineCommands.last.compilerConfiguration;
393 return lastCompilerConfiguration.computeRuntimeArguments( 265 return lastCompilerConfiguration.computeRuntimeArguments(
394 runtimeConfiguration, 266 runtimeConfiguration,
395 buildDir, 267 buildDir,
396 info, 268 info,
397 vmOptions, 269 vmOptions,
398 sharedOptions, 270 sharedOptions,
399 originalArguments, 271 originalArguments,
400 artifact); 272 artifact);
401 } 273 }
402
403 static ComposedCompilerConfiguration createDartKPConfiguration(
404 {bool isChecked,
405 bool isHostChecked,
406 Architecture arch,
407 bool useBlobs,
408 bool isAndroid,
409 bool useSdk,
410 bool verify,
411 bool strong,
412 bool treeShake}) {
413 return new ComposedCompilerConfiguration([
414 // Compile with dartk.
415 new PipelineCommand.runWithGlobalArguments(new DartKCompilerConfiguration(
416 isChecked: isChecked,
417 isHostChecked: isHostChecked,
418 useSdk: useSdk,
419 verify: verify,
420 strong: strong,
421 treeShake: treeShake)),
422
423 // Run the normal precompiler.
424 new PipelineCommand.runWithPreviousKernelOutput(
425 new PrecompilerCompilerConfiguration(
426 isChecked: isChecked,
427 arch: arch,
428 useBlobs: useBlobs,
429 isAndroid: isAndroid))
430 ]);
431 }
432
433 static ComposedCompilerConfiguration createDartKConfiguration(
434 {bool isChecked,
435 bool isHostChecked,
436 bool useSdk,
437 bool verify,
438 bool strong,
439 bool treeShake}) {
440 return new ComposedCompilerConfiguration([
441 // Compile with dartk.
442 new PipelineCommand.runWithGlobalArguments(new DartKCompilerConfiguration(
443 isChecked: isChecked,
444 isHostChecked: isHostChecked,
445 useSdk: useSdk,
446 verify: verify,
447 strong: strong,
448 treeShake: treeShake))
449 ]);
450 }
451 } 274 }
452 275
453 /// Common configuration for dart2js-based tools, such as, dart2js 276 /// Common configuration for dart2js-based tools, such as, dart2js
454 class Dart2xCompilerConfiguration extends CompilerConfiguration { 277 class Dart2xCompilerConfiguration extends CompilerConfiguration {
455 final String moniker; 278 final String moniker;
456 static Map<String, List<Uri>> _bootstrapDependenciesCache = 279 static Map<String, List<Uri>> _bootstrapDependenciesCache = {};
457 new Map<String, List<Uri>>();
458 280
459 Dart2xCompilerConfiguration(this.moniker, 281 Dart2xCompilerConfiguration(this.moniker, Configuration configuration)
460 {bool isDebug, bool isChecked, bool isHostChecked, bool useSdk}) 282 : super._subclass(configuration);
461 : super._subclass(
462 isDebug: isDebug,
463 isChecked: isChecked,
464 isHostChecked: isHostChecked,
465 useSdk: useSdk);
466 283
467 String computeCompilerPath(String buildDir) { 284 String computeCompilerPath(String buildDir) {
468 var prefix = 'sdk/bin'; 285 var prefix = 'sdk/bin';
469 String suffix = executableScriptSuffix; 286 var suffix = executableScriptSuffix;
470 if (isHostChecked) { 287
288 if (_isHostChecked) {
471 // The script dart2js_developer is not included in the 289 // The script dart2js_developer is not included in the
472 // shipped SDK, that is the script is not installed in 290 // shipped SDK, that is the script is not installed in
473 // "$buildDir/dart-sdk/bin/" 291 // "$buildDir/dart-sdk/bin/"
474 return '$prefix/dart2js_developer$suffix'; 292 return '$prefix/dart2js_developer$suffix';
475 } else {
476 if (useSdk) {
477 prefix = '$buildDir/dart-sdk/bin';
478 }
479 return '$prefix/dart2js$suffix';
480 } 293 }
294
295 if (_useSdk) {
296 prefix = '$buildDir/dart-sdk/bin';
297 }
298 return '$prefix/dart2js$suffix';
481 } 299 }
482 300
483 Command computeCompilationCommand(String outputFileName, String buildDir, 301 Command computeCompilationCommand(String outputFileName, String buildDir,
484 List<String> arguments, Map<String, String> environmentOverrides) { 302 List<String> arguments, Map<String, String> environmentOverrides) {
485 arguments = arguments.toList(); 303 arguments = arguments.toList();
486 arguments.add('--out=$outputFileName'); 304 arguments.add('--out=$outputFileName');
487 305
488 return Command.compilation( 306 return Command.compilation(
489 moniker, 307 moniker,
490 outputFileName, 308 outputFileName,
491 bootstrapDependencies(buildDir), 309 bootstrapDependencies(buildDir),
492 computeCompilerPath(buildDir), 310 computeCompilerPath(buildDir),
493 arguments, 311 arguments,
494 environmentOverrides, 312 environmentOverrides,
495 alwaysCompile: !useSdk); 313 alwaysCompile: !_useSdk);
496 } 314 }
497 315
498 List<Uri> bootstrapDependencies(String buildDir) { 316 List<Uri> bootstrapDependencies(String buildDir) {
499 if (!useSdk) return const <Uri>[]; 317 if (!_useSdk) return const <Uri>[];
500 return _bootstrapDependenciesCache.putIfAbsent( 318 return _bootstrapDependenciesCache.putIfAbsent(
501 buildDir, 319 buildDir,
502 () => [ 320 () => [
503 Uri.base 321 Uri.base
504 .resolveUri(nativeDirectoryToUri(buildDir)) 322 .resolveUri(_nativeDirectoryToUri(buildDir))
505 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot') 323 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot')
506 ]); 324 ]);
507 } 325 }
508 } 326 }
509 327
510 /// Configuration for dart2js compiler. 328 /// Configuration for dart2js compiler.
511 class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration { 329 class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration {
512 final bool isCsp; 330 Dart2jsCompilerConfiguration(Configuration configuration)
513 final bool useFastStartup; 331 : super('dart2js', configuration);
514 final bool useKernel;
515 final List<String> extraDart2jsOptions;
516
517 Dart2jsCompilerConfiguration(
518 {bool isDebug,
519 bool isChecked,
520 bool isHostChecked,
521 bool useSdk,
522 bool this.isCsp,
523 bool this.useFastStartup,
524 this.useKernel,
525 this.extraDart2jsOptions})
526 : super('dart2js',
527 isDebug: isDebug,
528 isChecked: isChecked,
529 isHostChecked: isHostChecked,
530 useSdk: useSdk);
531 332
532 int get timeoutMultiplier { 333 int get timeoutMultiplier {
533 var multiplier = 1; 334 var multiplier = 1;
534 if (isDebug) multiplier *= 4; 335 if (_isDebug) multiplier *= 4;
535 if (isChecked) multiplier *= 2; 336 if (_isChecked) multiplier *= 2;
536 if (isHostChecked) multiplier *= 16; 337 if (_isHostChecked) multiplier *= 16;
537 return multiplier; 338 return multiplier;
538 } 339 }
539 340
540 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, 341 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
541 List<String> arguments, Map<String, String> environmentOverrides) { 342 List<String> arguments, Map<String, String> environmentOverrides) {
542 var compilerArguments = arguments.toList()..addAll(extraDart2jsOptions); 343 var compilerArguments = arguments.toList()
344 ..addAll(_configuration.dart2jsOptions);
543 return new CommandArtifact([ 345 return new CommandArtifact([
544 computeCompilationCommand( 346 computeCompilationCommand(
545 '$tempDir/out.js', buildDir, compilerArguments, environmentOverrides) 347 '$tempDir/out.js', buildDir, compilerArguments, environmentOverrides)
546 ], '$tempDir/out.js', 'application/javascript'); 348 ], '$tempDir/out.js', 'application/javascript');
547 } 349 }
548 350
549 List<String> computeRuntimeArguments( 351 List<String> computeRuntimeArguments(
550 RuntimeConfiguration runtimeConfiguration, 352 RuntimeConfiguration runtimeConfiguration,
551 String buildDir, 353 String buildDir,
552 TestInformation info, 354 TestInformation info,
553 List<String> vmOptions, 355 List<String> vmOptions,
554 List<String> sharedOptions, 356 List<String> sharedOptions,
555 List<String> originalArguments, 357 List<String> originalArguments,
556 CommandArtifact artifact) { 358 CommandArtifact artifact) {
557 Uri sdk = useSdk 359 Uri sdk = _useSdk
558 ? nativeDirectoryToUri(buildDir).resolve('dart-sdk/') 360 ? _nativeDirectoryToUri(buildDir).resolve('dart-sdk/')
559 : nativeDirectoryToUri(TestUtils.dartDir.toNativePath()) 361 : _nativeDirectoryToUri(TestUtils.dartDir.toNativePath())
560 .resolve('sdk/'); 362 .resolve('sdk/');
561 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); 363 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/');
562 return runtimeConfiguration.dart2jsPreambles(preambleDir) 364 return runtimeConfiguration.dart2jsPreambles(preambleDir)
563 ..add(artifact.filename); 365 ..add(artifact.filename);
564 } 366 }
565 } 367 }
566 368
567 /// Configuration for dart2js compiler. 369 /// Configuration for dart2js compiler.
568 class DartdevcCompilerConfiguration extends CompilerConfiguration { 370 class DartdevcCompilerConfiguration extends CompilerConfiguration {
569 DartdevcCompilerConfiguration( 371 DartdevcCompilerConfiguration(Configuration configuration)
570 {bool isDebug, bool isChecked, bool isHostChecked}) 372 : super._subclass(configuration);
571 : super._subclass(
572 isDebug: isDebug,
573 isChecked: isChecked,
574 isHostChecked: isHostChecked,
575 useSdk: true);
576 373
577 String computeCompilerPath(String buildDir) { 374 String computeCompilerPath(String buildDir) {
578 return "$buildDir/dart-sdk/bin/dartdevc$executableScriptSuffix"; 375 var dir = _useSdk ? "$buildDir/dart-sdk" : "sdk";
376 return "$dir/bin/dartdevc$executableScriptSuffix";
579 } 377 }
580 378
581 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, 379 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
582 List<String> arguments, Map<String, String> environmentOverrides) { 380 List<String> arguments, Map<String, String> environmentOverrides) {
583 // TODO(rnystrom): There is a lot of overlap between this code and 381 // TODO(rnystrom): There is a lot of overlap between this code and
584 // _dartdevcCompileCommand() in test_suite.dart. This code path is only hit 382 // _dartdevcCompileCommand() in test_suite.dart. This code path is only hit
585 // when the test is expected to have a compile error. Consider refactoring 383 // when the test is expected to have a compile error. Consider refactoring
586 // to unify the two (and likewise for dart2js). 384 // to unify the two (and likewise for dart2js).
587 385
588 // TODO(rnystrom): Are there other arguments here that we need to keep? 386 // TODO(rnystrom): Are there other arguments here that we need to keep?
(...skipping 17 matching lines...) Expand all
606 computeCompilerPath(buildDir), 404 computeCompilerPath(buildDir),
607 compilerArguments, 405 compilerArguments,
608 environmentOverrides); 406 environmentOverrides);
609 407
610 return new CommandArtifact( 408 return new CommandArtifact(
611 [command], "$tempDir/out.js", "application/javascript"); 409 [command], "$tempDir/out.js", "application/javascript");
612 } 410 }
613 } 411 }
614 412
615 class PrecompilerCompilerConfiguration extends CompilerConfiguration { 413 class PrecompilerCompilerConfiguration extends CompilerConfiguration {
616 final Architecture arch;
617 final bool useBlobs;
618 final bool isAndroid;
619 final bool useDfe; 414 final bool useDfe;
620 415
621 PrecompilerCompilerConfiguration( 416 bool get _isAndroid => _configuration.system == System.android;
622 {bool isDebug, 417 bool get _isArm => _configuration.architecture == Architecture.arm;
623 bool isChecked, 418 bool get _isArm64 => _configuration.architecture == Architecture.arm64;
624 this.arch, 419
625 this.useBlobs, 420 PrecompilerCompilerConfiguration(Configuration configuration,
626 this.isAndroid, 421 {this.useDfe: false})
627 this.useDfe: false}) 422 : super._subclass(configuration);
628 : super._subclass(isDebug: isDebug, isChecked: isChecked);
629 423
630 int get timeoutMultiplier { 424 int get timeoutMultiplier {
631 var multiplier = 2; 425 var multiplier = 2;
632 if (isDebug) multiplier *= 4; 426 if (_isDebug) multiplier *= 4;
633 if (isChecked) multiplier *= 2; 427 if (_isChecked) multiplier *= 2;
634 return multiplier; 428 return multiplier;
635 } 429 }
636 430
637 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, 431 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
638 List<String> arguments, Map<String, String> environmentOverrides) { 432 List<String> arguments, Map<String, String> environmentOverrides) {
639 var commands = new List<Command>(); 433 var commands = [
640 commands.add(this.computeCompilationCommand( 434 computeCompilationCommand(
641 tempDir, buildDir, arguments, environmentOverrides)); 435 tempDir, buildDir, arguments, environmentOverrides)
642 if (!useBlobs) { 436 ];
643 commands.add(this.computeAssembleCommand( 437
438 if (!_configuration.useBlobs) {
439 commands.add(computeAssembleCommand(
644 tempDir, buildDir, arguments, environmentOverrides)); 440 tempDir, buildDir, arguments, environmentOverrides));
645 commands.add(this.computeRemoveAssemblyCommand( 441 commands.add(computeRemoveAssemblyCommand(
646 tempDir, buildDir, arguments, environmentOverrides)); 442 tempDir, buildDir, arguments, environmentOverrides));
647 } 443 }
444
648 return new CommandArtifact( 445 return new CommandArtifact(
649 commands, '$tempDir', 'application/dart-precompiled'); 446 commands, '$tempDir', 'application/dart-precompiled');
650 } 447 }
651 448
652 Command computeCompilationCommand(String tempDir, String buildDir, 449 Command computeCompilationCommand(String tempDir, String buildDir,
653 List<String> arguments, Map<String, String> environmentOverrides) { 450 List<String> arguments, Map<String, String> environmentOverrides) {
654 String exec; 451 String exec;
655 if (isAndroid) { 452 if (_isAndroid) {
656 if (arch == Architecture.arm) { 453 if (_isArm) {
657 exec = "$buildDir/clang_x86/dart_bootstrap"; 454 exec = "$buildDir/clang_x86/dart_bootstrap";
658 } else if (arch == Architecture.arm64) { 455 } else if (_configuration.architecture == Architecture.arm64) {
659 exec = "$buildDir/clang_x64/dart_bootstrap"; 456 exec = "$buildDir/clang_x64/dart_bootstrap";
660 } 457 }
661 } else { 458 } else {
662 exec = "$buildDir/dart_bootstrap"; 459 exec = "$buildDir/dart_bootstrap";
663 } 460 }
461
664 var args = <String>[]; 462 var args = <String>[];
665 if (useDfe) { 463 if (useDfe) {
666 args.add('--dfe=utils/kernel-service/kernel-service.dart'); 464 args.add('--dfe=utils/kernel-service/kernel-service.dart');
667 args.add('--kernel-binaries=${buildDir}/patched_sdk'); 465 args.add('--kernel-binaries=${buildDir}/patched_sdk');
668 } 466 }
467
669 args.add("--snapshot-kind=app-aot"); 468 args.add("--snapshot-kind=app-aot");
670 if (useBlobs) { 469 if (_configuration.useBlobs) {
671 args.add("--snapshot=$tempDir/out.aotsnapshot"); 470 args.add("--snapshot=$tempDir/out.aotsnapshot");
672 args.add("--use-blobs"); 471 args.add("--use-blobs");
673 } else { 472 } else {
674 args.add("--snapshot=$tempDir/out.S"); 473 args.add("--snapshot=$tempDir/out.S");
675 } 474 }
676 if (isAndroid && arch == Architecture.arm) { 475
476 if (_isAndroid && _isArm) {
677 args.add('--no-sim-use-hardfp'); 477 args.add('--no-sim-use-hardfp');
678 } 478 }
479
679 args.addAll(arguments); 480 args.addAll(arguments);
680 481
681 return Command.compilation('precompiler', tempDir, 482 return Command.compilation('precompiler', tempDir,
682 bootstrapDependencies(buildDir), exec, args, environmentOverrides, 483 bootstrapDependencies(buildDir), exec, args, environmentOverrides,
683 alwaysCompile: !useSdk); 484 alwaysCompile: !_useSdk);
684 } 485 }
685 486
686 Command computeAssembleCommand(String tempDir, String buildDir, 487 Command computeAssembleCommand(String tempDir, String buildDir,
687 List arguments, Map<String, String> environmentOverrides) { 488 List arguments, Map<String, String> environmentOverrides) {
688 String cc, shared, ldFlags; 489 String cc, shared, ldFlags;
689 if (isAndroid) { 490 if (_isAndroid) {
690 var ndk = "third_party/android_tools/ndk"; 491 var ndk = "third_party/android_tools/ndk";
691 String triple; 492 String triple;
692 if (arch == Architecture.arm) { 493 if (_isArm) {
693 triple = "arm-linux-androideabi"; 494 triple = "arm-linux-androideabi";
694 } else if (arch == Architecture.arm64) { 495 } else if (_isArm64) {
695 triple = "aarch64-linux-android"; 496 triple = "aarch64-linux-android";
696 } 497 }
697 String host; 498 String host;
698 if (Platform.isLinux) { 499 if (Platform.isLinux) {
699 host = "linux"; 500 host = "linux";
700 } else if (Platform.isMacOS) { 501 } else if (Platform.isMacOS) {
701 host = "darwin"; 502 host = "darwin";
702 } 503 }
703 cc = "$ndk/toolchains/$triple-4.9/prebuilt/$host-x86_64/bin/$triple-gcc"; 504 cc = "$ndk/toolchains/$triple-4.9/prebuilt/$host-x86_64/bin/$triple-gcc";
704 shared = '-shared'; 505 shared = '-shared';
705 } else if (Platform.isLinux) { 506 } else if (Platform.isLinux) {
706 cc = 'gcc'; 507 cc = 'gcc';
707 shared = '-shared'; 508 shared = '-shared';
708 } else if (Platform.isMacOS) { 509 } else if (Platform.isMacOS) {
709 cc = 'clang'; 510 cc = 'clang';
710 shared = '-dynamiclib'; 511 shared = '-dynamiclib';
711 // Tell Mac linker to give up generating eh_frame from dwarf. 512 // Tell Mac linker to give up generating eh_frame from dwarf.
712 ldFlags = '-Wl,-no_compact_unwind'; 513 ldFlags = '-Wl,-no_compact_unwind';
713 } else { 514 } else {
714 throw "Platform not supported: ${Platform.operatingSystem}"; 515 throw "Platform not supported: ${Platform.operatingSystem}";
715 } 516 }
716 517
717 String ccFlags; 518 String ccFlags;
718 switch (arch) { 519 switch (_configuration.architecture) {
719 case Architecture.x64: 520 case Architecture.x64:
720 case Architecture.simarm64: 521 case Architecture.simarm64:
721 ccFlags = "-m64"; 522 ccFlags = "-m64";
722 break; 523 break;
723 case Architecture.ia32: 524 case Architecture.ia32:
724 case Architecture.simarm: 525 case Architecture.simarm:
725 case Architecture.arm: 526 case Architecture.arm:
726 case Architecture.arm64: 527 case Architecture.arm64:
727 ccFlags = null; 528 ccFlags = null;
728 break; 529 break;
729 default: 530 default:
730 throw "Architecture not supported: ${arch.name}"; 531 throw "Architecture not supported: ${_configuration.architecture.name}";
731 } 532 }
732 533
733 var exec = cc; 534 var exec = cc;
734 var args = <String>[]; 535 var args = <String>[];
735 if (ccFlags != null) args.add(ccFlags); 536 if (ccFlags != null) args.add(ccFlags);
736 if (ldFlags != null) args.add(ldFlags); 537 if (ldFlags != null) args.add(ldFlags);
737 args.add(shared); 538 args.add(shared);
738 args.add('-nostdlib'); 539 args.add('-nostdlib');
739 args.add('-o'); 540 args.add('-o');
740 args.add('$tempDir/out.aotsnapshot'); 541 args.add('$tempDir/out.aotsnapshot');
741 args.add('$tempDir/out.S'); 542 args.add('$tempDir/out.S');
742 543
743 return Command.compilation('assemble', tempDir, 544 return Command.compilation('assemble', tempDir,
744 bootstrapDependencies(buildDir), exec, args, environmentOverrides, 545 bootstrapDependencies(buildDir), exec, args, environmentOverrides,
745 alwaysCompile: !useSdk); 546 alwaysCompile: !_useSdk);
746 } 547 }
747 548
748 // This step reduces the amount of space needed to run the precompilation 549 // This step reduces the amount of space needed to run the precompilation
749 // tests by 60%. 550 // tests by 60%.
750 Command computeRemoveAssemblyCommand(String tempDir, String buildDir, 551 Command computeRemoveAssemblyCommand(String tempDir, String buildDir,
751 List arguments, Map<String, String> environmentOverrides) { 552 List arguments, Map<String, String> environmentOverrides) {
752 var exec = 'rm'; 553 var exec = 'rm';
753 var args = ['$tempDir/out.S']; 554 var args = ['$tempDir/out.S'];
754 555
755 return Command.compilation('remove_assembly', tempDir, 556 return Command.compilation('remove_assembly', tempDir,
756 bootstrapDependencies(buildDir), exec, args, environmentOverrides, 557 bootstrapDependencies(buildDir), exec, args, environmentOverrides,
757 alwaysCompile: !useSdk); 558 alwaysCompile: !_useSdk);
758 } 559 }
759 560
760 List<String> filterVmOptions(List<String> vmOptions) { 561 List<String> filterVmOptions(List<String> vmOptions) {
761 var filtered = vmOptions.toList(); 562 var filtered = vmOptions.toList();
762 filtered.removeWhere( 563 filtered.removeWhere(
763 (option) => option.startsWith("--optimization-counter-threshold")); 564 (option) => option.startsWith("--optimization-counter-threshold"));
764 filtered.removeWhere( 565 filtered.removeWhere(
765 (option) => option.startsWith("--optimization_counter_threshold")); 566 (option) => option.startsWith("--optimization_counter_threshold"));
766 return filtered; 567 return filtered;
767 } 568 }
768 569
769 List<String> computeCompilerArguments( 570 List<String> computeCompilerArguments(
770 vmOptions, sharedOptions, originalArguments) { 571 vmOptions, sharedOptions, originalArguments) {
771 List<String> args = []; 572 List<String> args = [];
772 if (isChecked) { 573 if (_isChecked) {
773 args.add('--enable_asserts'); 574 args.add('--enable_asserts');
774 args.add('--enable_type_checks'); 575 args.add('--enable_type_checks');
775 } 576 }
776 return args 577 return args
777 ..addAll(filterVmOptions(vmOptions)) 578 ..addAll(filterVmOptions(vmOptions))
778 ..addAll(sharedOptions) 579 ..addAll(sharedOptions)
779 ..addAll(originalArguments); 580 ..addAll(originalArguments);
780 } 581 }
781 582
782 List<String> computeRuntimeArguments( 583 List<String> computeRuntimeArguments(
783 RuntimeConfiguration runtimeConfiguration, 584 RuntimeConfiguration runtimeConfiguration,
784 String buildDir, 585 String buildDir,
785 TestInformation info, 586 TestInformation info,
786 List<String> vmOptions, 587 List<String> vmOptions,
787 List<String> sharedOptions, 588 List<String> sharedOptions,
788 List<String> originalArguments, 589 List<String> originalArguments,
789 CommandArtifact artifact) { 590 CommandArtifact artifact) {
790 List<String> args = []; 591 var args = <String>[];
791 if (isChecked) { 592 if (_isChecked) {
792 args.add('--enable_asserts'); 593 args.add('--enable_asserts');
793 args.add('--enable_type_checks'); 594 args.add('--enable_type_checks');
794 } 595 }
795 596
796 var dir = artifact.filename; 597 var dir = artifact.filename;
797 if (runtimeConfiguration is DartPrecompiledAdbRuntimeConfiguration) { 598 if (runtimeConfiguration is DartPrecompiledAdbRuntimeConfiguration) {
798 // On android the precompiled snapshot will be pushed to a different 599 // On android the precompiled snapshot will be pushed to a different
799 // directory on the device, use that one instead. 600 // directory on the device, use that one instead.
800 dir = DartPrecompiledAdbRuntimeConfiguration.DeviceTestDir; 601 dir = DartPrecompiledAdbRuntimeConfiguration.DeviceTestDir;
801 } 602 }
802 originalArguments = 603 originalArguments =
803 replaceDartFileWith(originalArguments, "$dir/out.aotsnapshot"); 604 _replaceDartFiles(originalArguments, "$dir/out.aotsnapshot");
804 605
805 return args 606 return args
806 ..addAll(vmOptions) 607 ..addAll(vmOptions)
807 ..addAll(sharedOptions) 608 ..addAll(sharedOptions)
808 ..addAll(originalArguments); 609 ..addAll(originalArguments);
809 } 610 }
810 } 611 }
811 612
812 class AppJitCompilerConfiguration extends CompilerConfiguration { 613 class AppJitCompilerConfiguration extends CompilerConfiguration {
813 AppJitCompilerConfiguration({bool isDebug, bool isChecked}) 614 AppJitCompilerConfiguration(Configuration configuration)
814 : super._subclass(isDebug: isDebug, isChecked: isChecked); 615 : super._subclass(configuration);
815 616
816 int get timeoutMultiplier { 617 int get timeoutMultiplier {
817 var multiplier = 1; 618 var multiplier = 1;
818 if (isDebug) multiplier *= 2; 619 if (_isDebug) multiplier *= 2;
819 if (isChecked) multiplier *= 2; 620 if (_isChecked) multiplier *= 2;
820 return multiplier; 621 return multiplier;
821 } 622 }
822 623
823 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, 624 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
824 List<String> arguments, Map<String, String> environmentOverrides) { 625 List<String> arguments, Map<String, String> environmentOverrides) {
825 var snapshot = "$tempDir/out.jitsnapshot"; 626 var snapshot = "$tempDir/out.jitsnapshot";
826 return new CommandArtifact([ 627 return new CommandArtifact([
827 computeCompilationCommand( 628 computeCompilationCommand(
828 tempDir, buildDir, arguments, environmentOverrides) 629 tempDir, buildDir, arguments, environmentOverrides)
829 ], snapshot, 'application/dart-snapshot'); 630 ], snapshot, 'application/dart-snapshot');
830 } 631 }
831 632
832 Command computeCompilationCommand(String tempDir, String buildDir, 633 Command computeCompilationCommand(String tempDir, String buildDir,
833 List<String> arguments, Map<String, String> environmentOverrides) { 634 List<String> arguments, Map<String, String> environmentOverrides) {
834 var exec = "$buildDir/dart"; 635 var exec = "$buildDir/dart";
835 var snapshot = "$tempDir/out.jitsnapshot"; 636 var snapshot = "$tempDir/out.jitsnapshot";
836 var args = ["--snapshot=$snapshot", "--snapshot-kind=app-jit"]; 637 var args = ["--snapshot=$snapshot", "--snapshot-kind=app-jit"];
837 args.addAll(arguments); 638 args.addAll(arguments);
838 639
839 return Command.compilation('app_jit', tempDir, 640 return Command.compilation('app_jit', tempDir,
840 bootstrapDependencies(buildDir), exec, args, environmentOverrides, 641 bootstrapDependencies(buildDir), exec, args, environmentOverrides,
841 alwaysCompile: !useSdk); 642 alwaysCompile: !_useSdk);
842 } 643 }
843 644
844 List<String> computeCompilerArguments( 645 List<String> computeCompilerArguments(
845 vmOptions, sharedOptions, originalArguments) { 646 vmOptions, sharedOptions, originalArguments) {
846 var args = <String>[]; 647 var args = <String>[];
847 if (isChecked) { 648 if (_isChecked) {
848 args.add('--enable_asserts'); 649 args.add('--enable_asserts');
849 args.add('--enable_type_checks'); 650 args.add('--enable_type_checks');
850 } 651 }
851 return args 652 return args
852 ..addAll(vmOptions) 653 ..addAll(vmOptions)
853 ..addAll(sharedOptions) 654 ..addAll(sharedOptions)
854 ..addAll(originalArguments); 655 ..addAll(originalArguments);
855 } 656 }
856 657
857 List<String> computeRuntimeArguments( 658 List<String> computeRuntimeArguments(
858 RuntimeConfiguration runtimeConfiguration, 659 RuntimeConfiguration runtimeConfiguration,
859 String buildDir, 660 String buildDir,
860 TestInformation info, 661 TestInformation info,
861 List<String> vmOptions, 662 List<String> vmOptions,
862 List<String> sharedOptions, 663 List<String> sharedOptions,
863 List<String> originalArguments, 664 List<String> originalArguments,
864 CommandArtifact artifact) { 665 CommandArtifact artifact) {
865 List<String> args = []; 666 var args = <String>[];
866 if (isChecked) { 667 if (_isChecked) {
867 args.add('--enable_asserts'); 668 args.add('--enable_asserts');
868 args.add('--enable_type_checks'); 669 args.add('--enable_type_checks');
869 } 670 }
870 args..addAll(vmOptions)..addAll(sharedOptions)..addAll(originalArguments); 671 args..addAll(vmOptions)..addAll(sharedOptions)..addAll(originalArguments);
871 for (var i = 0; i < args.length; i++) { 672 for (var i = 0; i < args.length; i++) {
872 if (args[i].endsWith(".dart")) { 673 if (args[i].endsWith(".dart")) {
873 args[i] = artifact.filename; 674 args[i] = artifact.filename;
874 } 675 }
875 } 676 }
876 return args; 677 return args;
877 } 678 }
878 } 679 }
879 680
880 class AnalyzerCompilerConfiguration extends CompilerConfiguration { 681 class AnalyzerCompilerConfiguration extends CompilerConfiguration {
881 AnalyzerCompilerConfiguration( 682 AnalyzerCompilerConfiguration(Configuration configuration)
882 {bool isDebug, 683 : super._subclass(configuration);
883 bool isChecked,
884 bool isStrong,
885 bool isHostChecked,
886 bool useSdk})
887 : super._subclass(
888 isDebug: isDebug,
889 isChecked: isChecked,
890 isStrong: isStrong,
891 isHostChecked: isHostChecked,
892 useSdk: useSdk);
893 684
894 int get timeoutMultiplier => 4; 685 int get timeoutMultiplier => 4;
895 686
896 String computeCompilerPath(String buildDir) { 687 String computeCompilerPath(String buildDir) {
897 var prefix = 'sdk/bin'; 688 var prefix = 'sdk/bin';
898 String suffix = executableScriptSuffix; 689 String suffix = executableScriptSuffix;
899 if (isHostChecked) { 690 if (_isHostChecked) {
900 if (useSdk) { 691 if (_useSdk) {
901 throw "--host-checked and --use-sdk cannot be used together"; 692 throw "--host-checked and --use-sdk cannot be used together";
902 } 693 }
903 // The script dartanalyzer_developer is not included in the 694 // The script dartanalyzer_developer is not included in the
904 // shipped SDK, that is the script is not installed in 695 // shipped SDK, that is the script is not installed in
905 // "$buildDir/dart-sdk/bin/" 696 // "$buildDir/dart-sdk/bin/"
906 return '$prefix/dartanalyzer_developer$suffix'; 697 return '$prefix/dartanalyzer_developer$suffix';
907 } 698 }
908 if (useSdk) { 699 if (_useSdk) {
909 prefix = '$buildDir/dart-sdk/bin'; 700 prefix = '$buildDir/dart-sdk/bin';
910 } 701 }
911 return '$prefix/dartanalyzer$suffix'; 702 return '$prefix/dartanalyzer$suffix';
912 } 703 }
913 704
914 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, 705 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
915 List<String> arguments, Map<String, String> environmentOverrides) { 706 List<String> arguments, Map<String, String> environmentOverrides) {
916 arguments = arguments.toList(); 707 arguments = arguments.toList();
917 if (isChecked || isStrong) { 708 if (_isChecked || _isStrong) {
918 arguments.add('--enable_type_checks'); 709 arguments.add('--enable_type_checks');
919 } 710 }
920 if (isStrong) { 711 if (_isStrong) {
921 arguments.add('--strong'); 712 arguments.add('--strong');
922 } 713 }
714
715 // Since this is not a real compilation, no artifacts are produced.
923 return new CommandArtifact([ 716 return new CommandArtifact([
924 Command.analysis( 717 Command.analysis(
925 computeCompilerPath(buildDir), arguments, environmentOverrides) 718 computeCompilerPath(buildDir), arguments, environmentOverrides)
926 ], null, null); // Since this is not a real compilation, no artifacts are 719 ], null, null);
927 // produced.
928 } 720 }
929 721
930 List<String> computeRuntimeArguments( 722 List<String> computeRuntimeArguments(
931 RuntimeConfiguration runtimeConfiguration, 723 RuntimeConfiguration runtimeConfiguration,
932 String buildDir, 724 String buildDir,
933 TestInformation info, 725 TestInformation info,
934 List<String> vmOptions, 726 List<String> vmOptions,
935 List<String> sharedOptions, 727 List<String> sharedOptions,
936 List<String> originalArguments, 728 List<String> originalArguments,
937 CommandArtifact artifact) { 729 CommandArtifact artifact) {
938 return <String>[]; 730 return <String>[];
939 } 731 }
940 } 732 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698