OLD | NEW |
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'; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 throw "unreachable"; | 76 throw "unreachable"; |
77 } | 77 } |
78 | 78 |
79 CompilerConfiguration._subclass(this._configuration); | 79 CompilerConfiguration._subclass(this._configuration); |
80 | 80 |
81 /// A multiplier used to give tests longer time to run. | 81 /// A multiplier used to give tests longer time to run. |
82 int get timeoutMultiplier => 1; | 82 int get timeoutMultiplier => 1; |
83 | 83 |
84 // TODO(ahe): It shouldn't be necessary to pass [buildDir] to any of these | 84 // TODO(ahe): It shouldn't be necessary to pass [buildDir] to any of these |
85 // functions. It is fixed for a given configuration. | 85 // functions. It is fixed for a given configuration. |
86 String computeCompilerPath(String buildDir) { | 86 String computeCompilerPath() { |
87 throw "Unknown compiler for: $runtimeType"; | 87 throw "Unknown compiler for: $runtimeType"; |
88 } | 88 } |
89 | 89 |
90 bool get hasCompiler => true; | 90 bool get hasCompiler => true; |
91 | 91 |
92 String get executableScriptSuffix => Platform.isWindows ? '.bat' : ''; | 92 String get executableScriptSuffix => Platform.isWindows ? '.bat' : ''; |
93 | 93 |
94 List<Uri> bootstrapDependencies(String buildDir) => const <Uri>[]; | 94 List<Uri> bootstrapDependencies() => const <Uri>[]; |
95 | 95 |
96 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, | 96 /// Creates a [Command] to compile [inputFile] to [outputFile]. |
| 97 Command createCommand(String inputFile, String outputFile) { |
| 98 // TODO(rnystrom): See if this method can be unified with |
| 99 // computeCompilationArtifact() and/or computeCompilerArguments() for the |
| 100 // other compilers. |
| 101 throw new UnsupportedError("$this does not support createCommand()."); |
| 102 } |
| 103 |
| 104 CommandArtifact computeCompilationArtifact(String tempDir, |
97 List<String> arguments, Map<String, String> environmentOverrides) { | 105 List<String> arguments, Map<String, String> environmentOverrides) { |
98 return new CommandArtifact([], null, null); | 106 return new CommandArtifact([], null, null); |
99 } | 107 } |
100 | 108 |
101 List<String> computeCompilerArguments( | 109 List<String> computeCompilerArguments( |
102 List<String> vmOptions, List<String> sharedOptions, List<String> args) { | 110 List<String> vmOptions, List<String> sharedOptions, List<String> args) { |
103 return sharedOptions.toList()..addAll(args); | 111 return sharedOptions.toList()..addAll(args); |
104 } | 112 } |
105 | 113 |
106 List<String> computeRuntimeArguments( | 114 List<String> computeRuntimeArguments( |
107 RuntimeConfiguration runtimeConfiguration, | 115 RuntimeConfiguration runtimeConfiguration, |
108 String buildDir, | |
109 TestInformation info, | 116 TestInformation info, |
110 List<String> vmOptions, | 117 List<String> vmOptions, |
111 List<String> sharedOptions, | 118 List<String> sharedOptions, |
112 List<String> originalArguments, | 119 List<String> originalArguments, |
113 CommandArtifact artifact) { | 120 CommandArtifact artifact) { |
114 return [artifact.filename]; | 121 return [artifact.filename]; |
115 } | 122 } |
116 } | 123 } |
117 | 124 |
118 /// The "none" compiler. | 125 /// The "none" compiler. |
119 class NoneCompilerConfiguration extends CompilerConfiguration { | 126 class NoneCompilerConfiguration extends CompilerConfiguration { |
120 final bool useDfe; | 127 final bool useDfe; |
121 | 128 |
122 NoneCompilerConfiguration(Configuration configuration, {this.useDfe: false}) | 129 NoneCompilerConfiguration(Configuration configuration, {this.useDfe: false}) |
123 : super._subclass(configuration); | 130 : super._subclass(configuration); |
124 | 131 |
125 bool get hasCompiler => false; | 132 bool get hasCompiler => false; |
126 | 133 |
127 List<String> computeRuntimeArguments( | 134 List<String> computeRuntimeArguments( |
128 RuntimeConfiguration runtimeConfiguration, | 135 RuntimeConfiguration runtimeConfiguration, |
129 String buildDir, | |
130 TestInformation info, | 136 TestInformation info, |
131 List<String> vmOptions, | 137 List<String> vmOptions, |
132 List<String> sharedOptions, | 138 List<String> sharedOptions, |
133 List<String> originalArguments, | 139 List<String> originalArguments, |
134 CommandArtifact artifact) { | 140 CommandArtifact artifact) { |
| 141 var buildDir = _configuration.buildDirectory; |
135 var args = <String>[]; | 142 var args = <String>[]; |
136 if (useDfe) { | 143 if (useDfe) { |
137 args.add('--dfe=${buildDir}/gen/kernel-service.dart.snapshot'); | 144 args.add('--dfe=${buildDir}/gen/kernel-service.dart.snapshot'); |
138 args.add('--kernel-binaries=${buildDir}/patched_sdk'); | 145 args.add('--kernel-binaries=${buildDir}/patched_sdk'); |
139 } | 146 } |
140 if (_isChecked) { | 147 if (_isChecked) { |
141 args.add('--enable_asserts'); | 148 args.add('--enable_asserts'); |
142 args.add('--enable_type_checks'); | 149 args.add('--enable_type_checks'); |
143 } | 150 } |
144 if (_configuration.hotReload) { | 151 if (_configuration.hotReload) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 205 } |
199 } | 206 } |
200 | 207 |
201 class ComposedCompilerConfiguration extends CompilerConfiguration { | 208 class ComposedCompilerConfiguration extends CompilerConfiguration { |
202 final List<PipelineCommand> pipelineCommands; | 209 final List<PipelineCommand> pipelineCommands; |
203 | 210 |
204 ComposedCompilerConfiguration( | 211 ComposedCompilerConfiguration( |
205 Configuration configuration, this.pipelineCommands) | 212 Configuration configuration, this.pipelineCommands) |
206 : super._subclass(configuration); | 213 : super._subclass(configuration); |
207 | 214 |
208 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, | 215 CommandArtifact computeCompilationArtifact(String tempDir, |
209 List<String> globalArguments, Map<String, String> environmentOverrides) { | 216 List<String> globalArguments, Map<String, String> environmentOverrides) { |
210 var allCommands = <Command>[]; | 217 var allCommands = <Command>[]; |
211 | 218 |
212 // The first compilation command is as usual. | 219 // The first compilation command is as usual. |
213 var arguments = pipelineCommands[0].extractArguments(globalArguments, null); | 220 var arguments = pipelineCommands[0].extractArguments(globalArguments, null); |
214 CommandArtifact artifact = pipelineCommands[0] | 221 CommandArtifact artifact = pipelineCommands[0] |
215 .compilerConfiguration | 222 .compilerConfiguration |
216 .computeCompilationArtifact( | 223 .computeCompilationArtifact(tempDir, arguments, environmentOverrides); |
217 buildDir, tempDir, arguments, environmentOverrides); | |
218 allCommands.addAll(artifact.commands); | 224 allCommands.addAll(artifact.commands); |
219 | 225 |
220 // The following compilation commands are based on the output of the | 226 // The following compilation commands are based on the output of the |
221 // previous one. | 227 // previous one. |
222 for (var i = 1; i < pipelineCommands.length; i++) { | 228 for (var i = 1; i < pipelineCommands.length; i++) { |
223 PipelineCommand command = pipelineCommands[i]; | 229 PipelineCommand command = pipelineCommands[i]; |
224 | 230 |
225 arguments = command.extractArguments(globalArguments, artifact.filename); | 231 arguments = command.extractArguments(globalArguments, artifact.filename); |
226 artifact = command.compilerConfiguration.computeCompilationArtifact( | 232 artifact = command.compilerConfiguration |
227 buildDir, tempDir, arguments, environmentOverrides); | 233 .computeCompilationArtifact(tempDir, arguments, environmentOverrides); |
228 | 234 |
229 allCommands.addAll(artifact.commands); | 235 allCommands.addAll(artifact.commands); |
230 } | 236 } |
231 | 237 |
232 return new CommandArtifact( | 238 return new CommandArtifact( |
233 allCommands, artifact.filename, artifact.mimeType); | 239 allCommands, artifact.filename, artifact.mimeType); |
234 } | 240 } |
235 | 241 |
236 List<String> computeCompilerArguments(vmOptions, sharedOptions, args) { | 242 List<String> computeCompilerArguments(vmOptions, sharedOptions, args) { |
237 // The result will be passed as an input to [extractArguments] | 243 // The result will be passed as an input to [extractArguments] |
238 // (i.e. the arguments to the [PipelineCommand]). | 244 // (i.e. the arguments to the [PipelineCommand]). |
239 return <String>[]..addAll(vmOptions)..addAll(sharedOptions)..addAll(args); | 245 return <String>[]..addAll(vmOptions)..addAll(sharedOptions)..addAll(args); |
240 } | 246 } |
241 | 247 |
242 List<String> computeRuntimeArguments( | 248 List<String> computeRuntimeArguments( |
243 RuntimeConfiguration runtimeConfiguration, | 249 RuntimeConfiguration runtimeConfiguration, |
244 String buildDir, | |
245 TestInformation info, | 250 TestInformation info, |
246 List<String> vmOptions, | 251 List<String> vmOptions, |
247 List<String> sharedOptions, | 252 List<String> sharedOptions, |
248 List<String> originalArguments, | 253 List<String> originalArguments, |
249 CommandArtifact artifact) { | 254 CommandArtifact artifact) { |
250 CompilerConfiguration lastCompilerConfiguration = | 255 CompilerConfiguration lastCompilerConfiguration = |
251 pipelineCommands.last.compilerConfiguration; | 256 pipelineCommands.last.compilerConfiguration; |
252 return lastCompilerConfiguration.computeRuntimeArguments( | 257 return lastCompilerConfiguration.computeRuntimeArguments( |
253 runtimeConfiguration, | 258 runtimeConfiguration, |
254 buildDir, | |
255 info, | 259 info, |
256 vmOptions, | 260 vmOptions, |
257 sharedOptions, | 261 sharedOptions, |
258 originalArguments, | 262 originalArguments, |
259 artifact); | 263 artifact); |
260 } | 264 } |
261 } | 265 } |
262 | 266 |
263 /// Common configuration for dart2js-based tools, such as, dart2js | 267 /// Common configuration for dart2js-based tools, such as, dart2js |
264 class Dart2xCompilerConfiguration extends CompilerConfiguration { | 268 class Dart2xCompilerConfiguration extends CompilerConfiguration { |
265 final String moniker; | 269 final String moniker; |
266 static Map<String, List<Uri>> _bootstrapDependenciesCache = {}; | 270 static Map<String, List<Uri>> _bootstrapDependenciesCache = {}; |
267 | 271 |
268 Dart2xCompilerConfiguration(this.moniker, Configuration configuration) | 272 Dart2xCompilerConfiguration(this.moniker, Configuration configuration) |
269 : super._subclass(configuration); | 273 : super._subclass(configuration); |
270 | 274 |
271 String computeCompilerPath(String buildDir) { | 275 String computeCompilerPath() { |
272 var prefix = 'sdk/bin'; | 276 var prefix = 'sdk/bin'; |
273 var suffix = executableScriptSuffix; | 277 var suffix = executableScriptSuffix; |
274 | 278 |
275 if (_isHostChecked) { | 279 if (_isHostChecked) { |
276 // The script dart2js_developer is not included in the | 280 // The script dart2js_developer is not included in the |
277 // shipped SDK, that is the script is not installed in | 281 // shipped SDK, that is the script is not installed in |
278 // "$buildDir/dart-sdk/bin/" | 282 // "$buildDir/dart-sdk/bin/" |
279 return '$prefix/dart2js_developer$suffix'; | 283 return '$prefix/dart2js_developer$suffix'; |
280 } | 284 } |
281 | 285 |
282 if (_useSdk) { | 286 if (_useSdk) { |
283 prefix = '$buildDir/dart-sdk/bin'; | 287 prefix = '${_configuration.buildDirectory}/dart-sdk/bin'; |
284 } | 288 } |
285 return '$prefix/dart2js$suffix'; | 289 return '$prefix/dart2js$suffix'; |
286 } | 290 } |
287 | 291 |
288 Command computeCompilationCommand(String outputFileName, String buildDir, | 292 Command computeCompilationCommand(String outputFileName, |
289 List<String> arguments, Map<String, String> environmentOverrides) { | 293 List<String> arguments, Map<String, String> environmentOverrides) { |
290 arguments = arguments.toList(); | 294 arguments = arguments.toList(); |
291 arguments.add('--out=$outputFileName'); | 295 arguments.add('--out=$outputFileName'); |
292 | 296 |
293 return Command.compilation( | 297 return Command.compilation(moniker, outputFileName, bootstrapDependencies(), |
294 moniker, | 298 computeCompilerPath(), arguments, environmentOverrides, |
295 outputFileName, | |
296 bootstrapDependencies(buildDir), | |
297 computeCompilerPath(buildDir), | |
298 arguments, | |
299 environmentOverrides, | |
300 alwaysCompile: !_useSdk); | 299 alwaysCompile: !_useSdk); |
301 } | 300 } |
302 | 301 |
303 List<Uri> bootstrapDependencies(String buildDir) { | 302 List<Uri> bootstrapDependencies() { |
304 if (!_useSdk) return const <Uri>[]; | 303 if (!_useSdk) return const <Uri>[]; |
305 return _bootstrapDependenciesCache.putIfAbsent( | 304 return _bootstrapDependenciesCache.putIfAbsent( |
306 buildDir, | 305 _configuration.buildDirectory, |
307 () => [ | 306 () => [ |
308 Uri.base | 307 Uri.base |
309 .resolveUri(new Uri.directory(buildDir)) | 308 .resolveUri(new Uri.directory(_configuration.buildDirectory)) |
310 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot') | 309 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot') |
311 ]); | 310 ]); |
312 } | 311 } |
313 } | 312 } |
314 | 313 |
315 /// Configuration for dart2js compiler. | 314 /// Configuration for dart2js compiler. |
316 class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration { | 315 class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration { |
317 Dart2jsCompilerConfiguration(Configuration configuration) | 316 Dart2jsCompilerConfiguration(Configuration configuration) |
318 : super('dart2js', configuration); | 317 : super('dart2js', configuration); |
319 | 318 |
320 int get timeoutMultiplier { | 319 int get timeoutMultiplier { |
321 var multiplier = 1; | 320 var multiplier = 1; |
322 if (_isDebug) multiplier *= 4; | 321 if (_isDebug) multiplier *= 4; |
323 if (_isChecked) multiplier *= 2; | 322 if (_isChecked) multiplier *= 2; |
324 if (_isHostChecked) multiplier *= 16; | 323 if (_isHostChecked) multiplier *= 16; |
325 return multiplier; | 324 return multiplier; |
326 } | 325 } |
327 | 326 |
328 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, | 327 CommandArtifact computeCompilationArtifact(String tempDir, |
329 List<String> arguments, Map<String, String> environmentOverrides) { | 328 List<String> arguments, Map<String, String> environmentOverrides) { |
330 var compilerArguments = arguments.toList() | 329 var compilerArguments = arguments.toList() |
331 ..addAll(_configuration.dart2jsOptions); | 330 ..addAll(_configuration.dart2jsOptions); |
332 return new CommandArtifact([ | 331 return new CommandArtifact([ |
333 computeCompilationCommand( | 332 computeCompilationCommand( |
334 '$tempDir/out.js', buildDir, compilerArguments, environmentOverrides) | 333 '$tempDir/out.js', compilerArguments, environmentOverrides) |
335 ], '$tempDir/out.js', 'application/javascript'); | 334 ], '$tempDir/out.js', 'application/javascript'); |
336 } | 335 } |
337 | 336 |
338 List<String> computeRuntimeArguments( | 337 List<String> computeRuntimeArguments( |
339 RuntimeConfiguration runtimeConfiguration, | 338 RuntimeConfiguration runtimeConfiguration, |
340 String buildDir, | |
341 TestInformation info, | 339 TestInformation info, |
342 List<String> vmOptions, | 340 List<String> vmOptions, |
343 List<String> sharedOptions, | 341 List<String> sharedOptions, |
344 List<String> originalArguments, | 342 List<String> originalArguments, |
345 CommandArtifact artifact) { | 343 CommandArtifact artifact) { |
346 Uri sdk = _useSdk | 344 Uri sdk = _useSdk |
347 ? new Uri.directory(buildDir).resolve('dart-sdk/') | 345 ? new Uri.directory(_configuration.buildDirectory).resolve('dart-sdk/') |
348 : new Uri.directory(TestUtils.dartDir.toNativePath()).resolve('sdk/'); | 346 : new Uri.directory(TestUtils.dartDir.toNativePath()).resolve('sdk/'); |
349 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); | 347 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); |
350 return runtimeConfiguration.dart2jsPreambles(preambleDir) | 348 return runtimeConfiguration.dart2jsPreambles(preambleDir) |
351 ..add(artifact.filename); | 349 ..add(artifact.filename); |
352 } | 350 } |
353 } | 351 } |
354 | 352 |
355 /// Configuration for dart2js compiler. | 353 /// Configuration for dart2js compiler. |
356 class DartdevcCompilerConfiguration extends CompilerConfiguration { | 354 class DartdevcCompilerConfiguration extends CompilerConfiguration { |
357 DartdevcCompilerConfiguration(Configuration configuration) | 355 DartdevcCompilerConfiguration(Configuration configuration) |
358 : super._subclass(configuration); | 356 : super._subclass(configuration); |
359 | 357 |
360 String computeCompilerPath(String buildDir) { | 358 String computeCompilerPath() { |
361 var dir = _useSdk ? "$buildDir/dart-sdk" : "sdk"; | 359 var dir = _useSdk ? "${_configuration.buildDirectory}/dart-sdk" : "sdk"; |
362 return "$dir/bin/dartdevc$executableScriptSuffix"; | 360 return "$dir/bin/dartdevc$executableScriptSuffix"; |
363 } | 361 } |
364 | 362 |
365 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, | 363 Command createCommand(String inputFile, String outputFile) { |
| 364 var moduleRoot = |
| 365 new Path(outputFile).directoryPath.directoryPath.toString(); |
| 366 |
| 367 var args = [ |
| 368 "--dart-sdk", |
| 369 "${_configuration.buildDirectory}/dart-sdk", |
| 370 "--library-root", |
| 371 new Path(inputFile).directoryPath.toString(), |
| 372 "--module-root", |
| 373 moduleRoot, |
| 374 "--no-summarize", |
| 375 "--no-source-map", |
| 376 "-o", |
| 377 outputFile, |
| 378 inputFile, |
| 379 ]; |
| 380 |
| 381 // Link to the summaries for the available packages, so that they don't |
| 382 // get recompiled into the test's own module. |
| 383 for (var package in testPackages) { |
| 384 args.add("-s"); |
| 385 |
| 386 // Since the summaries for the packages are not near the tests, we give |
| 387 // dartdevc explicit module paths for each one. When the test is run, we |
| 388 // will tell require.js where to find each package's compiled JS. |
| 389 var summary = _configuration.buildDirectory + |
| 390 "/gen/utils/dartdevc/pkg/$package.sum"; |
| 391 args.add("$summary:$package"); |
| 392 } |
| 393 |
| 394 return Command.compilation(Compiler.dartdevc.name, outputFile, |
| 395 bootstrapDependencies(), computeCompilerPath(), args, const {}); |
| 396 } |
| 397 |
| 398 CommandArtifact computeCompilationArtifact(String tempDir, |
366 List<String> arguments, Map<String, String> environmentOverrides) { | 399 List<String> arguments, Map<String, String> environmentOverrides) { |
367 // TODO(rnystrom): There is a lot of overlap between this code and | |
368 // _dartdevcCompileCommand() in test_suite.dart. This code path is only hit | |
369 // when the test is expected to have a compile error. Consider refactoring | |
370 // to unify the two (and likewise for dart2js). | |
371 | |
372 // TODO(rnystrom): Are there other arguments here that we need to keep? | 400 // TODO(rnystrom): Are there other arguments here that we need to keep? |
373 // What about arguments specified in the test itself? | 401 // What about arguments specified in the test itself? |
374 var inputFile = arguments.last; | 402 var inputFile = arguments.last; |
| 403 var outputFile = "$tempDir/${inputFile.replaceAll('.dart', '.js')}"; |
375 | 404 |
376 var compilerArguments = [ | 405 return new CommandArtifact([createCommand(inputFile, outputFile)], |
377 "--dart-sdk", | 406 outputFile, "application/javascript"); |
378 "$buildDir/dart-sdk", | |
379 "--library-root", | |
380 new Path(inputFile).directoryPath.toString(), | |
381 "-o", | |
382 "$tempDir/out.js", | |
383 inputFile | |
384 ]; | |
385 | |
386 var command = Command.compilation( | |
387 Compiler.dartdevc.name, | |
388 "$tempDir/out.js", | |
389 bootstrapDependencies(buildDir), | |
390 computeCompilerPath(buildDir), | |
391 compilerArguments, | |
392 environmentOverrides); | |
393 | |
394 return new CommandArtifact( | |
395 [command], "$tempDir/out.js", "application/javascript"); | |
396 } | 407 } |
397 } | 408 } |
398 | 409 |
399 class PrecompilerCompilerConfiguration extends CompilerConfiguration { | 410 class PrecompilerCompilerConfiguration extends CompilerConfiguration { |
400 final bool useDfe; | 411 final bool useDfe; |
401 | 412 |
402 bool get _isAndroid => _configuration.system == System.android; | 413 bool get _isAndroid => _configuration.system == System.android; |
403 bool get _isArm => _configuration.architecture == Architecture.arm; | 414 bool get _isArm => _configuration.architecture == Architecture.arm; |
404 bool get _isArm64 => _configuration.architecture == Architecture.arm64; | 415 bool get _isArm64 => _configuration.architecture == Architecture.arm64; |
405 | 416 |
406 PrecompilerCompilerConfiguration(Configuration configuration, | 417 PrecompilerCompilerConfiguration(Configuration configuration, |
407 {this.useDfe: false}) | 418 {this.useDfe: false}) |
408 : super._subclass(configuration); | 419 : super._subclass(configuration); |
409 | 420 |
410 int get timeoutMultiplier { | 421 int get timeoutMultiplier { |
411 var multiplier = 2; | 422 var multiplier = 2; |
412 if (_isDebug) multiplier *= 4; | 423 if (_isDebug) multiplier *= 4; |
413 if (_isChecked) multiplier *= 2; | 424 if (_isChecked) multiplier *= 2; |
414 return multiplier; | 425 return multiplier; |
415 } | 426 } |
416 | 427 |
417 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, | 428 CommandArtifact computeCompilationArtifact(String tempDir, |
418 List<String> arguments, Map<String, String> environmentOverrides) { | 429 List<String> arguments, Map<String, String> environmentOverrides) { |
419 var commands = [ | 430 var commands = [ |
420 computeCompilationCommand( | 431 computeCompilationCommand(tempDir, arguments, environmentOverrides) |
421 tempDir, buildDir, arguments, environmentOverrides) | |
422 ]; | 432 ]; |
423 | 433 |
424 if (!_configuration.useBlobs) { | 434 if (!_configuration.useBlobs) { |
425 commands.add(computeAssembleCommand( | 435 commands.add( |
426 tempDir, buildDir, arguments, environmentOverrides)); | 436 computeAssembleCommand(tempDir, arguments, environmentOverrides)); |
427 commands.add(computeRemoveAssemblyCommand( | 437 commands.add(computeRemoveAssemblyCommand( |
428 tempDir, buildDir, arguments, environmentOverrides)); | 438 tempDir, arguments, environmentOverrides)); |
429 } | 439 } |
430 | 440 |
431 return new CommandArtifact( | 441 return new CommandArtifact( |
432 commands, '$tempDir', 'application/dart-precompiled'); | 442 commands, '$tempDir', 'application/dart-precompiled'); |
433 } | 443 } |
434 | 444 |
435 Command computeCompilationCommand(String tempDir, String buildDir, | 445 Command computeCompilationCommand(String tempDir, List<String> arguments, |
436 List<String> arguments, Map<String, String> environmentOverrides) { | 446 Map<String, String> environmentOverrides) { |
| 447 var buildDir = _configuration.buildDirectory; |
437 String exec; | 448 String exec; |
438 if (_isAndroid) { | 449 if (_isAndroid) { |
439 if (_isArm) { | 450 if (_isArm) { |
440 exec = "$buildDir/clang_x86/dart_bootstrap"; | 451 exec = "$buildDir/clang_x86/dart_bootstrap"; |
441 } else if (_configuration.architecture == Architecture.arm64) { | 452 } else if (_configuration.architecture == Architecture.arm64) { |
442 exec = "$buildDir/clang_x64/dart_bootstrap"; | 453 exec = "$buildDir/clang_x64/dart_bootstrap"; |
443 } | 454 } |
444 } else { | 455 } else { |
445 exec = "$buildDir/dart_bootstrap"; | 456 exec = "$buildDir/dart_bootstrap"; |
446 } | 457 } |
(...skipping 11 matching lines...) Expand all Loading... |
458 } else { | 469 } else { |
459 args.add("--snapshot=$tempDir/out.S"); | 470 args.add("--snapshot=$tempDir/out.S"); |
460 } | 471 } |
461 | 472 |
462 if (_isAndroid && _isArm) { | 473 if (_isAndroid && _isArm) { |
463 args.add('--no-sim-use-hardfp'); | 474 args.add('--no-sim-use-hardfp'); |
464 } | 475 } |
465 | 476 |
466 args.addAll(arguments); | 477 args.addAll(arguments); |
467 | 478 |
468 return Command.compilation('precompiler', tempDir, | 479 return Command.compilation('precompiler', tempDir, bootstrapDependencies(), |
469 bootstrapDependencies(buildDir), exec, args, environmentOverrides, | 480 exec, args, environmentOverrides, |
470 alwaysCompile: !_useSdk); | 481 alwaysCompile: !_useSdk); |
471 } | 482 } |
472 | 483 |
473 Command computeAssembleCommand(String tempDir, String buildDir, | 484 Command computeAssembleCommand(String tempDir, List arguments, |
474 List arguments, Map<String, String> environmentOverrides) { | 485 Map<String, String> environmentOverrides) { |
475 String cc, shared, ldFlags; | 486 String cc, shared, ldFlags; |
476 if (_isAndroid) { | 487 if (_isAndroid) { |
477 var ndk = "third_party/android_tools/ndk"; | 488 var ndk = "third_party/android_tools/ndk"; |
478 String triple; | 489 String triple; |
479 if (_isArm) { | 490 if (_isArm) { |
480 triple = "arm-linux-androideabi"; | 491 triple = "arm-linux-androideabi"; |
481 } else if (_isArm64) { | 492 } else if (_isArm64) { |
482 triple = "aarch64-linux-android"; | 493 triple = "aarch64-linux-android"; |
483 } | 494 } |
484 String host; | 495 String host; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 var exec = cc; | 531 var exec = cc; |
521 var args = <String>[]; | 532 var args = <String>[]; |
522 if (ccFlags != null) args.add(ccFlags); | 533 if (ccFlags != null) args.add(ccFlags); |
523 if (ldFlags != null) args.add(ldFlags); | 534 if (ldFlags != null) args.add(ldFlags); |
524 args.add(shared); | 535 args.add(shared); |
525 args.add('-nostdlib'); | 536 args.add('-nostdlib'); |
526 args.add('-o'); | 537 args.add('-o'); |
527 args.add('$tempDir/out.aotsnapshot'); | 538 args.add('$tempDir/out.aotsnapshot'); |
528 args.add('$tempDir/out.S'); | 539 args.add('$tempDir/out.S'); |
529 | 540 |
530 return Command.compilation('assemble', tempDir, | 541 return Command.compilation('assemble', tempDir, bootstrapDependencies(), |
531 bootstrapDependencies(buildDir), exec, args, environmentOverrides, | 542 exec, args, environmentOverrides, |
532 alwaysCompile: !_useSdk); | 543 alwaysCompile: !_useSdk); |
533 } | 544 } |
534 | 545 |
535 // This step reduces the amount of space needed to run the precompilation | 546 // This step reduces the amount of space needed to run the precompilation |
536 // tests by 60%. | 547 // tests by 60%. |
537 Command computeRemoveAssemblyCommand(String tempDir, String buildDir, | 548 Command computeRemoveAssemblyCommand(String tempDir, List arguments, |
538 List arguments, Map<String, String> environmentOverrides) { | 549 Map<String, String> environmentOverrides) { |
539 var exec = 'rm'; | 550 var exec = 'rm'; |
540 var args = ['$tempDir/out.S']; | 551 var args = ['$tempDir/out.S']; |
541 | 552 |
542 return Command.compilation('remove_assembly', tempDir, | 553 return Command.compilation('remove_assembly', tempDir, |
543 bootstrapDependencies(buildDir), exec, args, environmentOverrides, | 554 bootstrapDependencies(), exec, args, environmentOverrides, |
544 alwaysCompile: !_useSdk); | 555 alwaysCompile: !_useSdk); |
545 } | 556 } |
546 | 557 |
547 List<String> filterVmOptions(List<String> vmOptions) { | 558 List<String> filterVmOptions(List<String> vmOptions) { |
548 var filtered = vmOptions.toList(); | 559 var filtered = vmOptions.toList(); |
549 filtered.removeWhere( | 560 filtered.removeWhere( |
550 (option) => option.startsWith("--optimization-counter-threshold")); | 561 (option) => option.startsWith("--optimization-counter-threshold")); |
551 filtered.removeWhere( | 562 filtered.removeWhere( |
552 (option) => option.startsWith("--optimization_counter_threshold")); | 563 (option) => option.startsWith("--optimization_counter_threshold")); |
553 return filtered; | 564 return filtered; |
554 } | 565 } |
555 | 566 |
556 List<String> computeCompilerArguments( | 567 List<String> computeCompilerArguments( |
557 vmOptions, sharedOptions, originalArguments) { | 568 vmOptions, sharedOptions, originalArguments) { |
558 List<String> args = []; | 569 List<String> args = []; |
559 if (_isChecked) { | 570 if (_isChecked) { |
560 args.add('--enable_asserts'); | 571 args.add('--enable_asserts'); |
561 args.add('--enable_type_checks'); | 572 args.add('--enable_type_checks'); |
562 } | 573 } |
563 return args | 574 return args |
564 ..addAll(filterVmOptions(vmOptions)) | 575 ..addAll(filterVmOptions(vmOptions)) |
565 ..addAll(sharedOptions) | 576 ..addAll(sharedOptions) |
566 ..addAll(originalArguments); | 577 ..addAll(originalArguments); |
567 } | 578 } |
568 | 579 |
569 List<String> computeRuntimeArguments( | 580 List<String> computeRuntimeArguments( |
570 RuntimeConfiguration runtimeConfiguration, | 581 RuntimeConfiguration runtimeConfiguration, |
571 String buildDir, | |
572 TestInformation info, | 582 TestInformation info, |
573 List<String> vmOptions, | 583 List<String> vmOptions, |
574 List<String> sharedOptions, | 584 List<String> sharedOptions, |
575 List<String> originalArguments, | 585 List<String> originalArguments, |
576 CommandArtifact artifact) { | 586 CommandArtifact artifact) { |
577 var args = <String>[]; | 587 var args = <String>[]; |
578 if (_isChecked) { | 588 if (_isChecked) { |
579 args.add('--enable_asserts'); | 589 args.add('--enable_asserts'); |
580 args.add('--enable_type_checks'); | 590 args.add('--enable_type_checks'); |
581 } | 591 } |
(...skipping 18 matching lines...) Expand all Loading... |
600 AppJitCompilerConfiguration(Configuration configuration) | 610 AppJitCompilerConfiguration(Configuration configuration) |
601 : super._subclass(configuration); | 611 : super._subclass(configuration); |
602 | 612 |
603 int get timeoutMultiplier { | 613 int get timeoutMultiplier { |
604 var multiplier = 1; | 614 var multiplier = 1; |
605 if (_isDebug) multiplier *= 2; | 615 if (_isDebug) multiplier *= 2; |
606 if (_isChecked) multiplier *= 2; | 616 if (_isChecked) multiplier *= 2; |
607 return multiplier; | 617 return multiplier; |
608 } | 618 } |
609 | 619 |
610 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, | 620 CommandArtifact computeCompilationArtifact(String tempDir, |
611 List<String> arguments, Map<String, String> environmentOverrides) { | 621 List<String> arguments, Map<String, String> environmentOverrides) { |
612 var snapshot = "$tempDir/out.jitsnapshot"; | 622 var snapshot = "$tempDir/out.jitsnapshot"; |
613 return new CommandArtifact([ | 623 return new CommandArtifact( |
614 computeCompilationCommand( | 624 [computeCompilationCommand(tempDir, arguments, environmentOverrides)], |
615 tempDir, buildDir, arguments, environmentOverrides) | 625 snapshot, |
616 ], snapshot, 'application/dart-snapshot'); | 626 'application/dart-snapshot'); |
617 } | 627 } |
618 | 628 |
619 Command computeCompilationCommand(String tempDir, String buildDir, | 629 Command computeCompilationCommand(String tempDir, List<String> arguments, |
620 List<String> arguments, Map<String, String> environmentOverrides) { | 630 Map<String, String> environmentOverrides) { |
621 var exec = "$buildDir/dart"; | 631 var exec = "${_configuration.buildDirectory}/dart"; |
622 var snapshot = "$tempDir/out.jitsnapshot"; | 632 var snapshot = "$tempDir/out.jitsnapshot"; |
623 var args = ["--snapshot=$snapshot", "--snapshot-kind=app-jit"]; | 633 var args = ["--snapshot=$snapshot", "--snapshot-kind=app-jit"]; |
624 args.addAll(arguments); | 634 args.addAll(arguments); |
625 | 635 |
626 return Command.compilation('app_jit', tempDir, | 636 return Command.compilation('app_jit', tempDir, bootstrapDependencies(), |
627 bootstrapDependencies(buildDir), exec, args, environmentOverrides, | 637 exec, args, environmentOverrides, |
628 alwaysCompile: !_useSdk); | 638 alwaysCompile: !_useSdk); |
629 } | 639 } |
630 | 640 |
631 List<String> computeCompilerArguments( | 641 List<String> computeCompilerArguments( |
632 vmOptions, sharedOptions, originalArguments) { | 642 vmOptions, sharedOptions, originalArguments) { |
633 var args = <String>[]; | 643 var args = <String>[]; |
634 if (_isChecked) { | 644 if (_isChecked) { |
635 args.add('--enable_asserts'); | 645 args.add('--enable_asserts'); |
636 args.add('--enable_type_checks'); | 646 args.add('--enable_type_checks'); |
637 } | 647 } |
638 return args | 648 return args |
639 ..addAll(vmOptions) | 649 ..addAll(vmOptions) |
640 ..addAll(sharedOptions) | 650 ..addAll(sharedOptions) |
641 ..addAll(originalArguments); | 651 ..addAll(originalArguments); |
642 } | 652 } |
643 | 653 |
644 List<String> computeRuntimeArguments( | 654 List<String> computeRuntimeArguments( |
645 RuntimeConfiguration runtimeConfiguration, | 655 RuntimeConfiguration runtimeConfiguration, |
646 String buildDir, | |
647 TestInformation info, | 656 TestInformation info, |
648 List<String> vmOptions, | 657 List<String> vmOptions, |
649 List<String> sharedOptions, | 658 List<String> sharedOptions, |
650 List<String> originalArguments, | 659 List<String> originalArguments, |
651 CommandArtifact artifact) { | 660 CommandArtifact artifact) { |
652 var args = <String>[]; | 661 var args = <String>[]; |
653 if (_isChecked) { | 662 if (_isChecked) { |
654 args.add('--enable_asserts'); | 663 args.add('--enable_asserts'); |
655 args.add('--enable_type_checks'); | 664 args.add('--enable_type_checks'); |
656 } | 665 } |
657 args..addAll(vmOptions)..addAll(sharedOptions)..addAll(originalArguments); | 666 args..addAll(vmOptions)..addAll(sharedOptions)..addAll(originalArguments); |
658 for (var i = 0; i < args.length; i++) { | 667 for (var i = 0; i < args.length; i++) { |
659 if (args[i].endsWith(".dart")) { | 668 if (args[i].endsWith(".dart")) { |
660 args[i] = artifact.filename; | 669 args[i] = artifact.filename; |
661 } | 670 } |
662 } | 671 } |
663 return args; | 672 return args; |
664 } | 673 } |
665 } | 674 } |
666 | 675 |
667 class AnalyzerCompilerConfiguration extends CompilerConfiguration { | 676 class AnalyzerCompilerConfiguration extends CompilerConfiguration { |
668 AnalyzerCompilerConfiguration(Configuration configuration) | 677 AnalyzerCompilerConfiguration(Configuration configuration) |
669 : super._subclass(configuration); | 678 : super._subclass(configuration); |
670 | 679 |
671 int get timeoutMultiplier => 4; | 680 int get timeoutMultiplier => 4; |
672 | 681 |
673 String computeCompilerPath(String buildDir) { | 682 String computeCompilerPath() { |
674 var prefix = 'sdk/bin'; | 683 var prefix = 'sdk/bin'; |
675 String suffix = executableScriptSuffix; | 684 String suffix = executableScriptSuffix; |
676 if (_isHostChecked) { | 685 if (_isHostChecked) { |
677 if (_useSdk) { | 686 if (_useSdk) { |
678 throw "--host-checked and --use-sdk cannot be used together"; | 687 throw "--host-checked and --use-sdk cannot be used together"; |
679 } | 688 } |
680 // The script dartanalyzer_developer is not included in the | 689 // The script dartanalyzer_developer is not included in the |
681 // shipped SDK, that is the script is not installed in | 690 // shipped SDK, that is the script is not installed in |
682 // "$buildDir/dart-sdk/bin/" | 691 // "$buildDir/dart-sdk/bin/" |
683 return '$prefix/dartanalyzer_developer$suffix'; | 692 return '$prefix/dartanalyzer_developer$suffix'; |
684 } | 693 } |
685 if (_useSdk) { | 694 if (_useSdk) { |
686 prefix = '$buildDir/dart-sdk/bin'; | 695 prefix = '${_configuration.buildDirectory}/dart-sdk/bin'; |
687 } | 696 } |
688 return '$prefix/dartanalyzer$suffix'; | 697 return '$prefix/dartanalyzer$suffix'; |
689 } | 698 } |
690 | 699 |
691 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, | 700 CommandArtifact computeCompilationArtifact(String tempDir, |
692 List<String> arguments, Map<String, String> environmentOverrides) { | 701 List<String> arguments, Map<String, String> environmentOverrides) { |
693 arguments = arguments.toList(); | 702 arguments = arguments.toList(); |
694 if (_isChecked || _isStrong) { | 703 if (_isChecked || _isStrong) { |
695 arguments.add('--enable_type_checks'); | 704 arguments.add('--enable_type_checks'); |
696 } | 705 } |
697 if (_isStrong) { | 706 if (_isStrong) { |
698 arguments.add('--strong'); | 707 arguments.add('--strong'); |
699 } | 708 } |
700 | 709 |
701 // Since this is not a real compilation, no artifacts are produced. | 710 // Since this is not a real compilation, no artifacts are produced. |
702 return new CommandArtifact([ | 711 return new CommandArtifact([ |
703 Command.analysis( | 712 Command.analysis(computeCompilerPath(), arguments, environmentOverrides) |
704 computeCompilerPath(buildDir), arguments, environmentOverrides) | |
705 ], null, null); | 713 ], null, null); |
706 } | 714 } |
707 | 715 |
708 List<String> computeRuntimeArguments( | 716 List<String> computeRuntimeArguments( |
709 RuntimeConfiguration runtimeConfiguration, | 717 RuntimeConfiguration runtimeConfiguration, |
710 String buildDir, | |
711 TestInformation info, | 718 TestInformation info, |
712 List<String> vmOptions, | 719 List<String> vmOptions, |
713 List<String> sharedOptions, | 720 List<String> sharedOptions, |
714 List<String> originalArguments, | 721 List<String> originalArguments, |
715 CommandArtifact artifact) { | 722 CommandArtifact artifact) { |
716 return <String>[]; | 723 return <String>[]; |
717 } | 724 } |
718 } | 725 } |
OLD | NEW |