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

Unified Diff: lib/src/utils.dart

Issue 1014173002: Copy resources refered to in the HTML to the output folder (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/dependency_graph.dart ('k') | test/codegen/expect/server_mode/html_input.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 7fc38a0d1beabdd58a28ad67efc4feeffea8e722..dd62656ddfa875dfc0f7bd617775b75237a0ab04 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -298,11 +298,24 @@ String computeHash(String contents) {
return CryptoUtils.bytesToHex((new MD5()..add(contents.codeUnits)).close());
}
-String resourceOutputPath(Uri resourceUri) {
+/// Computes a hash for the given file path (reads the contents in binary form).
+String computeHashFromFile(String filepath) {
+ var bytes = new File(filepath).readAsBytesSync();
+ return CryptoUtils.bytesToHex((new MD5()..add(bytes)).close());
+}
+
+String resourceOutputPath(Uri resourceUri, Uri entryUri) {
if (resourceUri.scheme == 'package') return resourceUri.path;
- // Only support file:/// urls for resources in the dev_compiler package
if (resourceUri.scheme != 'file') return null;
+ var filepath = resourceUri.path;
+ var relativePath = path.relative(filepath, from: path.dirname(entryUri.path));
+
+ // File:/// urls can be for resources in the same project or resources from
+ // the dev_compiler package. For now we only support relative paths going
+ // further inside the folder where the entrypoint is located, otherwise we
+ // assume this is a runtime resource from the dev_compiler.
+ if (!relativePath.startsWith('..')) return relativePath;
var segments = resourceUri.pathSegments;
var len = segments.length;
if (segments.length < 4 ||
« no previous file with comments | « lib/src/dependency_graph.dart ('k') | test/codegen/expect/server_mode/html_input.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698