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

Side by Side Diff: dart/utils/compiler/build_helper.dart

Issue 9969209: Make dart2js executable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/utils/compiler/compiler.gyp » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #import('dart:uri'); 6 #import('dart:uri');
7 7
8 main() { 8 main() {
9 List<String> arguments = new Options().arguments; 9 List<String> arguments = new Options().arguments;
10 Uri uri = new Uri(scheme: 'file', path: '${arguments[0]}/'); 10 Uri uri = new Uri(scheme: 'file', path: '${arguments[0]}/');
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 writeScript(Uri uri, List<String> chunks) { 24 writeScript(Uri uri, List<String> chunks) {
25 var f = new File(uri.path); 25 var f = new File(uri.path);
26 var stream = f.openSync(FileMode.WRITE); 26 var stream = f.openSync(FileMode.WRITE);
27 for (String chunk in chunks) { 27 for (String chunk in chunks) {
28 stream.writeStringSync(chunk); 28 stream.writeStringSync(chunk);
29 } 29 }
30 stream.closeSync(); 30 stream.closeSync();
31 31
32 // TODO(ahe): Make script executable.
33 // TODO(ahe): Also make a .bat file for Windows. 32 // TODO(ahe): Also make a .bat file for Windows.
33
34 if (new Platform().operatingSystem() != 'windows') {
35 onExit(int exitCode, String stdout, String stderr) {
36 if (exitCode != 0) {
37 print(stdout);
38 print(stderr);
39 exit(exitCode);
40 }
41 }
42 new Process.run('/bin/chmod', ['+x', uri.path], null, onExit);
43 }
34 } 44 }
35 45
36 buildScript(Uri uri) { 46 buildScript(Uri uri) {
47 String dart2jsPath =
48 uri.resolve('../../lib/compiler/implementation/dart2js.dart').path;
49 String libraryRoot = uri.resolve('../../').path;
37 return """ 50 return """
51 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
kasperl 2012/04/17 15:19:39 Would it make sense to throw this string into a to
ahe 2012/04/17 16:08:15 I'm using string interpolation. The best I can do
52 // for details. All rights reserved. Use of this source code is governed by a
53 // BSD-style license that can be found in the LICENSE file.
38 54
39 #import('dart:io'); 55 #import('dart:io');
40 56
41 #import('${uri.resolve('../../lib/compiler/implementation/dart2js.dart').path}') ; 57 #import('$dart2jsPath');
42 58
43 class Helper { 59 class Helper {
44 void run() { 60 void run() {
45 try { 61 try {
46 List<String> argv = ['--library-root=${uri.resolve('../../').path}']; 62 List<String> argv = ['--library-root=$libraryRoot'];
47 argv.addAll(new Options().arguments); 63 argv.addAll(new Options().arguments);
48 compile(argv); 64 compile(argv);
49 } catch (var exception, var trace) { 65 } catch (var exception, var trace) {
50 try { 66 try {
51 print('Internal error: \$exception'); 67 print('Internal error: \$exception');
52 } catch (var ignored) { 68 } catch (var ignored) {
53 print('Internal error: error while printing exception'); 69 print('Internal error: error while printing exception');
54 } 70 }
55 try { 71 try {
56 print(trace); 72 print(trace);
57 } finally { 73 } finally {
58 exit(253); // 253 is recognized as a crash by our test scripts. 74 exit(253); // 253 is recognized as a crash by our test scripts.
59 } 75 }
60 } 76 }
61 } 77 }
62 } 78 }
63 79
64 void main() { 80 void main() {
65 new Helper().run(); 81 new Helper().run();
66 } 82 }
67 """; 83 """;
68 } 84 }
OLDNEW
« no previous file with comments | « no previous file | dart/utils/compiler/compiler.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698