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

Side by Side Diff: tests/compiler/dart2js/kernel/compiler_helper.dart

Issue 2942863002: Compile and run Hello World! (Closed)
Patch Set: Rebased Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 // Partial test that the closed world computed from [WorldImpact]s derived from 5 // Partial test that the closed world computed from [WorldImpact]s derived from
6 // kernel is equivalent to the original computed from resolution. 6 // kernel is equivalent to the original computed from resolution.
7 library dart2js.kernel.compiler_helper; 7 library dart2js.kernel.compiler_helper;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 MemoryDillLibraryLoaderTask(KernelToElementMapImpl elementMap, 132 MemoryDillLibraryLoaderTask(KernelToElementMapImpl elementMap,
133 DiagnosticReporter reporter, Measurer measurer, this.program) 133 DiagnosticReporter reporter, Measurer measurer, this.program)
134 : super(elementMap, null, null, reporter, measurer); 134 : super(elementMap, null, null, reporter, measurer);
135 135
136 Future<LoadedLibraries> loadLibrary(Uri resolvedUri, 136 Future<LoadedLibraries> loadLibrary(Uri resolvedUri,
137 {bool skipFileWithPartOfTag: false}) async { 137 {bool skipFileWithPartOfTag: false}) async {
138 return createLoadedLibraries(program); 138 return createLoadedLibraries(program);
139 } 139 }
140 } 140 }
141 141
142 Future<Compiler> compileWithDill( 142 Future createTemp(Uri entryPoint, Map<String, String> memorySourceFiles,
143 Uri entryPoint, Map<String, String> memorySourceFiles, List<String> options, 143 {bool printSteps: false}) async {
144 {bool printSteps: false,
145 CompilerOutput compilerOutput,
146 void beforeRun(Compiler compiler)}) async {
147 if (memorySourceFiles.isNotEmpty) { 144 if (memorySourceFiles.isNotEmpty) {
148 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill'); 145 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill');
149 if (printSteps) { 146 if (printSteps) {
150 print('--- create temp directory $dir -------------------------------'); 147 print('--- create temp directory $dir -------------------------------');
151 } 148 }
152 memorySourceFiles.forEach((String name, String source) { 149 memorySourceFiles.forEach((String name, String source) {
153 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source); 150 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source);
154 }); 151 });
155 entryPoint = dir.uri.resolve(entryPoint.path); 152 entryPoint = dir.uri.resolve(entryPoint.path);
156 } 153 }
157 if (printSteps) { 154 if (printSteps) {
158 print('---- generate dill -----------------------------------------------'); 155 print('---- generate dill -----------------------------------------------');
159 } 156 }
160 157
161 Uri dillFile = Uri.parse('$entryPoint.dill'); 158 Uri dillFile = Uri.parse('$entryPoint.dill');
162 String buildDir = Platform.isMacOS ? 'xcodebuild' : 'out'; 159 String buildDir = Platform.isMacOS ? 'xcodebuild' : 'out';
163 String configuration = 160 String configuration =
164 Platform.environment['DART_CONFIGURATION'] ?? 'ReleaseX64'; 161 Platform.environment['DART_CONFIGURATION'] ?? 'ReleaseX64';
165 await generate.main([ 162 await generate.main([
166 '--platform=$buildDir/$configuration/patched_dart2js_sdk/platform.dill', 163 '--platform=$buildDir/$configuration/patched_dart2js_sdk/platform.dill',
167 '$entryPoint' 164 '$entryPoint'
168 ]); 165 ]);
166 return dillFile;
167 }
168
169 Future<Compiler> compileWithDill(
170 Uri entryPoint, Map<String, String> memorySourceFiles, List<String> options,
171 {bool printSteps: false,
172 CompilerOutput compilerOutput,
173 void beforeRun(Compiler compiler)}) async {
174 Uri dillFile =
175 await createTemp(entryPoint, memorySourceFiles, printSteps: printSteps);
169 176
170 if (printSteps) { 177 if (printSteps) {
171 print('---- compile from dill $dillFile ---------------------------------'); 178 print('---- compile from dill $dillFile ---------------------------------');
172 } 179 }
173 Compiler compiler = compilerFor( 180 Compiler compiler = compilerFor(
174 entryPoint: dillFile, 181 entryPoint: dillFile,
175 options: [Flags.loadFromDill]..addAll(options), 182 options: [Flags.loadFromDill]..addAll(options),
176 outputProvider: compilerOutput); 183 outputProvider: compilerOutput);
177 ElementResolutionWorldBuilder.useInstantiationMap = true; 184 ElementResolutionWorldBuilder.useInstantiationMap = true;
178 compiler.resolution.retainCachesForTesting = true; 185 compiler.resolution.retainCachesForTesting = true;
179 if (beforeRun != null) { 186 if (beforeRun != null) {
180 beforeRun(compiler); 187 beforeRun(compiler);
181 } 188 }
182 await compiler.run(dillFile); 189 await compiler.run(dillFile);
183 return compiler; 190 return compiler;
184 } 191 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/kernel/compile_from_dill_test.dart ('k') | tests/compiler/dart2js/kernel/run_from_dill_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698