Chromium Code Reviews| Index: platform_tools/android/launcher/skia_launcher.cpp |
| diff --git a/platform_tools/android/launcher/skia_launcher.cpp b/platform_tools/android/launcher/skia_launcher.cpp |
| index 972382dc16f325188ce3717e4e44e794056ffb1e..f5eae41372523ae43a66d319ce48e3051a662c19 100644 |
| --- a/platform_tools/android/launcher/skia_launcher.cpp |
| +++ b/platform_tools/android/launcher/skia_launcher.cpp |
| @@ -28,6 +28,29 @@ int launch_app(int (*app_main)(int, const char**), int argc, |
| return (*app_main)(argc, argv); |
| } |
| +void* load_library(const char** argv, const char* libraryName) |
| +{ |
| + // attempt to lookup the location of the shared libraries |
| + char libraryLocation[100]; |
| + sprintf(libraryLocation, "%s/lib/lib%s.so", argv[0], libraryName); |
| + if (!file_exists(libraryLocation)) { |
| + printf("ERROR: Unable to find the appropriate library in the Skia App.\n"); |
| + printf("ERROR: Did you provide the correct program_name?\n"); |
| + usage(argv[0]); |
| + return NULL; |
| + } |
| + |
| + // load the appropriate library |
| + void* appLibrary = dlopen(libraryLocation, RTLD_LOCAL | RTLD_LAZY); |
| + if (!appLibrary) { |
| + printf("ERROR: Unable to open the shared library.\n"); |
| + printf("ERROR: %s", dlerror()); |
| + return NULL; |
| + } |
| + |
| + return appLibrary; |
| +} |
| + |
| int main(int argc, const char** argv) { |
| // check that the program name was specified |
| @@ -44,23 +67,11 @@ int main(int argc, const char** argv) { |
| return -1; |
| } |
| - // attempt to lookup the location of the shared libraries |
| - char libraryLocation[100]; |
| - sprintf(libraryLocation, "%s/lib/lib%s.so", appLocation, argv[1]); |
| - if (!file_exists(libraryLocation)) { |
| - printf("ERROR: Unable to find the appropriate library in the Skia App.\n"); |
| - printf("ERROR: Did you provide the correct program_name?\n"); |
| - usage(argv[0]); |
| - return -1; |
| - } |
| + // load the local skia shared library |
| + load_library(argv, "libskia_local.so"); |
|
djsollen
2013/05/30 20:35:29
if this returns NULL we should abort and return -1
|
| // load the appropriate library |
| - void* appLibrary = dlopen(libraryLocation, RTLD_LOCAL | RTLD_LAZY); |
| - if (!appLibrary) { |
| - printf("ERROR: Unable to open the shared library.\n"); |
| - printf("ERROR: %s", dlerror()); |
| - return -1; |
| - } |
| + void* appLibrary = load_library(argv, argv[1]); |
|
djsollen
2013/05/30 20:35:29
same here
|
| // find the address of the main function |
| int (*app_main)(int, const char**); |