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

Unified Diff: runtime/bin/builtin.dart

Issue 186473003: Refactor native extension shared library lookup. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add check for loading from http(s): Created 6 years, 10 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 | « no previous file | runtime/bin/dartutils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index 2a9bd3014d886ff412086023c815603b12b94c01..70abc70fbe3b613c72cff6db54fbcf7ccba32fc0 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -221,9 +221,6 @@ String _resolveUri(String base, String userString) {
// Returns either a file path or a URI starting with http:, as a String.
String _filePathFromUri(String userUri) {
- if (userUri.startsWith(_DART_EXT)) {
- userUri = userUri.substring(_DART_EXT.length);
- }
var uri = Uri.parse(userUri);
_logResolution('# Getting file path from: $uri');
@@ -262,3 +259,50 @@ String _filePathFromPackageUri(Uri uri) {
_packageRoot;
return _filePathFromUri(packageRoot.resolve(uri.path).toString());
}
+
+
+// Returns the directory part, the filename part, and the name
+// of a native extension URL as a list [directory, filename, name].
+// The directory part is either a file system path or an HTTP(S) URL.
+// The filename part is the extension name, with the platform-dependent
+// prefixes and extensions added.
+String _extensionPathFromUri(String userUri) {
Ivan Posva 2014/03/04 20:03:56 Please remove the types in this file. They will on
+ if (!userUri.startsWith(_DART_EXT)) {
+ throw 'Unexpected internal error: Extension URI $userUri missing dart-ext:';
+ }
+ userUri = userUri.substring(_DART_EXT.length);
+
+ if (userUri.contains('\\')) {
+ throw 'Unexpected internal error: Extension URI $userUri contains \\';
+ }
+
+ String filename;
+ String name;
+ String path; // Will end in '/'.
+ int index = userUri.lastIndexOf('/');
+ if (index == -1) {
+ name = userUri;
+ path = './';
+ } else if (index == userUri.length - 1) {
+ throw 'Extension name missing in $extensionUri';
+ } else {
+ name = userUri.substring(index + 1);
+ path = userUri.substring(0, index + 1);
+ }
+
+ path = _filePathFromUri(path);
+
+ if (Platform.isLinux || Platform.isAndroid) {
+ filename = 'lib$name.so';
Ivan Posva 2014/03/04 20:03:56 We will also have to have a plan to deal with diff
+ } else if (Platform.isMacOS) {
+ filename = 'lib$name.dylib';
+ } else if (Platform.isWindows) {
+ filename = '$name.dll';
+ } else {
+ _logResolution(
+ 'Native extensions not supported on ${Platform.operatingSystem}');
+ throw 'Native extensions not supported on ${Platform.operatingSystem}';
+ }
+
+ return [path, filename, name];
+}
« no previous file with comments | « no previous file | runtime/bin/dartutils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698