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

Side by Side Diff: dart/sdk/lib/_internal/compiler/samples/jsonify/jsonify.dart

Issue 133893008: Add GYP build rule for Try Dart! (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments from Kasper and Martin Created 6 years, 11 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 | « dart/dart.gyp ('k') | dart/site/try/app.yaml » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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:convert'; 6 import 'dart:convert';
7 7
8 // TODO(ahe): Should be dart:mirrors. 8 // TODO(ahe): Should be dart:mirrors.
9 import '../../implementation/mirrors/mirrors.dart'; 9 import '../../implementation/mirrors/mirrors.dart';
10 10
(...skipping 13 matching lines...) Expand all
24 const SDK_ROOT = '../../../../../'; 24 const SDK_ROOT = '../../../../../';
25 25
26 bool isPublicDart2jsLibrary(String name) { 26 bool isPublicDart2jsLibrary(String name) {
27 return !name.startsWith('_') && LIBRARIES[name].isDart2jsLibrary; 27 return !name.startsWith('_') && LIBRARIES[name].isDart2jsLibrary;
28 } 28 }
29 29
30 var handler; 30 var handler;
31 RandomAccessFile output; 31 RandomAccessFile output;
32 Uri outputUri; 32 Uri outputUri;
33 Uri sdkRoot; 33 Uri sdkRoot;
34 const bool outputJson =
35 const bool.fromEnvironment('outputJson', defaultValue: false);
34 36
35 main(List<String> arguments) { 37 main(List<String> arguments) {
36 handler = new FormattingDiagnosticHandler() 38 handler = new FormattingDiagnosticHandler()
37 ..throwOnError = true; 39 ..throwOnError = true;
38 40
39 outputUri = 41 outputUri =
40 handler.provider.cwd.resolve(nativeToUriPath(arguments.first)); 42 handler.provider.cwd.resolve(nativeToUriPath(arguments.first));
41 output = new File(arguments.first).openSync(mode: FileMode.WRITE); 43 output = new File(arguments.first).openSync(mode: FileMode.WRITE);
42 44
43 Uri myLocation = 45 Uri myLocation =
(...skipping 26 matching lines...) Expand all
70 LIBRARIES.forEach((name, info) { 72 LIBRARIES.forEach((name, info) {
71 var patch = info.dart2jsPatchPath; 73 var patch = info.dart2jsPatchPath;
72 if (patch != null) { 74 if (patch != null) {
73 Uri uri = sdkRoot.resolve('sdk/lib/$patch'); 75 Uri uri = sdkRoot.resolve('sdk/lib/$patch');
74 String filename = relativize(sdkRoot, uri, false); 76 String filename = relativize(sdkRoot, uri, false);
75 SourceFile file = handler.provider.sourceFiles['$uri']; 77 SourceFile file = handler.provider.sourceFiles['$uri'];
76 map['sdk:/$filename'] = file.slowText(); 78 map['sdk:/$filename'] = file.slowText();
77 } 79 }
78 }); 80 });
79 81
80 output.writeStringSync(''' 82 if (outputJson) {
83 output.writeStringSync(JSON.encode(map));
84 } else {
85 output.writeStringSync('''
81 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 86 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
82 // for details. All rights reserved. Use of this source code is governed by a 87 // for details. All rights reserved. Use of this source code is governed by a
83 // BSD-style license that can be found in the LICENSE file. 88 // BSD-style license that can be found in the LICENSE file.
84 89
85 // DO NOT EDIT. 90 // DO NOT EDIT.
86 // This file is generated by jsonify.dart. 91 // This file is generated by jsonify.dart.
87 92
88 library dart.sdk_sources; 93 library dart.sdk_sources;
89 94
90 const Map<String, String> SDK_SOURCES = const <String, String>'''); 95 const Map<String, String> SDK_SOURCES = const <String, String>''');
91 output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$')); 96 output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$'));
92 output.writeStringSync(';\n'); 97 output.writeStringSync(';\n');
98 }
93 output.closeSync(); 99 output.closeSync();
94 } 100 }
OLDNEW
« no previous file with comments | « dart/dart.gyp ('k') | dart/site/try/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698