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

Unified Diff: runtime/bin/extensions.cc

Issue 1896203002: Search for a native extension for the host architecture (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | « runtime/bin/extensions.h ('k') | runtime/bin/platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/extensions.cc
diff --git a/runtime/bin/extensions.cc b/runtime/bin/extensions.cc
index 7fa06fd64524cbeed4cff47b0c2f58b7ec3d1a4a..f4b921f9cac63061f02690eccd686ef2d439b2fb 100644
--- a/runtime/bin/extensions.cc
+++ b/runtime/bin/extensions.cc
@@ -8,6 +8,7 @@
#include "bin/dartutils.h"
#include "bin/file.h"
+#include "bin/platform.h"
#include "include/dart_api.h"
#include "platform/assert.h"
#include "platform/globals.h"
@@ -16,18 +17,42 @@ namespace dart {
namespace bin {
Dart_Handle Extensions::LoadExtension(const char* extension_directory,
- const char* extension_file,
const char* extension_name,
Dart_Handle parent_library) {
if (strncmp(extension_directory, "http://", 7) == 0 ||
strncmp(extension_directory, "https://", 8) == 0) {
return Dart_NewApiError("Cannot load native extensions over http:");
}
- const char* library_strings[] = { extension_directory, extension_file, NULL };
+
+ // For example on Linux: directory/libfoo-arm.so
+ const char* library_strings[] = {
+ extension_directory, // directory/
+ Platform::LibraryPrefix(), // lib
+ extension_name, // foo
+ "-",
+ Platform::HostArchitecture(), // arm
+ ".",
+ Platform::LibraryExtension(), // so
+ NULL,
+ };
const char* library_file = Concatenate(library_strings);
void* library_handle = LoadExtensionLibrary(library_file);
if (library_handle == NULL) {
- return GetError();
+ // Fallback on a library file name that does not specify the host
+ // architecture. For example on Linux: directory/libfoo.so
+ const char* fallback_library_strings[] = {
+ extension_directory, // directory/
+ Platform::LibraryPrefix(), // lib
+ extension_name, // foo
+ ".",
+ Platform::LibraryExtension(), // so
+ NULL,
+ };
+ const char* fallback_library_file = Concatenate(fallback_library_strings);
+ library_handle = LoadExtensionLibrary(fallback_library_file);
+ if (library_handle == NULL) {
+ return GetError();
+ }
}
const char* strings[] = { extension_name, "_Init", NULL };
« no previous file with comments | « runtime/bin/extensions.h ('k') | runtime/bin/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698