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

Side by Side Diff: runtime/bin/extensions_linux.cc

Issue 9694045: Change lookup path for Dart native extensions shared libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "bin/extensions.h" 5 #include "bin/extensions.h"
6 #include <dlfcn.h> 6 #include <dlfcn.h>
7 7
8 void* Extensions::LoadExtensionLibrary(const char* library_name) { 8 void* Extensions::LoadExtensionLibrary(const char* library_path) {
Mads Ager (google) 2012/03/14 10:29:47 The splitting up of the path into path and extensi
Bill Hesse 2012/03/14 17:15:04 Done.
9 const char* strings[4] = { "./lib", library_name, ".so", NULL }; 9 const char* library_path_strings[2] = { library_path, NULL };
10 char* library_path = Concatenate(strings); 10 char* mutable_library_path = Concatenate(library_path_strings);
Mads Ager (google) 2012/03/14 10:29:47 This is just a strdup?
Bill Hesse 2012/03/14 17:15:04 This is moved to the platform-independent code, an
11 void* lib_handle = dlopen(library_path, RTLD_LAZY); 11
12 free(library_path); 12 char* last_path_separator =
13 strrchr(mutable_library_path, '/');
14 if (last_path_separator == NULL) {
15 free(mutable_library_path);
16 return Dart_Error("Cannot find path separator in resolved extension name");
17 }
18 char* extension_name = last_path_separator + 1;
19 *last_path_separator = '\0';
20
21 const char* strings[5] = { mutable_library_path, "/lib",
22 extension_name, ".so", NULL };
23 char* library_file_path = Concatenate(strings);
24 fprintf(stderr, "%s\n", library_file_path);
25 void* lib_handle = dlopen(library_file_path, RTLD_LAZY);
26 free(library_file_path);
27 free(mutable_library_path);
13 return lib_handle; 28 return lib_handle;
14 } 29 }
15 30
16 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { 31 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) {
17 void* result = dlsym(lib_handle, symbol); 32 void* result = dlsym(lib_handle, symbol);
18 if (dlerror() != NULL) return NULL; 33 if (dlerror() != NULL) return NULL;
19 return result; 34 return result;
20 } 35 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698