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

Side by Side Diff: lib/devc.dart

Issue 1148283010: Remove dart backend (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 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
« no previous file with comments | « .gitignore ('k') | lib/runtime/dart_logging_runtime.dart » ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Command line tool to run the checker on a Dart program. 5 /// Command line tool to run the checker on a Dart program.
6 library dev_compiler.devc; 6 library dev_compiler.devc;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
11 11
12 import 'package:analyzer/src/generated/error.dart' as analyzer; 12 import 'package:analyzer/src/generated/error.dart' as analyzer;
13 import 'package:analyzer/src/generated/engine.dart' 13 import 'package:analyzer/src/generated/engine.dart'
14 show AnalysisContext, ChangeSet; 14 show AnalysisContext, ChangeSet;
15 import 'package:analyzer/src/generated/source.dart' show Source; 15 import 'package:analyzer/src/generated/source.dart' show Source;
16 import 'package:logging/logging.dart' show Level, Logger, LogRecord; 16 import 'package:logging/logging.dart' show Level, Logger, LogRecord;
17 import 'package:path/path.dart' as path; 17 import 'package:path/path.dart' as path;
18 import 'package:shelf/shelf.dart' as shelf; 18 import 'package:shelf/shelf.dart' as shelf;
19 import 'package:shelf/shelf_io.dart' as shelf; 19 import 'package:shelf/shelf_io.dart' as shelf;
20 import 'package:shelf_static/shelf_static.dart' as shelf_static; 20 import 'package:shelf_static/shelf_static.dart' as shelf_static;
21 21
22 import 'src/analysis_context.dart'; 22 import 'src/analysis_context.dart';
23 import 'src/checker/checker.dart'; 23 import 'src/checker/checker.dart';
24 import 'src/checker/rules.dart'; 24 import 'src/checker/rules.dart';
25 import 'src/codegen/code_generator.dart' show CodeGenerator; 25 import 'src/codegen/code_generator.dart' show CodeGenerator;
26 import 'src/codegen/dart_codegen.dart';
27 import 'src/codegen/html_codegen.dart'; 26 import 'src/codegen/html_codegen.dart';
28 import 'src/codegen/js_codegen.dart'; 27 import 'src/codegen/js_codegen.dart';
29 import 'src/dependency_graph.dart'; 28 import 'src/dependency_graph.dart';
30 import 'src/info.dart' 29 import 'src/info.dart'
31 show AnalyzerError, CheckerResults, LibraryInfo, LibraryUnit; 30 show AnalyzerError, CheckerResults, LibraryInfo, LibraryUnit;
32 import 'src/options.dart'; 31 import 'src/options.dart';
33 import 'src/report.dart'; 32 import 'src/report.dart';
34 import 'src/utils.dart'; 33 import 'src/utils.dart';
35 34
36 /// Sets up the type checker logger to print a span that highlights error 35 /// Sets up the type checker logger to print a span that highlights error
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ? ResolverOptions.implicitHtmlFile 83 ? ResolverOptions.implicitHtmlFile
85 : inputFile)); 84 : inputFile));
86 var entryNode = graph.nodeFromUri(inputUri); 85 var entryNode = graph.nodeFromUri(inputUri);
87 86
88 return new Compiler._( 87 return new Compiler._(
89 options, context, reporter, rules, checker, entryNode); 88 options, context, reporter, rules, checker, entryNode);
90 } 89 }
91 90
92 Compiler._(this.options, this.context, this._reporter, this.rules, 91 Compiler._(this.options, this.context, this._reporter, this.rules,
93 this._checker, this._entryNode) { 92 this._checker, this._entryNode) {
94 if (options.dumpSrcDir != null) {
95 _generators.add(new EmptyDartGenerator(this));
96 }
97 if (options.outputDir != null) { 93 if (options.outputDir != null) {
98 _generators.add( 94 _generators.add(new JSGenerator(this));
99 options.outputDart ? new DartGenerator(this) : new JSGenerator(this));
100 } 95 }
101 // TODO(sigmund): refactor to support hashing of the dart output? 96 // TODO(sigmund): refactor to support hashing of the dart output?
102 _hashing = 97 _hashing = options.enableHashing && _generators.length == 1;
103 options.enableHashing && _generators.length == 1 && !options.outputDart;
104 } 98 }
105 99
106 Uri get entryPointUri => _entryNode.uri; 100 Uri get entryPointUri => _entryNode.uri;
107 101
108 bool _buildSource(SourceNode node) { 102 bool _buildSource(SourceNode node) {
109 if (node is HtmlSourceNode) { 103 if (node is HtmlSourceNode) {
110 _buildHtmlFile(node); 104 _buildHtmlFile(node);
111 } else if (node is DartSourceNode) { 105 } else if (node is DartSourceNode) {
112 _buildDartLibrary(node); 106 _buildDartLibrary(node);
113 } else if (node is ResourceSourceNode) { 107 } else if (node is ResourceSourceNode) {
(...skipping 13 matching lines...) Expand all
127 _reporter.enterHtml(uri); 121 _reporter.enterHtml(uri);
128 var output = generateEntryHtml(node, options); 122 var output = generateEntryHtml(node, options);
129 if (output == null) { 123 if (output == null) {
130 _failure = true; 124 _failure = true;
131 return; 125 return;
132 } 126 }
133 _reporter.leaveHtml(); 127 _reporter.leaveHtml();
134 var filename = path.basename(node.uri.path); 128 var filename = path.basename(node.uri.path);
135 String outputFile = path.join(options.outputDir, filename); 129 String outputFile = path.join(options.outputDir, filename);
136 new File(outputFile).writeAsStringSync(output); 130 new File(outputFile).writeAsStringSync(output);
137
138 if (options.outputDart) return;
139 } 131 }
140 132
141 void _buildResourceFile(ResourceSourceNode node) { 133 void _buildResourceFile(ResourceSourceNode node) {
142 // ResourceSourceNodes files that just need to be copied over to the output 134 // ResourceSourceNodes files that just need to be copied over to the output
143 // location. These can be external dependencies or pieces of the 135 // location. These can be external dependencies or pieces of the
144 // dev_compiler runtime. 136 // dev_compiler runtime.
145 if (options.outputDir == null || options.outputDart) return; 137 if (options.outputDir == null) return;
146 var filepath = resourceOutputPath(node.uri, _entryNode.uri); 138 var filepath = resourceOutputPath(node.uri, _entryNode.uri);
147 assert(filepath != null); 139 assert(filepath != null);
148 filepath = path.join(options.outputDir, filepath); 140 filepath = path.join(options.outputDir, filepath);
149 var dir = path.dirname(filepath); 141 var dir = path.dirname(filepath);
150 new Directory(dir).createSync(recursive: true); 142 new Directory(dir).createSync(recursive: true);
151 new File.fromUri(node.source.uri).copySync(filepath); 143 new File.fromUri(node.source.uri).copySync(filepath);
152 if (_hashing) node.cachingHash = computeHashFromFile(filepath); 144 if (_hashing) node.cachingHash = computeHashFromFile(filepath);
153 } 145 }
154 146
155 bool _isEntry(DartSourceNode node) { 147 bool _isEntry(DartSourceNode node) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Note: the cache-control header should be enough, but this doesn't hurt 319 // Note: the cache-control header should be enough, but this doesn't hurt
328 // and can help renew the policy after it expires. 320 // and can help renew the policy after it expires.
329 headers['ETag'] = hash; 321 headers['ETag'] = hash;
330 } 322 }
331 return response.change(headers: headers); 323 return response.change(headers: headers);
332 }; 324 };
333 } 325 }
334 326
335 final _log = new Logger('dev_compiler'); 327 final _log = new Logger('dev_compiler');
336 final _earlyErrorResult = new CheckerResults(const [], null, true); 328 final _earlyErrorResult = new CheckerResults(const [], null, true);
OLDNEW
« no previous file with comments | « .gitignore ('k') | lib/runtime/dart_logging_runtime.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698