| OLD | NEW |
| 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'; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 new File(outputFile).writeAsStringSync(output); | 129 new File(outputFile).writeAsStringSync(output); |
| 130 | 130 |
| 131 if (_options.outputDart) return; | 131 if (_options.outputDart) return; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void _buildResourceFile(ResourceSourceNode node) { | 134 void _buildResourceFile(ResourceSourceNode node) { |
| 135 // ResourceSourceNodes files that just need to be copied over to the output | 135 // ResourceSourceNodes files that just need to be copied over to the output |
| 136 // location. These can be external dependencies or pieces of the | 136 // location. These can be external dependencies or pieces of the |
| 137 // dev_compiler runtime. | 137 // dev_compiler runtime. |
| 138 if (_options.outputDir == null || _options.outputDart) return; | 138 if (_options.outputDir == null || _options.outputDart) return; |
| 139 var filepath = resourceOutputPath(node.uri); | 139 var filepath = resourceOutputPath(node.uri, _entryNode.uri); |
| 140 assert(filepath != null); | 140 assert(filepath != null); |
| 141 filepath = path.join(_options.outputDir, filepath); | 141 filepath = path.join(_options.outputDir, filepath); |
| 142 var dir = path.dirname(filepath); | 142 var dir = path.dirname(filepath); |
| 143 new Directory(dir).createSync(recursive: true); | 143 new Directory(dir).createSync(recursive: true); |
| 144 var text = node.source.contents.data; | 144 new File.fromUri(node.source.uri).copySync(filepath); |
| 145 new File(filepath).writeAsStringSync(text); | 145 if (_hashing) node.cachingHash = computeHashFromFile(filepath); |
| 146 if (_hashing) node.cachingHash = computeHash(text); | |
| 147 } | 146 } |
| 148 | 147 |
| 149 bool _isEntry(DartSourceNode node) { | 148 bool _isEntry(DartSourceNode node) { |
| 150 if (_entryNode is DartSourceNode) return _entryNode == node; | 149 if (_entryNode is DartSourceNode) return _entryNode == node; |
| 151 return (_entryNode as HtmlSourceNode).scripts.contains(node); | 150 return (_entryNode as HtmlSourceNode).scripts.contains(node); |
| 152 } | 151 } |
| 153 | 152 |
| 154 void _buildDartLibrary(DartSourceNode node) { | 153 void _buildDartLibrary(DartSourceNode node) { |
| 155 var source = node.source; | 154 var source = node.source; |
| 156 // TODO(sigmund): find out from analyzer team if there is a better way | 155 // TODO(sigmund): find out from analyzer team if there is a better way |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // Note: the cache-control header should be enough, but this doesn't hurt | 303 // Note: the cache-control header should be enough, but this doesn't hurt |
| 305 // and can help renew the policy after it expires. | 304 // and can help renew the policy after it expires. |
| 306 headers['ETag'] = segments[1]; | 305 headers['ETag'] = segments[1]; |
| 307 } | 306 } |
| 308 return response.change(headers: headers); | 307 return response.change(headers: headers); |
| 309 }; | 308 }; |
| 310 } | 309 } |
| 311 | 310 |
| 312 final _log = new Logger('dev_compiler'); | 311 final _log = new Logger('dev_compiler'); |
| 313 final _earlyErrorResult = new CheckerResults(const [], null, true); | 312 final _earlyErrorResult = new CheckerResults(const [], null, true); |
| OLD | NEW |