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

Unified Diff: tools/testing/dart/compiler_configuration.dart

Issue 2914893003: Revert "Replace the configuration map with a typed object." (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/testing/dart/co19_test_config.dart ('k') | tools/testing/dart/configuration.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/compiler_configuration.dart
diff --git a/tools/testing/dart/compiler_configuration.dart b/tools/testing/dart/compiler_configuration.dart
index fcdd979305da5cc9f4d20ac0ecf57b714fdbe18d..e63dbbb38d5390f69cb49d46509a125e5e6338d3 100644
--- a/tools/testing/dart/compiler_configuration.dart
+++ b/tools/testing/dart/compiler_configuration.dart
@@ -2,12 +2,14 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:io';
+library compiler_configuration;
-import 'configuration.dart';
-import 'runtime_configuration.dart';
-import 'test_runner.dart';
-import 'test_suite.dart';
+import 'dart:io' show Platform;
+
+import 'runtime_configuration.dart' show RuntimeConfiguration;
+import 'runtime_configuration.dart' show DartPrecompiledAdbRuntimeConfiguration;
+import 'test_runner.dart' show Command, CommandBuilder, CompilationCommand;
+import 'test_suite.dart' show TestInformation, TestUtils;
List<String> replaceDartFileWith(List<String> list, String replacement) {
var copy = new List<String>.from(list);
@@ -51,70 +53,84 @@ abstract class CompilerConfiguration {
throw new UnsupportedError("This compiler does not support DFE.");
}
- factory CompilerConfiguration(Configuration configuration) {
- switch (configuration.compiler) {
- case Compiler.dart2analyzer:
+ // TODO(ahe): Remove this constructor and move the switch to
+ // test_options.dart. We probably want to store an instance of
+ // [CompilerConfiguration] in [configuration] there.
+ factory CompilerConfiguration(Map<String, dynamic> configuration) {
+ var compiler = configuration['compiler'] as String;
+
+ // TODO(ahe): Move these booleans into a struction configuration object
+ // which can eventually completely replace the Map-based configuration
+ // object.
+ var isDebug = (configuration['mode'] as String) == 'debug';
+ var isChecked = configuration['checked'] as bool;
+ var isStrong = configuration['strong'] as bool;
+ var isHostChecked = configuration['host_checked'] as bool;
+ var useSdk = configuration['use_sdk'] as bool;
+ var isCsp = configuration['csp'] as bool;
+ var useBlobs = configuration['use_blobs'] as bool;
+ var hotReload = configuration['hot_reload'] as bool;
+ var hotReloadRollback = configuration['hot_reload_rollback'] as bool;
+ var useFastStartup = configuration['fast_startup'] as bool;
+ var useKernelInDart2js = configuration['dart2js_with_kernel'] as bool;
+
+ switch (compiler) {
+ case 'dart2analyzer':
return new AnalyzerCompilerConfiguration(
- isDebug: configuration.mode.isDebug,
- isChecked: configuration.isChecked,
- isStrong: configuration.isStrong,
- isHostChecked: configuration.isHostChecked,
- useSdk: configuration.useSdk);
-
- case Compiler.dart2js:
+ isDebug: isDebug,
+ isChecked: isChecked,
+ isStrong: isStrong,
+ isHostChecked: isHostChecked,
+ useSdk: useSdk);
+ case 'dart2js':
return new Dart2jsCompilerConfiguration(
- isDebug: configuration.mode.isDebug,
- isChecked: configuration.isChecked,
- isHostChecked: configuration.isHostChecked,
- useSdk: configuration.useSdk,
- isCsp: configuration.isCsp,
- useFastStartup: configuration.useFastStartup,
- useKernel: configuration.useDart2JSWithKernel,
- extraDart2jsOptions: configuration.dart2jsOptions);
-
- case Compiler.appJit:
+ isDebug: isDebug,
+ isChecked: isChecked,
+ isHostChecked: isHostChecked,
+ useSdk: useSdk,
+ isCsp: isCsp,
+ useFastStartup: useFastStartup,
+ useKernel: useKernelInDart2js,
+ extraDart2jsOptions:
+ TestUtils.getExtraOptions(configuration, 'dart2js_options'));
+ case 'app_jit':
return new AppJitCompilerConfiguration(
- isDebug: configuration.mode.isDebug,
- isChecked: configuration.isChecked);
-
- case Compiler.precompiler:
+ isDebug: isDebug, isChecked: isChecked);
+ case 'precompiler':
return new PrecompilerCompilerConfiguration(
- isDebug: configuration.mode.isDebug,
- isChecked: configuration.isChecked,
- arch: configuration.architecture,
- useBlobs: configuration.useBlobs,
- isAndroid: configuration.system == System.android);
-
- case Compiler.dartk:
+ isDebug: isDebug,
+ isChecked: isChecked,
+ arch: configuration['arch'] as String,
+ useBlobs: useBlobs,
+ isAndroid: configuration['system'] == 'android');
+ case 'dartk':
return new NoneCompilerConfiguration(
- isDebug: configuration.mode.isDebug,
- isChecked: configuration.isChecked,
- isHostChecked: configuration.isHostChecked,
- useSdk: configuration.useSdk,
- hotReload: configuration.hotReload,
- hotReloadRollback: configuration.hotReloadRollback,
+ isDebug: isDebug,
+ isChecked: isChecked,
+ isHostChecked: isHostChecked,
+ useSdk: useSdk,
+ hotReload: hotReload,
+ hotReloadRollback: hotReloadRollback,
useDfe: true);
-
- case Compiler.dartkp:
+ case 'dartkp':
return new PrecompilerCompilerConfiguration(
- isDebug: configuration.mode.isDebug,
- isChecked: configuration.isChecked,
- arch: configuration.architecture,
- useBlobs: configuration.useBlobs,
- isAndroid: configuration.system == System.android,
+ isDebug: isDebug,
+ isChecked: isChecked,
+ arch: configuration['arch'] as String,
+ useBlobs: useBlobs,
+ isAndroid: configuration['system'] == 'android',
useDfe: true);
-
- case Compiler.none:
+ case 'none':
return new NoneCompilerConfiguration(
- isDebug: configuration.mode.isDebug,
- isChecked: configuration.isChecked,
- isHostChecked: configuration.isHostChecked,
- useSdk: configuration.useSdk,
- hotReload: configuration.hotReload,
- hotReloadRollback: configuration.hotReloadRollback);
+ isDebug: isDebug,
+ isChecked: isChecked,
+ isHostChecked: isHostChecked,
+ useSdk: useSdk,
+ hotReload: hotReload,
+ hotReloadRollback: hotReloadRollback);
+ default:
+ throw "Unknown compiler '$compiler'";
}
-
- throw "unreachable";
}
CompilerConfiguration._subclass(
@@ -124,8 +140,11 @@ abstract class CompilerConfiguration {
this.isHostChecked: false,
this.useSdk: false});
- /// A multiplier used to give tests longer time to run.
- int get timeoutMultiplier => 1;
+ /// Return a multiplier used to give tests longer time to run.
+ // TODO(ahe): Convert to getter!
+ int computeTimeoutMultiplier() {
+ return 1;
+ }
// TODO(ahe): It shouldn't be necessary to pass [buildDir] to any of these
// functions. It is fixed for a given configuration.
@@ -411,7 +430,7 @@ class ComposedCompilerConfiguration extends CompilerConfiguration {
static ComposedCompilerConfiguration createDartKPConfiguration(
{bool isChecked,
bool isHostChecked,
- Architecture arch,
+ String arch,
bool useBlobs,
bool isAndroid,
bool useSdk,
@@ -541,8 +560,8 @@ class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration {
isHostChecked: isHostChecked,
useSdk: useSdk);
- int get timeoutMultiplier {
- var multiplier = 1;
+ int computeTimeoutMultiplier() {
+ int multiplier = 1;
if (isDebug) multiplier *= 4;
if (isChecked) multiplier *= 2;
if (isHostChecked) multiplier *= 16;
@@ -581,7 +600,7 @@ class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration {
}
class PrecompilerCompilerConfiguration extends CompilerConfiguration {
- final Architecture arch;
+ final String arch;
final bool useBlobs;
final bool isAndroid;
final bool useDfe;
@@ -595,8 +614,8 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
this.useDfe: false})
: super._subclass(isDebug: isDebug, isChecked: isChecked);
- int get timeoutMultiplier {
- var multiplier = 2;
+ int computeTimeoutMultiplier() {
+ int multiplier = 2;
if (isDebug) multiplier *= 4;
if (isChecked) multiplier *= 2;
return multiplier;
@@ -629,9 +648,9 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
Map<String, String> environmentOverrides) {
String exec;
if (isAndroid) {
- if (arch == Architecture.arm) {
+ if (arch == "arm") {
exec = "$buildDir/clang_x86/dart_bootstrap";
- } else if (arch == Architecture.arm64) {
+ } else if (arch == "arm64") {
exec = "$buildDir/clang_x64/dart_bootstrap";
}
} else {
@@ -649,7 +668,7 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
} else {
args.add("--snapshot=$tempDir/out.S");
}
- if (isAndroid && arch == Architecture.arm) {
+ if (isAndroid && arch == 'arm') {
args.add('--no-sim-use-hardfp');
}
args.addAll(arguments);
@@ -664,13 +683,13 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
CommandBuilder commandBuilder,
List arguments,
Map<String, String> environmentOverrides) {
- String cc, shared, ldFlags;
+ String cc, shared, ld_flags;
if (isAndroid) {
var ndk = "third_party/android_tools/ndk";
String triple;
- if (arch == Architecture.arm) {
+ if (arch == "arm") {
triple = "arm-linux-androideabi";
- } else if (arch == Architecture.arm64) {
+ } else if (arch == "arm64") {
triple = "aarch64-linux-android";
}
String host;
@@ -688,37 +707,36 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
cc = 'clang';
shared = '-dynamiclib';
// Tell Mac linker to give up generating eh_frame from dwarf.
- ldFlags = '-Wl,-no_compact_unwind';
+ ld_flags = '-Wl,-no_compact_unwind';
} else {
throw "Platform not supported: ${Platform.operatingSystem}";
}
- String ccFlags;
- switch (arch) {
- case Architecture.x64:
- case Architecture.simarm64:
- ccFlags = "-m64";
- break;
- case Architecture.ia32:
- case Architecture.simarm:
- case Architecture.simmips:
- ccFlags = "-m32";
- break;
- case Architecture.arm:
- case Architecture.arm64:
- ccFlags = null;
- break;
- case Architecture.mips:
- ccFlags = "-EL";
- break;
- default:
- throw "Architecture not supported: ${arch.name}";
+ String cc_flags;
+ if (arch == 'x64') {
+ cc_flags = "-m64";
+ } else if (arch == 'simarm64') {
+ cc_flags = "-m64";
+ } else if (arch == 'ia32') {
+ cc_flags = "-m32";
+ } else if (arch == 'simarm') {
+ cc_flags = "-m32";
+ } else if (arch == 'simmips') {
+ cc_flags = "-m32";
+ } else if (arch == 'arm') {
+ cc_flags = null;
+ } else if (arch == 'arm64') {
+ cc_flags = null;
+ } else if (arch == 'mips') {
+ cc_flags = "-EL";
+ } else {
+ throw "Architecture not supported: $arch";
}
var exec = cc;
var args = <String>[];
- if (ccFlags != null) args.add(ccFlags);
- if (ldFlags != null) args.add(ldFlags);
+ if (cc_flags != null) args.add(cc_flags);
+ if (ld_flags != null) args.add(ld_flags);
args.add(shared);
args.add('-nostdlib');
args.add('-o');
@@ -806,8 +824,8 @@ class AppJitCompilerConfiguration extends CompilerConfiguration {
AppJitCompilerConfiguration({bool isDebug, bool isChecked})
: super._subclass(isDebug: isDebug, isChecked: isChecked);
- int get timeoutMultiplier {
- var multiplier = 1;
+ int computeTimeoutMultiplier() {
+ int multiplier = 1;
if (isDebug) multiplier *= 2;
if (isChecked) multiplier *= 2;
return multiplier;
@@ -891,7 +909,9 @@ class AnalyzerCompilerConfiguration extends CompilerConfiguration {
isHostChecked: isHostChecked,
useSdk: useSdk);
- int get timeoutMultiplier => 4;
+ int computeTimeoutMultiplier() {
+ return 4;
+ }
String computeCompilerPath(String buildDir) {
var prefix = 'sdk/bin';
« no previous file with comments | « tools/testing/dart/co19_test_config.dart ('k') | tools/testing/dart/configuration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698