| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return -1; | 60 return -1; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // attempt to lookup the location of the skia app | 63 // attempt to lookup the location of the skia app |
| 64 const char* appLocation = "/data/local/tmp"; | 64 const char* appLocation = "/data/local/tmp"; |
| 65 if (!file_exists(appLocation)) { | 65 if (!file_exists(appLocation)) { |
| 66 printf("ERROR: Unable to find /data/local/tmp on the device.\n"); | 66 printf("ERROR: Unable to find /data/local/tmp on the device.\n"); |
| 67 return -1; | 67 return -1; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void* skiaLibrary; | |
| 71 | |
| 72 #if defined(SKIA_DLL) | 70 #if defined(SKIA_DLL) |
| 73 // load the local skia shared library | 71 // load the local skia shared library |
| 74 skiaLibrary = load_library(appLocation, "skia_android"); | 72 void* skiaLibrary = load_library(appLocation, "skia_android"); |
| 75 if (NULL == skiaLibrary) | 73 if (NULL == skiaLibrary) |
| 76 { | 74 { |
| 77 return -1; | 75 return -1; |
| 78 } | 76 } |
| 79 #endif | 77 #endif |
| 80 | 78 |
| 81 // load the appropriate library | 79 // load the appropriate library |
| 82 void* appLibrary = load_library(appLocation, argv[1]); | 80 void* appLibrary = load_library(appLocation, argv[1]); |
| 83 if (NULL == appLibrary) { | 81 if (NULL == appLibrary) { |
| 84 return -1; | 82 return -1; |
| 85 } | 83 } |
| 86 | 84 |
| 87 #if !defined(SKIA_DLL) | |
| 88 skiaLibrary = appLibrary; | |
| 89 #endif | |
| 90 | |
| 91 // find the address of the main function | 85 // find the address of the main function |
| 92 int (*app_main)(int, const char**); | 86 int (*app_main)(int, const char**); |
| 93 *(void **) (&app_main) = dlsym(appLibrary, "main"); | 87 *(void **) (&app_main) = dlsym(appLibrary, "main"); |
| 94 | 88 |
| 95 if (!app_main) { | 89 if (!app_main) { |
| 96 printf("ERROR: Unable to load the main function of the selected program.
\n"); | 90 printf("ERROR: Unable to load the main function of the selected program.
\n"); |
| 97 printf("ERROR: %s\n", dlerror()); | 91 printf("ERROR: %s\n", dlerror()); |
| 98 return -1; | 92 return -1; |
| 99 } | 93 } |
| 100 | 94 |
| 101 // pass all additional arguments to the main function | 95 // pass all additional arguments to the main function |
| 102 return launch_app(app_main, argc - 1, ++argv); | 96 return launch_app(app_main, argc - 1, ++argv); |
| 103 } | 97 } |
| OLD | NEW |