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 library compiler_configuration; | 5 library compiler_configuration; |
6 | 6 |
7 import 'dart:io' show | 7 import 'dart:io' show |
8 Platform; | 8 Platform; |
9 | 9 |
10 import 'runtime_configuration.dart' show | 10 import 'runtime_configuration.dart' show |
11 RuntimeConfiguration; | 11 RuntimeConfiguration; |
12 | 12 |
13 import 'test_runner.dart' show | 13 import 'test_runner.dart' show |
14 Command, | 14 Command, |
15 CommandBuilder, | 15 CommandBuilder, |
16 CompilationCommand; | 16 CompilationCommand; |
17 | 17 |
18 import 'test_suite.dart' show | 18 import 'test_suite.dart' show |
19 TestInformation, | 19 TestInformation, |
20 TestUtils; | 20 TestUtils; |
21 | 21 |
22 import 'fletch_session_command.dart' show | 22 import 'dartino_session_command.dart' show |
23 FletchSessionCommand; | 23 DartinoSessionCommand; |
24 | 24 |
25 /// Grouping of a command with its expected result. | 25 /// Grouping of a command with its expected result. |
26 class CommandArtifact { | 26 class CommandArtifact { |
27 final List<Command> commands; | 27 final List<Command> commands; |
28 | 28 |
29 /// Expected result of running [command]. | 29 /// Expected result of running [command]. |
30 final String filename; | 30 final String filename; |
31 | 31 |
32 /// MIME type of [filename]. | 32 /// MIME type of [filename]. |
33 final String mimeType; | 33 final String mimeType; |
(...skipping 24 matching lines...) Expand all Loading... |
58 // TODO(ahe): Move these booleans into a struction configuration object | 58 // TODO(ahe): Move these booleans into a struction configuration object |
59 // which can eventually completely replace the Map-based configuration | 59 // which can eventually completely replace the Map-based configuration |
60 // object. | 60 // object. |
61 bool isDebug = configuration['mode'] == 'debug'; | 61 bool isDebug = configuration['mode'] == 'debug'; |
62 bool isChecked = configuration['checked']; | 62 bool isChecked = configuration['checked']; |
63 bool isHostChecked = configuration['host_checked']; | 63 bool isHostChecked = configuration['host_checked']; |
64 bool useSdk = configuration['use_sdk']; | 64 bool useSdk = configuration['use_sdk']; |
65 bool isCsp = configuration['csp']; | 65 bool isCsp = configuration['csp']; |
66 | 66 |
67 switch (compiler) { | 67 switch (compiler) { |
68 case 'fletchc': | 68 case 'dartino_compiler': |
69 return new FletchCCompilerConfiguration( | 69 return new DartinoCCompilerConfiguration( |
70 isDebug: isDebug, isChecked: isChecked, | 70 isDebug: isDebug, isChecked: isChecked, |
71 isHostChecked: isHostChecked, useSdk: useSdk); | 71 isHostChecked: isHostChecked, useSdk: useSdk); |
72 case 'none': | 72 case 'none': |
73 return new NoneCompilerConfiguration( | 73 return new NoneCompilerConfiguration( |
74 isDebug: isDebug, isChecked: isChecked, | 74 isDebug: isDebug, isChecked: isChecked, |
75 isHostChecked: isHostChecked, useSdk: useSdk); | 75 isHostChecked: isHostChecked, useSdk: useSdk); |
76 default: | 76 default: |
77 throw "Unknown compiler '$compiler'"; | 77 throw "Unknown compiler '$compiler'"; |
78 } | 78 } |
79 } | 79 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 this.moniker, | 163 this.moniker, |
164 {bool isDebug, | 164 {bool isDebug, |
165 bool isChecked, | 165 bool isChecked, |
166 bool isHostChecked, | 166 bool isHostChecked, |
167 bool useSdk}) | 167 bool useSdk}) |
168 : super._subclass( | 168 : super._subclass( |
169 isDebug: isDebug, isChecked: isChecked, | 169 isDebug: isDebug, isChecked: isChecked, |
170 isHostChecked: isHostChecked, useSdk: useSdk); | 170 isHostChecked: isHostChecked, useSdk: useSdk); |
171 | 171 |
172 String computeCompilerPath(String buildDir) { | 172 String computeCompilerPath(String buildDir) { |
173 return useSdk ? '$buildDir/dartino-sdk/bin/fletch-vm' | 173 return useSdk ? '$buildDir/dartino-sdk/bin/dartino-vm' |
174 : '$buildDir/fletch-vm'; | 174 : '$buildDir/dartino-vm'; |
175 } | 175 } |
176 | 176 |
177 CompilationCommand computeCompilationCommand( | 177 CompilationCommand computeCompilationCommand( |
178 String outputFileName, | 178 String outputFileName, |
179 String buildDir, | 179 String buildDir, |
180 CommandBuilder commandBuilder, | 180 CommandBuilder commandBuilder, |
181 List arguments, | 181 List arguments, |
182 Map<String, String> environmentOverrides) { | 182 Map<String, String> environmentOverrides) { |
183 arguments = new List.from(arguments); | 183 arguments = new List.from(arguments); |
184 arguments.add('--out=$outputFileName'); | 184 arguments.add('--out=$outputFileName'); |
185 | 185 |
186 return commandBuilder.getCompilationCommand( | 186 return commandBuilder.getCompilationCommand( |
187 moniker, outputFileName, !useSdk, | 187 moniker, outputFileName, !useSdk, |
188 bootstrapDependencies(buildDir), | 188 bootstrapDependencies(buildDir), |
189 computeCompilerPath(buildDir), | 189 computeCompilerPath(buildDir), |
190 arguments, environmentOverrides); | 190 arguments, environmentOverrides); |
191 } | 191 } |
192 | 192 |
193 List<Uri> bootstrapDependencies(String buildDir) { | 193 List<Uri> bootstrapDependencies(String buildDir) { |
194 if (!useSdk) return const <Uri>[]; | 194 if (!useSdk) return const <Uri>[]; |
195 | 195 |
196 Uri absoluteBuildDir = Uri.base.resolveUri(nativeDirectoryToUri(buildDir)); | 196 Uri absoluteBuildDir = Uri.base.resolveUri(nativeDirectoryToUri(buildDir)); |
197 return [absoluteBuildDir.resolve( | 197 return [absoluteBuildDir.resolve( |
198 'dart-sdk/bin/snapshots/dart2js.dart.snapshot')]; | 198 'dart-sdk/bin/snapshots/dart2js.dart.snapshot')]; |
199 } | 199 } |
200 } | 200 } |
201 | 201 |
202 class FletchCCompilerConfiguration extends Dart2xCompilerConfiguration { | 202 class DartinoCCompilerConfiguration extends Dart2xCompilerConfiguration { |
203 | 203 |
204 FletchCCompilerConfiguration({ | 204 DartinoCCompilerConfiguration({ |
205 bool isDebug, | 205 bool isDebug, |
206 bool isChecked, | 206 bool isChecked, |
207 bool isHostChecked, | 207 bool isHostChecked, |
208 bool useSdk}) | 208 bool useSdk}) |
209 : super( | 209 : super( |
210 'fletchc', | 210 'dartino_compiler', |
211 isDebug: isDebug, isChecked: isChecked, | 211 isDebug: isDebug, isChecked: isChecked, |
212 isHostChecked: isHostChecked, useSdk: useSdk) { | 212 isHostChecked: isHostChecked, useSdk: useSdk) { |
213 if (!isHostChecked) { | 213 if (!isHostChecked) { |
214 throw "fletch only works with --host-checked option."; | 214 throw "dartino only works with --host-checked option."; |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 CommandArtifact computeCompilationArtifact( | 218 CommandArtifact computeCompilationArtifact( |
219 String buildDir, | 219 String buildDir, |
220 String tempDir, | 220 String tempDir, |
221 CommandBuilder commandBuilder, | 221 CommandBuilder commandBuilder, |
222 List basicArguments, | 222 List basicArguments, |
223 Map<String, String> environmentOverrides) { | 223 Map<String, String> environmentOverrides) { |
224 String snapshotFileName = '$tempDir/fletch.snapshot'; | 224 String snapshotFileName = '$tempDir/dartino.snapshot'; |
225 String executable = useSdk ? '$buildDir/dartino-sdk/bin/fletch' | 225 String executable = useSdk ? '$buildDir/dartino-sdk/bin/dartino' |
226 : '$buildDir/fletch'; | 226 : '$buildDir/dartino'; |
227 String dart = useSdk ? '$buildDir/dartino-sdk/internal/dart' | 227 String dart = useSdk ? '$buildDir/dartino-sdk/internal/dart' |
228 : '$buildDir/dart'; | 228 : '$buildDir/dart'; |
229 Map<String, String> environment = { | 229 Map<String, String> environment = { |
230 'DART_VM' : dart, | 230 'DART_VM' : dart, |
231 }..addAll(environmentOverrides); | 231 }..addAll(environmentOverrides); |
232 | 232 |
233 Command command = new FletchSessionCommand( | 233 Command command = new DartinoSessionCommand( |
234 executable, basicArguments.first, basicArguments, | 234 executable, basicArguments.first, basicArguments, |
235 environment, snapshotFileName: snapshotFileName); | 235 environment, snapshotFileName: snapshotFileName); |
236 | 236 |
237 return new CommandArtifact( | 237 return new CommandArtifact( |
238 <Command>[command], snapshotFileName, 'application/fletch-snapshot'); | 238 <Command>[command], snapshotFileName, 'application/dartino-snapshot'); |
239 } | 239 } |
240 | 240 |
241 List<String> computeRuntimeArguments( | 241 List<String> computeRuntimeArguments( |
242 RuntimeConfiguration runtimeConfiguration, | 242 RuntimeConfiguration runtimeConfiguration, |
243 String buildDir, | 243 String buildDir, |
244 TestInformation info, | 244 TestInformation info, |
245 List<String> vmOptions, | 245 List<String> vmOptions, |
246 List<String> sharedOptions, | 246 List<String> sharedOptions, |
247 List<String> originalArguments, | 247 List<String> originalArguments, |
248 CommandArtifact artifact) { | 248 CommandArtifact artifact) { |
249 return <String>[] | 249 return <String>[] |
250 ..addAll(vmOptions) | 250 ..addAll(vmOptions) |
251 ..add(artifact.filename); | 251 ..add(artifact.filename); |
252 } | 252 } |
253 } | 253 } |
OLD | NEW |