Initial modified libraries support (flutter/engine#2845)

This commit is contained in:
John McCutchan
2016-08-01 12:30:44 -07:00
committed by GitHub
parent 0c30ca0d8d
commit c7e72aa115
2 changed files with 23 additions and 9 deletions

2
DEPS
View File

@@ -25,7 +25,7 @@ vars = {
# Note: When updating the Dart revision, ensure that all entries that are
# dependencies of dart are also updated
'dart_revision': 'd37ea681f5d80a3ab150b709baaeb1fef7a12cae',
'dart_revision': '59e67cc36d0877949719160de8959a11db4a8027',
'dart_boringssl_revision': 'daeafc22c66ad48f6b32fc8d3362eb9ba31b774e',
'dart_observatory_packages_revision': 'e5e1e543bea10d4bed95b22ad3e7aa2b20a23584',
'dart_root_certificates_revision': 'aed07942ce98507d2be28cbd29e879525410c7fc',

View File

@@ -67,7 +67,7 @@ class Loader {
base::FilePath GetFilePathForURL(std::string url);
base::FilePath GetFilePathForPackageURL(std::string url);
base::FilePath GetFilePathForFileURL(std::string url);
std::string Fetch(const std::string& url);
std::string Fetch(const std::string& url, std::string* resolved_url);
Dart_Handle Import(Dart_Handle url);
Dart_Handle Source(Dart_Handle library, Dart_Handle url);
@@ -159,10 +159,13 @@ base::FilePath Loader::GetFilePathForFileURL(std::string url) {
return base::FilePath(url);
}
std::string Loader::Fetch(const std::string& url) {
std::string Loader::Fetch(const std::string& url,
std::string* resolved_url) {
base::FilePath path = GetFilePathForURL(url);
base::FilePath absolute_path = base::MakeAbsoluteFilePath(path);
*resolved_url = "file://" + absolute_path.value();
std::string source;
if (!base::ReadFileToString(base::MakeAbsoluteFilePath(path), &source)) {
if (!base::ReadFileToString(absolute_path, &source)) {
fprintf(stderr, "error: Unable to find Dart library '%s'.\n", url.c_str());
exit(1);
}
@@ -171,15 +174,22 @@ std::string Loader::Fetch(const std::string& url) {
}
Dart_Handle Loader::Import(Dart_Handle url) {
Dart_Handle source = StringToDart(Fetch(StringFromDart(url)));
Dart_Handle result = Dart_LoadLibrary(url, source, 0, 0);
std::string resolved_url;
Dart_Handle source = StringToDart(Fetch(StringFromDart(url), &resolved_url));
Dart_Handle result = Dart_LoadLibrary(url,
StringToDart(resolved_url),
source, 0, 0);
LogIfError(result);
return result;
}
Dart_Handle Loader::Source(Dart_Handle library, Dart_Handle url) {
Dart_Handle source = StringToDart(Fetch(StringFromDart(url)));
Dart_Handle result = Dart_LoadSource(library, url, source, 0, 0);
std::string resolved_url;
Dart_Handle source = StringToDart(Fetch(StringFromDart(url), &resolved_url));
Dart_Handle result = Dart_LoadSource(library,
url,
StringToDart(resolved_url),
source, 0, 0);
LogIfError(result);
return result;
}
@@ -226,8 +236,12 @@ Dart_Handle HandleLibraryTag(Dart_LibraryTag tag,
}
void LoadScript(const std::string& url) {
std::string resolved_url;
Dart_Handle source = StringToDart(GetLoader().Fetch(url, &resolved_url));
LogIfError(
Dart_LoadScript(StringToDart(url), StringToDart(GetLoader().Fetch(url)),
Dart_LoadScript(StringToDart(url),
StringToDart(resolved_url),
source,
0, 0));
}