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