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

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

Issue 1859973002: Autoformat tools/testing/dart (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Format whole directory Created 4 years, 8 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 | « tools/testing/dart/co19_test_config.dart ('k') | tools/testing/dart/dependency_graph.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library compiler_configuration; 5 library compiler_configuration;
6 6
7 import 'dart:io' show 7 import 'dart:io' show Platform;
8 Platform;
9 8
10 import 'runtime_configuration.dart' show 9 import 'runtime_configuration.dart' show RuntimeConfiguration;
11 RuntimeConfiguration;
12 10
13 import 'test_runner.dart' show 11 import 'test_runner.dart' show Command, CommandBuilder, CompilationCommand;
14 Command,
15 CommandBuilder,
16 CompilationCommand;
17 12
18 import 'test_suite.dart' show 13 import 'test_suite.dart' show TestInformation, TestUtils;
19 TestInformation,
20 TestUtils;
21 14
22 /// Grouping of a command with its expected result. 15 /// Grouping of a command with its expected result.
23 class CommandArtifact { 16 class CommandArtifact {
24 final List<Command> commands; 17 final List<Command> commands;
25 18
26 /// Expected result of running [command]. 19 /// Expected result of running [command].
27 final String filename; 20 final String filename;
28 21
29 /// MIME type of [filename]. 22 /// MIME type of [filename].
30 final String mimeType; 23 final String mimeType;
31 24
32 CommandArtifact(this.commands, this.filename, this.mimeType); 25 CommandArtifact(this.commands, this.filename, this.mimeType);
33 } 26 }
34 27
35 Uri nativeDirectoryToUri(String nativePath) { 28 Uri nativeDirectoryToUri(String nativePath) {
36 Uri uri = new Uri.file(nativePath); 29 Uri uri = new Uri.file(nativePath);
37 String path = uri.path; 30 String path = uri.path;
38 return (path == '' || path.endsWith('/')) 31 return (path == '' || path.endsWith('/')) ? uri : Uri.parse('$uri/');
39 ? uri
40 : Uri.parse('$uri/');
41 } 32 }
42 33
43 abstract class CompilerConfiguration { 34 abstract class CompilerConfiguration {
44 final bool isDebug; 35 final bool isDebug;
45 final bool isChecked; 36 final bool isChecked;
46 final bool isHostChecked; 37 final bool isHostChecked;
47 final bool useSdk; 38 final bool useSdk;
48 39
49 // TODO(ahe): Remove this constructor and move the switch to 40 // TODO(ahe): Remove this constructor and move the switch to
50 // test_options.dart. We probably want to store an instance of 41 // test_options.dart. We probably want to store an instance of
51 // [CompilerConfiguration] in [configuration] there. 42 // [CompilerConfiguration] in [configuration] there.
52 factory CompilerConfiguration(Map configuration) { 43 factory CompilerConfiguration(Map configuration) {
53 String compiler = configuration['compiler']; 44 String compiler = configuration['compiler'];
54 45
55 // TODO(ahe): Move these booleans into a struction configuration object 46 // TODO(ahe): Move these booleans into a struction configuration object
56 // which can eventually completely replace the Map-based configuration 47 // which can eventually completely replace the Map-based configuration
57 // object. 48 // object.
58 bool isDebug = configuration['mode'] == 'debug'; 49 bool isDebug = configuration['mode'] == 'debug';
59 bool isChecked = configuration['checked']; 50 bool isChecked = configuration['checked'];
60 bool isHostChecked = configuration['host_checked']; 51 bool isHostChecked = configuration['host_checked'];
61 bool useSdk = configuration['use_sdk']; 52 bool useSdk = configuration['use_sdk'];
62 bool isCsp = configuration['csp']; 53 bool isCsp = configuration['csp'];
63 bool useCps = configuration['cps_ir']; 54 bool useCps = configuration['cps_ir'];
64 55
65 switch (compiler) { 56 switch (compiler) {
66 case 'dart2analyzer': 57 case 'dart2analyzer':
67 return new AnalyzerCompilerConfiguration( 58 return new AnalyzerCompilerConfiguration(
68 isDebug: isDebug, isChecked: isChecked, 59 isDebug: isDebug,
69 isHostChecked: isHostChecked, useSdk: useSdk); 60 isChecked: isChecked,
61 isHostChecked: isHostChecked,
62 useSdk: useSdk);
70 case 'dart2js': 63 case 'dart2js':
71 return new Dart2jsCompilerConfiguration( 64 return new Dart2jsCompilerConfiguration(
72 isDebug: isDebug, isChecked: isChecked, 65 isDebug: isDebug,
73 isHostChecked: isHostChecked, useCps: useCps, useSdk: useSdk, 66 isChecked: isChecked,
74 isCsp: isCsp, extraDart2jsOptions: 67 isHostChecked: isHostChecked,
68 useCps: useCps,
69 useSdk: useSdk,
70 isCsp: isCsp,
71 extraDart2jsOptions:
75 TestUtils.getExtraOptions(configuration, 'dart2js_options')); 72 TestUtils.getExtraOptions(configuration, 'dart2js_options'));
76 case 'dart2app': 73 case 'dart2app':
77 return new Dart2AppSnapshotCompilerConfiguration( 74 return new Dart2AppSnapshotCompilerConfiguration(
78 isDebug: isDebug, isChecked: isChecked); 75 isDebug: isDebug, isChecked: isChecked);
79 case 'precompiler': 76 case 'precompiler':
80 return new PrecompilerCompilerConfiguration( 77 return new PrecompilerCompilerConfiguration(
81 isDebug: isDebug, isChecked: isChecked, 78 isDebug: isDebug,
79 isChecked: isChecked,
82 arch: configuration['arch']); 80 arch: configuration['arch']);
83 case 'none': 81 case 'none':
84 return new NoneCompilerConfiguration( 82 return new NoneCompilerConfiguration(
85 isDebug: isDebug, isChecked: isChecked, 83 isDebug: isDebug,
86 isHostChecked: isHostChecked, useSdk: useSdk); 84 isChecked: isChecked,
85 isHostChecked: isHostChecked,
86 useSdk: useSdk);
87 default: 87 default:
88 throw "Unknown compiler '$compiler'"; 88 throw "Unknown compiler '$compiler'";
89 } 89 }
90 } 90 }
91 91
92 CompilerConfiguration._subclass({ 92 CompilerConfiguration._subclass(
93 this.isDebug: false, 93 {this.isDebug: false,
94 this.isChecked: false, 94 this.isChecked: false,
95 this.isHostChecked: false, 95 this.isHostChecked: false,
96 this.useSdk: false}); 96 this.useSdk: false});
97 97
98 /// Return a multiplier used to give tests longer time to run. 98 /// Return a multiplier used to give tests longer time to run.
99 // TODO(ahe): Convert to getter! 99 // TODO(ahe): Convert to getter!
100 int computeTimeoutMultiplier() { 100 int computeTimeoutMultiplier() {
101 return 1; 101 return 1;
102 } 102 }
103 103
(...skipping 15 matching lines...) Expand all
119 CommandArtifact computeCompilationArtifact( 119 CommandArtifact computeCompilationArtifact(
120 String buildDir, 120 String buildDir,
121 String tempDir, 121 String tempDir,
122 CommandBuilder commandBuilder, 122 CommandBuilder commandBuilder,
123 List arguments, 123 List arguments,
124 Map<String, String> environmentOverrides) { 124 Map<String, String> environmentOverrides) {
125 return new CommandArtifact([], null, null); 125 return new CommandArtifact([], null, null);
126 } 126 }
127 127
128 List<String> computeCompilerArguments(vmOptions, sharedOptions, args) { 128 List<String> computeCompilerArguments(vmOptions, sharedOptions, args) {
129 return new List<String>() 129 return new List<String>()..addAll(sharedOptions)..addAll(args);
130 ..addAll(sharedOptions)
131 ..addAll(args);
132 } 130 }
133 131
134 List<String> computeRuntimeArguments( 132 List<String> computeRuntimeArguments(
135 RuntimeConfiguration runtimeConfiguration, 133 RuntimeConfiguration runtimeConfiguration,
136 String buildDir, 134 String buildDir,
137 TestInformation info, 135 TestInformation info,
138 List<String> vmOptions, 136 List<String> vmOptions,
139 List<String> sharedOptions, 137 List<String> sharedOptions,
140 List<String> originalArguments, 138 List<String> originalArguments,
141 CommandArtifact artifact) { 139 CommandArtifact artifact) {
142 return <String>[artifact.filename]; 140 return <String>[artifact.filename];
143 } 141 }
144 } 142 }
145 143
146 /// The "none" compiler. 144 /// The "none" compiler.
147 class NoneCompilerConfiguration extends CompilerConfiguration { 145 class NoneCompilerConfiguration extends CompilerConfiguration {
148 146 NoneCompilerConfiguration(
149 NoneCompilerConfiguration({ 147 {bool isDebug, bool isChecked, bool isHostChecked, bool useSdk})
150 bool isDebug,
151 bool isChecked,
152 bool isHostChecked,
153 bool useSdk})
154 : super._subclass( 148 : super._subclass(
155 isDebug: isDebug, isChecked: isChecked, 149 isDebug: isDebug,
156 isHostChecked: isHostChecked, useSdk: useSdk); 150 isChecked: isChecked,
151 isHostChecked: isHostChecked,
152 useSdk: useSdk);
157 153
158 bool get hasCompiler => false; 154 bool get hasCompiler => false;
159 155
160 List<String> computeRuntimeArguments( 156 List<String> computeRuntimeArguments(
161 RuntimeConfiguration runtimeConfiguration, 157 RuntimeConfiguration runtimeConfiguration,
162 String buildDir, 158 String buildDir,
163 TestInformation info, 159 TestInformation info,
164 List<String> vmOptions, 160 List<String> vmOptions,
165 List<String> sharedOptions, 161 List<String> sharedOptions,
166 List<String> originalArguments, 162 List<String> originalArguments,
167 CommandArtifact artifact) { 163 CommandArtifact artifact) {
168 List<String> args = []; 164 List<String> args = [];
169 if (isChecked) { 165 if (isChecked) {
170 args.add('--enable_asserts'); 166 args.add('--enable_asserts');
171 args.add('--enable_type_checks'); 167 args.add('--enable_type_checks');
172 } 168 }
173 return args 169 return args
174 ..addAll(vmOptions) 170 ..addAll(vmOptions)
175 ..addAll(sharedOptions) 171 ..addAll(sharedOptions)
176 ..addAll(originalArguments); 172 ..addAll(originalArguments);
177 } 173 }
178 } 174 }
179 175
180 /// Common configuration for dart2js-based tools, such as, dart2js 176 /// Common configuration for dart2js-based tools, such as, dart2js
181 class Dart2xCompilerConfiguration extends CompilerConfiguration { 177 class Dart2xCompilerConfiguration extends CompilerConfiguration {
182 final String moniker; 178 final String moniker;
183 static Map<String, List<Uri>> _bootstrapDependenciesCache = 179 static Map<String, List<Uri>> _bootstrapDependenciesCache =
184 new Map<String, List<Uri>>(); 180 new Map<String, List<Uri>>();
185 181
186 Dart2xCompilerConfiguration( 182 Dart2xCompilerConfiguration(this.moniker,
187 this.moniker, 183 {bool isDebug, bool isChecked, bool isHostChecked, bool useSdk})
188 {bool isDebug,
189 bool isChecked,
190 bool isHostChecked,
191 bool useSdk})
192 : super._subclass( 184 : super._subclass(
193 isDebug: isDebug, isChecked: isChecked, 185 isDebug: isDebug,
194 isHostChecked: isHostChecked, useSdk: useSdk); 186 isChecked: isChecked,
187 isHostChecked: isHostChecked,
188 useSdk: useSdk);
195 189
196 String computeCompilerPath(String buildDir) { 190 String computeCompilerPath(String buildDir) {
197 var prefix = 'sdk/bin'; 191 var prefix = 'sdk/bin';
198 String suffix = executableScriptSuffix; 192 String suffix = executableScriptSuffix;
199 if (isHostChecked) { 193 if (isHostChecked) {
200 // The script dart2js_developer is not included in the 194 // The script dart2js_developer is not included in the
201 // shipped SDK, that is the script is not installed in 195 // shipped SDK, that is the script is not installed in
202 // "$buildDir/dart-sdk/bin/" 196 // "$buildDir/dart-sdk/bin/"
203 return '$prefix/dart2js_developer$suffix'; 197 return '$prefix/dart2js_developer$suffix';
204 } else { 198 } else {
205 if (useSdk) { 199 if (useSdk) {
206 prefix = '$buildDir/dart-sdk/bin'; 200 prefix = '$buildDir/dart-sdk/bin';
207 } 201 }
208 return '$prefix/dart2js$suffix'; 202 return '$prefix/dart2js$suffix';
209 } 203 }
210 } 204 }
211 205
212 CompilationCommand computeCompilationCommand( 206 CompilationCommand computeCompilationCommand(
213 String outputFileName, 207 String outputFileName,
214 String buildDir, 208 String buildDir,
215 CommandBuilder commandBuilder, 209 CommandBuilder commandBuilder,
216 List arguments, 210 List arguments,
217 Map<String, String> environmentOverrides) { 211 Map<String, String> environmentOverrides) {
218 arguments = new List.from(arguments); 212 arguments = new List.from(arguments);
219 arguments.add('--out=$outputFileName'); 213 arguments.add('--out=$outputFileName');
220 214
221 return commandBuilder.getCompilationCommand( 215 return commandBuilder.getCompilationCommand(
222 moniker, outputFileName, !useSdk, 216 moniker,
217 outputFileName,
218 !useSdk,
223 bootstrapDependencies(buildDir), 219 bootstrapDependencies(buildDir),
224 computeCompilerPath(buildDir), 220 computeCompilerPath(buildDir),
225 arguments, environmentOverrides); 221 arguments,
222 environmentOverrides);
226 } 223 }
227 224
228 List<Uri> bootstrapDependencies(String buildDir) { 225 List<Uri> bootstrapDependencies(String buildDir) {
229 if (!useSdk) return const <Uri>[]; 226 if (!useSdk) return const <Uri>[];
230 return _bootstrapDependenciesCache.putIfAbsent(buildDir, () => 227 return _bootstrapDependenciesCache.putIfAbsent(
231 [Uri.base.resolveUri(nativeDirectoryToUri(buildDir)) 228 buildDir,
232 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot')]); 229 () => [
230 Uri.base
231 .resolveUri(nativeDirectoryToUri(buildDir))
232 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot')
233 ]);
233 } 234 }
234 } 235 }
235 236
236 /// Configuration for dart2js compiler. 237 /// Configuration for dart2js compiler.
237 class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration { 238 class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration {
238 final bool isCsp; 239 final bool isCsp;
239 final bool useCps; 240 final bool useCps;
240 final List<String> extraDart2jsOptions; 241 final List<String> extraDart2jsOptions;
241 // We cache the extended environment to save memory. 242 // We cache the extended environment to save memory.
242 static Map<String, String> cpsFlagCache; 243 static Map<String, String> cpsFlagCache;
243 static Map<String, String> environmentOverridesCacheObject; 244 static Map<String, String> environmentOverridesCacheObject;
244 245
245 Dart2jsCompilerConfiguration({ 246 Dart2jsCompilerConfiguration(
246 bool isDebug, 247 {bool isDebug,
247 bool isChecked, 248 bool isChecked,
248 bool isHostChecked, 249 bool isHostChecked,
249 bool useSdk, 250 bool useSdk,
250 bool this.useCps, 251 bool this.useCps,
251 bool this.isCsp, 252 bool this.isCsp,
252 this.extraDart2jsOptions}) 253 this.extraDart2jsOptions})
253 : super( 254 : super('dart2js',
254 'dart2js', 255 isDebug: isDebug,
255 isDebug: isDebug, isChecked: isChecked, 256 isChecked: isChecked,
256 isHostChecked: isHostChecked, useSdk: useSdk); 257 isHostChecked: isHostChecked,
258 useSdk: useSdk);
257 259
258 int computeTimeoutMultiplier() { 260 int computeTimeoutMultiplier() {
259 int multiplier = 1; 261 int multiplier = 1;
260 if (isDebug) multiplier *= 4; 262 if (isDebug) multiplier *= 4;
261 if (isChecked) multiplier *= 2; 263 if (isChecked) multiplier *= 2;
262 if (isHostChecked) multiplier *= 16; 264 if (isHostChecked) multiplier *= 16;
263 return multiplier; 265 return multiplier;
264 } 266 }
265 267
266 CommandArtifact computeCompilationArtifact( 268 CommandArtifact computeCompilationArtifact(
267 String buildDir, 269 String buildDir,
268 String tempDir, 270 String tempDir,
269 CommandBuilder commandBuilder, 271 CommandBuilder commandBuilder,
270 List arguments, 272 List arguments,
271 Map<String, String> environmentOverrides) { 273 Map<String, String> environmentOverrides) {
272 List compilerArguments = new List.from(arguments) 274 List compilerArguments = new List.from(arguments)
273 ..addAll(extraDart2jsOptions); 275 ..addAll(extraDart2jsOptions);
274 return new CommandArtifact( 276 return new CommandArtifact(<Command>[
275 <Command>[ 277 this.computeCompilationCommand('$tempDir/out.js', buildDir,
276 this.computeCompilationCommand( 278 CommandBuilder.instance, compilerArguments, environmentOverrides)
277 '$tempDir/out.js', 279 ], '$tempDir/out.js', 'application/javascript');
278 buildDir,
279 CommandBuilder.instance,
280 compilerArguments,
281 environmentOverrides)],
282 '$tempDir/out.js',
283 'application/javascript');
284 } 280 }
285 281
286 List<String> computeRuntimeArguments( 282 List<String> computeRuntimeArguments(
287 RuntimeConfiguration runtimeConfiguration, 283 RuntimeConfiguration runtimeConfiguration,
288 String buildDir, 284 String buildDir,
289 TestInformation info, 285 TestInformation info,
290 List<String> vmOptions, 286 List<String> vmOptions,
291 List<String> sharedOptions, 287 List<String> sharedOptions,
292 List<String> originalArguments, 288 List<String> originalArguments,
293 CommandArtifact artifact) { 289 CommandArtifact artifact) {
294 Uri sdk = useSdk ? 290 Uri sdk = useSdk
295 nativeDirectoryToUri(buildDir).resolve('dart-sdk/') : 291 ? nativeDirectoryToUri(buildDir).resolve('dart-sdk/')
296 nativeDirectoryToUri(TestUtils.dartDir.toNativePath()).resolve('sdk/'); 292 : nativeDirectoryToUri(TestUtils.dartDir.toNativePath())
297 Uri preambleDir = sdk.resolve( 293 .resolve('sdk/');
298 'lib/_internal/js_runtime/lib/preambles/'); 294 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/');
299 return runtimeConfiguration.dart2jsPreambles(preambleDir) 295 return runtimeConfiguration.dart2jsPreambles(preambleDir)
300 ..add(artifact.filename); 296 ..add(artifact.filename);
301 } 297 }
302 } 298 }
303 299
304
305 class PrecompilerCompilerConfiguration extends CompilerConfiguration { 300 class PrecompilerCompilerConfiguration extends CompilerConfiguration {
306 final String arch; 301 final String arch;
307 302
308 PrecompilerCompilerConfiguration({ 303 PrecompilerCompilerConfiguration({bool isDebug, bool isChecked, String arch})
309 bool isDebug, 304 : super._subclass(isDebug: isDebug, isChecked: isChecked),
310 bool isChecked, 305 arch = arch;
311 String arch})
312 : super._subclass(isDebug: isDebug, isChecked: isChecked), arch = arch;
313 306
314 int computeTimeoutMultiplier() { 307 int computeTimeoutMultiplier() {
315 int multiplier = 2; 308 int multiplier = 2;
316 if (isDebug) multiplier *= 4; 309 if (isDebug) multiplier *= 4;
317 if (isChecked) multiplier *= 2; 310 if (isChecked) multiplier *= 2;
318 return multiplier; 311 return multiplier;
319 } 312 }
320 313
321 CommandArtifact computeCompilationArtifact( 314 CommandArtifact computeCompilationArtifact(
322 String buildDir, 315 String buildDir,
323 String tempDir, 316 String tempDir,
324 CommandBuilder commandBuilder, 317 CommandBuilder commandBuilder,
325 List arguments, 318 List arguments,
326 Map<String, String> environmentOverrides) { 319 Map<String, String> environmentOverrides) {
327 return new CommandArtifact( 320 return new CommandArtifact(<Command>[
328 <Command>[ 321 this.computeCompilationCommand(tempDir, buildDir, CommandBuilder.instance,
329 this.computeCompilationCommand( 322 arguments, environmentOverrides),
330 tempDir, 323 this.computeAssembleCommand(tempDir, buildDir, CommandBuilder.instance,
331 buildDir, 324 arguments, environmentOverrides),
332 CommandBuilder.instance, 325 this.computeRemoveAssemblyCommand(tempDir, buildDir,
333 arguments, 326 CommandBuilder.instance, arguments, environmentOverrides)
334 environmentOverrides), 327 ], '$tempDir', 'application/dart-precompiled');
335 this.computeAssembleCommand(
336 tempDir,
337 buildDir,
338 CommandBuilder.instance,
339 arguments,
340 environmentOverrides),
341 this.computeRemoveAssemblyCommand(
342 tempDir,
343 buildDir,
344 CommandBuilder.instance,
345 arguments,
346 environmentOverrides)],
347 '$tempDir',
348 'application/dart-precompiled');
349 } 328 }
350 329
351 CompilationCommand computeCompilationCommand( 330 CompilationCommand computeCompilationCommand(
352 String tempDir, 331 String tempDir,
353 String buildDir, 332 String buildDir,
354 CommandBuilder commandBuilder, 333 CommandBuilder commandBuilder,
355 List arguments, 334 List arguments,
356 Map<String, String> environmentOverrides) { 335 Map<String, String> environmentOverrides) {
357 var exec = "$buildDir/dart_bootstrap"; 336 var exec = "$buildDir/dart_bootstrap";
358 var args = new List(); 337 var args = new List();
359 args.add("--gen-precompiled-snapshot=$tempDir"); 338 args.add("--gen-precompiled-snapshot=$tempDir");
360 args.addAll(arguments); 339 args.addAll(arguments);
361 340
362 return commandBuilder.getCompilationCommand( 341 return commandBuilder.getCompilationCommand('precompiler', tempDir, !useSdk,
363 'precompiler', tempDir, !useSdk, 342 bootstrapDependencies(buildDir), exec, args, environmentOverrides);
364 bootstrapDependencies(buildDir),
365 exec, args, environmentOverrides);
366 } 343 }
367 344
368 CompilationCommand computeAssembleCommand( 345 CompilationCommand computeAssembleCommand(
369 String tempDir, 346 String tempDir,
370 String buildDir, 347 String buildDir,
371 CommandBuilder commandBuilder, 348 CommandBuilder commandBuilder,
372 List arguments, 349 List arguments,
373 Map<String, String> environmentOverrides) { 350 Map<String, String> environmentOverrides) {
374 var cc, cc_flags, shared, libname; 351 var cc, cc_flags, shared, libname;
375 if (Platform.isLinux) { 352 if (Platform.isLinux) {
(...skipping 18 matching lines...) Expand all
394 cc_flags = "-m32"; 371 cc_flags = "-m32";
395 } else if (arch == 'arm') { 372 } else if (arch == 'arm') {
396 cc_flags = ""; 373 cc_flags = "";
397 } else if (arch == 'mips') { 374 } else if (arch == 'mips') {
398 cc_flags = "-EL"; 375 cc_flags = "-EL";
399 } else { 376 } else {
400 throw "Architecture not supported: $arch"; 377 throw "Architecture not supported: $arch";
401 } 378 }
402 379
403 var exec = cc; 380 var exec = cc;
404 var args = [shared, 381 var args = [
405 cc_flags, 382 shared,
406 '-o', 383 cc_flags,
407 '$tempDir/$libname', 384 '-o',
408 '$tempDir/precompiled.S']; 385 '$tempDir/$libname',
386 '$tempDir/precompiled.S'
387 ];
409 388
410 return commandBuilder.getCompilationCommand( 389 return commandBuilder.getCompilationCommand('assemble', tempDir, !useSdk,
411 'assemble', tempDir, !useSdk, 390 bootstrapDependencies(buildDir), exec, args, environmentOverrides);
412 bootstrapDependencies(buildDir),
413 exec, args, environmentOverrides);
414 } 391 }
415 392
416 // This step reduces the amount of space needed to run the precompilation 393 // This step reduces the amount of space needed to run the precompilation
417 // tests by 60%. 394 // tests by 60%.
418 CompilationCommand computeRemoveAssemblyCommand( 395 CompilationCommand computeRemoveAssemblyCommand(
419 String tempDir, 396 String tempDir,
420 String buildDir, 397 String buildDir,
421 CommandBuilder commandBuilder, 398 CommandBuilder commandBuilder,
422 List arguments, 399 List arguments,
423 Map<String, String> environmentOverrides) { 400 Map<String, String> environmentOverrides) {
424 var exec = 'rm'; 401 var exec = 'rm';
425 var args = ['$tempDir/precompiled.S']; 402 var args = ['$tempDir/precompiled.S'];
426 403
427 return commandBuilder.getCompilationCommand( 404 return commandBuilder.getCompilationCommand(
428 'remove_assembly', tempDir, !useSdk, 405 'remove_assembly',
406 tempDir,
407 !useSdk,
429 bootstrapDependencies(buildDir), 408 bootstrapDependencies(buildDir),
430 exec, args, environmentOverrides); 409 exec,
410 args,
411 environmentOverrides);
431 } 412 }
432 413
433 List<String> filterVmOptions(List<String> vmOptions) { 414 List<String> filterVmOptions(List<String> vmOptions) {
434 var filtered = new List.from(vmOptions); 415 var filtered = new List.from(vmOptions);
435 filtered.removeWhere( 416 filtered.removeWhere(
436 (option) => option.startsWith("--optimization-counter-threshold")); 417 (option) => option.startsWith("--optimization-counter-threshold"));
437 filtered.removeWhere( 418 filtered.removeWhere(
438 (option) => option.startsWith("--optimization_counter_threshold")); 419 (option) => option.startsWith("--optimization_counter_threshold"));
439 return filtered; 420 return filtered;
440 } 421 }
441 422
442 List<String> computeCompilerArguments(vmOptions, 423 List<String> computeCompilerArguments(
443 sharedOptions, 424 vmOptions, sharedOptions, originalArguments) {
444 originalArguments) {
445 List<String> args = []; 425 List<String> args = [];
446 if (isChecked) { 426 if (isChecked) {
447 args.add('--enable_asserts'); 427 args.add('--enable_asserts');
448 args.add('--enable_type_checks'); 428 args.add('--enable_type_checks');
449 } 429 }
450 return args 430 return args
451 ..addAll(filterVmOptions(vmOptions)) 431 ..addAll(filterVmOptions(vmOptions))
452 ..addAll(sharedOptions) 432 ..addAll(sharedOptions)
453 ..addAll(originalArguments); 433 ..addAll(originalArguments);
454 } 434 }
455 435
456 List<String> computeRuntimeArguments( 436 List<String> computeRuntimeArguments(
457 RuntimeConfiguration runtimeConfiguration, 437 RuntimeConfiguration runtimeConfiguration,
458 String buildDir, 438 String buildDir,
459 TestInformation info, 439 TestInformation info,
460 List<String> vmOptions, 440 List<String> vmOptions,
461 List<String> sharedOptions, 441 List<String> sharedOptions,
462 List<String> originalArguments, 442 List<String> originalArguments,
463 CommandArtifact artifact) { 443 CommandArtifact artifact) {
464 List<String> args = []; 444 List<String> args = [];
465 if (isChecked) { 445 if (isChecked) {
466 args.add('--enable_asserts'); 446 args.add('--enable_asserts');
467 args.add('--enable_type_checks'); 447 args.add('--enable_type_checks');
468 } 448 }
469 return args 449 return args
470 ..addAll(vmOptions) 450 ..addAll(vmOptions)
471 ..addAll(sharedOptions) 451 ..addAll(sharedOptions)
472 ..addAll(originalArguments); 452 ..addAll(originalArguments);
473 } 453 }
474 } 454 }
475 455
476
477 class Dart2AppSnapshotCompilerConfiguration extends CompilerConfiguration { 456 class Dart2AppSnapshotCompilerConfiguration extends CompilerConfiguration {
478 Dart2AppSnapshotCompilerConfiguration({ 457 Dart2AppSnapshotCompilerConfiguration({bool isDebug, bool isChecked})
479 bool isDebug,
480 bool isChecked})
481 : super._subclass(isDebug: isDebug, isChecked: isChecked); 458 : super._subclass(isDebug: isDebug, isChecked: isChecked);
482 459
483 int computeTimeoutMultiplier() { 460 int computeTimeoutMultiplier() {
484 int multiplier = 2; 461 int multiplier = 2;
485 if (isDebug) multiplier *= 4; 462 if (isDebug) multiplier *= 4;
486 if (isChecked) multiplier *= 2; 463 if (isChecked) multiplier *= 2;
487 return multiplier; 464 return multiplier;
488 } 465 }
489 466
490 CommandArtifact computeCompilationArtifact( 467 CommandArtifact computeCompilationArtifact(
491 String buildDir, 468 String buildDir,
492 String tempDir, 469 String tempDir,
493 CommandBuilder commandBuilder, 470 CommandBuilder commandBuilder,
494 List arguments, 471 List arguments,
495 Map<String, String> environmentOverrides) { 472 Map<String, String> environmentOverrides) {
496 String outputName = computeOutputName(tempDir); 473 String outputName = computeOutputName(tempDir);
497 return new CommandArtifact( 474 return new CommandArtifact(<Command>[
498 <Command>[ 475 this.computeCompilationCommand(outputName, buildDir,
499 this.computeCompilationCommand( 476 CommandBuilder.instance, arguments, environmentOverrides)
500 outputName, 477 ], outputName, 'application/dart-snapshot');
501 buildDir,
502 CommandBuilder.instance,
503 arguments,
504 environmentOverrides)],
505 outputName,
506 'application/dart-snapshot');
507 } 478 }
508 479
509 String computeOutputName(String tempDir) { 480 String computeOutputName(String tempDir) {
510 var randName = TestUtils.getRandomNumber().toString(); 481 var randName = TestUtils.getRandomNumber().toString();
511 return '$tempDir/test.$randName'; 482 return '$tempDir/test.$randName';
512 } 483 }
513 484
514 CompilationCommand computeCompilationCommand( 485 CompilationCommand computeCompilationCommand(
515 String outputName, 486 String outputName,
516 String buildDir, 487 String buildDir,
517 CommandBuilder commandBuilder, 488 CommandBuilder commandBuilder,
518 List arguments, 489 List arguments,
519 Map<String, String> environmentOverrides) { 490 Map<String, String> environmentOverrides) {
520 var exec = "$buildDir/dart_bootstrap"; 491 var exec = "$buildDir/dart_bootstrap";
521 var args = new List(); 492 var args = new List();
522 args.add("--full-snapshot-after-run=$outputName"); 493 args.add("--full-snapshot-after-run=$outputName");
523 args.addAll(arguments); 494 args.addAll(arguments);
524 495
525 return commandBuilder.getCompilationCommand( 496 return commandBuilder.getCompilationCommand(
526 'dart2snapshot', outputName, !useSdk, 497 'dart2snapshot',
498 outputName,
499 !useSdk,
527 bootstrapDependencies(buildDir), 500 bootstrapDependencies(buildDir),
528 exec, args, environmentOverrides); 501 exec,
502 args,
503 environmentOverrides);
529 } 504 }
530 505
531 List<String> computeCompilerArguments(vmOptions, 506 List<String> computeCompilerArguments(
532 sharedOptions, 507 vmOptions, sharedOptions, originalArguments) {
533 originalArguments) {
534 List<String> args = []; 508 List<String> args = [];
535 if (isChecked) { 509 if (isChecked) {
536 args.add('--enable_asserts'); 510 args.add('--enable_asserts');
537 args.add('--enable_type_checks'); 511 args.add('--enable_type_checks');
538 } 512 }
539 return args 513 return args
540 ..addAll(vmOptions) 514 ..addAll(vmOptions)
541 ..addAll(sharedOptions) 515 ..addAll(sharedOptions)
542 ..addAll(originalArguments); 516 ..addAll(originalArguments);
543 } 517 }
544 518
545 List<String> computeRuntimeArguments( 519 List<String> computeRuntimeArguments(
546 RuntimeConfiguration runtimeConfiguration, 520 RuntimeConfiguration runtimeConfiguration,
547 String buildDir, 521 String buildDir,
548 TestInformation info, 522 TestInformation info,
549 List<String> vmOptions, 523 List<String> vmOptions,
550 List<String> sharedOptions, 524 List<String> sharedOptions,
551 List<String> originalArguments, 525 List<String> originalArguments,
552 CommandArtifact artifact) { 526 CommandArtifact artifact) {
553 List<String> args = []; 527 List<String> args = [];
554 if (isChecked) { 528 if (isChecked) {
555 args.add('--enable_asserts'); 529 args.add('--enable_asserts');
556 args.add('--enable_type_checks'); 530 args.add('--enable_type_checks');
557 } 531 }
558 return args 532 return args
559 ..addAll(vmOptions) 533 ..addAll(vmOptions)
560 ..addAll(sharedOptions) 534 ..addAll(sharedOptions)
561 ..addAll(originalArguments); 535 ..addAll(originalArguments);
562 } 536 }
563 } 537 }
564 538
565
566 class AnalyzerCompilerConfiguration extends CompilerConfiguration { 539 class AnalyzerCompilerConfiguration extends CompilerConfiguration {
567 AnalyzerCompilerConfiguration( 540 AnalyzerCompilerConfiguration(
568 {bool isDebug, 541 {bool isDebug, bool isChecked, bool isHostChecked, bool useSdk})
569 bool isChecked,
570 bool isHostChecked,
571 bool useSdk})
572 : super._subclass( 542 : super._subclass(
573 isDebug: isDebug, isChecked: isChecked, 543 isDebug: isDebug,
574 isHostChecked: isHostChecked, useSdk: useSdk); 544 isChecked: isChecked,
545 isHostChecked: isHostChecked,
546 useSdk: useSdk);
575 547
576 int computeTimeoutMultiplier() { 548 int computeTimeoutMultiplier() {
577 return 4; 549 return 4;
578 } 550 }
579 551
580 String computeCompilerPath(String buildDir) { 552 String computeCompilerPath(String buildDir) {
581 var prefix = 'sdk/bin'; 553 var prefix = 'sdk/bin';
582 String suffix = executableScriptSuffix; 554 String suffix = executableScriptSuffix;
583 if (isHostChecked) { 555 if (isHostChecked) {
584 if (useSdk) { 556 if (useSdk) {
(...skipping 13 matching lines...) Expand all
598 CommandArtifact computeCompilationArtifact( 570 CommandArtifact computeCompilationArtifact(
599 String buildDir, 571 String buildDir,
600 String tempDir, 572 String tempDir,
601 CommandBuilder commandBuilder, 573 CommandBuilder commandBuilder,
602 List arguments, 574 List arguments,
603 Map<String, String> environmentOverrides) { 575 Map<String, String> environmentOverrides) {
604 arguments = new List.from(arguments); 576 arguments = new List.from(arguments);
605 if (isChecked) { 577 if (isChecked) {
606 arguments.add('--enable_type_checks'); 578 arguments.add('--enable_type_checks');
607 } 579 }
608 return new CommandArtifact( 580 return new CommandArtifact(<Command>[
609 <Command>[ 581 commandBuilder.getAnalysisCommand('dart2analyzer',
610 commandBuilder.getAnalysisCommand( 582 computeCompilerPath(buildDir), arguments, environmentOverrides,
611 'dart2analyzer', computeCompilerPath(buildDir), arguments, 583 flavor: 'dart2analyzer')
612 environmentOverrides, 584 ], null, null); // Since this is not a real compilation, no artifacts are
613 flavor: 'dart2analyzer')], 585 // produced.
614 null, null); // Since this is not a real compilation, no artifacts are
615 // produced.
616 } 586 }
617 587
618 List<String> computeRuntimeArguments( 588 List<String> computeRuntimeArguments(
619 RuntimeConfiguration runtimeConfiguration, 589 RuntimeConfiguration runtimeConfiguration,
620 String buildDir, 590 String buildDir,
621 TestInformation info, 591 TestInformation info,
622 List<String> vmOptions, 592 List<String> vmOptions,
623 List<String> sharedOptions, 593 List<String> sharedOptions,
624 List<String> originalArguments, 594 List<String> originalArguments,
625 CommandArtifact artifact) { 595 CommandArtifact artifact) {
626 return <String>[]; 596 return <String>[];
627 } 597 }
628 } 598 }
OLDNEW
« no previous file with comments | « tools/testing/dart/co19_test_config.dart ('k') | tools/testing/dart/dependency_graph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698