From 52f0297aafc1e267fda6e612f168a9fe5bc62784 Mon Sep 17 00:00:00 2001 From: "djsollen@google.com" Date: Mon, 3 Jun 2013 12:10:19 +0000 Subject: Prepare skia for shared library build on android This reapplies revision 9378 after the buildbot has been updated. R=borenet@google.com, djsollen@google.com Review URL: https://codereview.chromium.org/15855006 git-svn-id: http://skia.googlecode.com/svn/trunk@9395 2bbb7eff-a529-9590-31e7-b0007b416f81 --- .../app/src/com/skia/SkiaIntentService.java | 11 +++--- .../app/src/com/skia/SkiaSampleActivity.java | 1 + platform_tools/android/bin/android_setup.sh | 1 + platform_tools/android/gyp/skia_android.gypi | 2 ++ platform_tools/android/launcher/skia_launcher.cpp | 40 ++++++++++++++++------ 5 files changed, 39 insertions(+), 16 deletions(-) (limited to 'platform_tools') diff --git a/platform_tools/android/app/src/com/skia/SkiaIntentService.java b/platform_tools/android/app/src/com/skia/SkiaIntentService.java index e2707f7964..68d336e70e 100644 --- a/platform_tools/android/app/src/com/skia/SkiaIntentService.java +++ b/platform_tools/android/app/src/com/skia/SkiaIntentService.java @@ -16,7 +16,7 @@ public class SkiaIntentService extends IntentService { public SkiaIntentService() { super("SkiaIntentService"); } - + @Override public IBinder onBind(Intent arg0) { return null; @@ -25,12 +25,12 @@ public class SkiaIntentService extends IntentService { public void onCreate() { super.onCreate(); } - + @Override public void onDestroy() { super.onDestroy(); } - + @Override public void onHandleIntent(Intent intent) { @@ -51,10 +51,11 @@ public class SkiaIntentService extends IntentService { String cmd = bundle.getString("args").trim(); String[] args = cmd.split("\\s+"); Log.d("skia", "Executing Command: " + cmd); - + // Load the requested library String lib = args[0]; try { + System.loadLibrary("skia_android"); System.loadLibrary(lib); } catch (UnsatisfiedLinkError e) { Log.e("skia", "Library " + lib + @@ -62,7 +63,7 @@ public class SkiaIntentService extends IntentService { SkiaReturn(-1, returnRepeats); throw e; } - + // JNI call to run the program int retval = run(args); SkiaReturn(retval, returnRepeats); diff --git a/platform_tools/android/app/src/com/skia/SkiaSampleActivity.java b/platform_tools/android/app/src/com/skia/SkiaSampleActivity.java index 4b5e7d6b7f..62f81a58f5 100644 --- a/platform_tools/android/app/src/com/skia/SkiaSampleActivity.java +++ b/platform_tools/android/app/src/com/skia/SkiaSampleActivity.java @@ -42,6 +42,7 @@ public class SkiaSampleActivity extends Activity mSlideList = new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1); try { + System.loadLibrary("skia_android"); System.loadLibrary("SampleApp"); LinearLayout holder = (LinearLayout) findViewById(R.id.holder); diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/android_setup.sh index b955bea1cd..e5cea6e863 100755 --- a/platform_tools/android/bin/android_setup.sh +++ b/platform_tools/android/bin/android_setup.sh @@ -126,6 +126,7 @@ setup_device() { DEFINES="${DEFINES} skia_os=android" DEFINES="${DEFINES} android_base=${SCRIPT_DIR}/.." DEFINES="${DEFINES} android_toolchain=${TOOLCHAIN_TYPE}" + DEFINES="${DEFINES} skia_shared_lib=1" # Setup the build variation depending on the target device TARGET_DEVICE="$1" diff --git a/platform_tools/android/gyp/skia_android.gypi b/platform_tools/android/gyp/skia_android.gypi index 43c59c1d43..72dc942ab9 100644 --- a/platform_tools/android/gyp/skia_android.gypi +++ b/platform_tools/android/gyp/skia_android.gypi @@ -4,6 +4,7 @@ 'target_name': 'CopySkiaAppDeps', 'type': 'none', 'dependencies': [ + 'skia_lib.gyp:skia_lib', 'SampleApp.gyp:SampleApp', 'bench.gyp:bench', 'gm.gyp:gm', @@ -56,6 +57,7 @@ '<(PRODUCT_DIR)/lib.target/libtests.so', '<(PRODUCT_DIR)/lib.target/libpathops_unittest.so', '<(PRODUCT_DIR)/lib.target/gdbserver', + '<(PRODUCT_DIR)/lib.target/libskia_android.so', ], }, ], diff --git a/platform_tools/android/launcher/skia_launcher.cpp b/platform_tools/android/launcher/skia_launcher.cpp index 972382dc16..231289d4e9 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,21 +67,16 @@ 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]); + // load the local skia shared library + void* skiaLibrary = load_library(argv, "libskia_android.so"); + if (NULL == skiaLibrary) + { 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()); + void* appLibrary = load_library(argv, argv[1]); + if (NULL == appLibrary) { return -1; } -- cgit v1.2.3