Support linking skia statically on Android
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 26 Nov 2013 20:39:11 +0000 (20:39 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 26 Nov 2013 20:39:11 +0000 (20:39 +0000)
Support linking skia statically on Android. Skia symbols should be
exported by the app library, to the extent that skia_launcher needs
them.

Syncs libskia_android.so to the device only if it exists.

R=djsollen@google.com

Author: kkinnunen@nvidia.com

Review URL: https://codereview.chromium.org/61893008

git-svn-id: http://skia.googlecode.com/svn/trunk@12399 2bbb7eff-a529-9590-31e7-b0007b416f81

platform_tools/android/app/src/com/skia/SkiaSampleActivity.java
platform_tools/android/bin/android_run_skia
platform_tools/android/bin/android_setup.sh
platform_tools/android/gyp/skia_android.gypi
platform_tools/android/launcher/skia_launcher.cpp

index 62f81a5..0a7a569 100644 (file)
@@ -43,6 +43,11 @@ public class SkiaSampleActivity extends Activity
 
         try {
             System.loadLibrary("skia_android");
+        } catch (UnsatisfiedLinkError e) {
+            // This might be because skia was linked to SampleApp statically.
+        }
+
+        try {
             System.loadLibrary("SampleApp");
 
             LinearLayout holder = (LinearLayout) findViewById(R.id.holder);
index 3314225..11c3675 100755 (executable)
@@ -28,7 +28,10 @@ then
 fi
 
 adb_push_if_needed "${SKIA_OUT}/${configuration}/skia_launcher" /data/local/tmp
-adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" /data/local/tmp
+if [ -f "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" ]; then
+    # Does not exist for builds with static skia.
+    adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" /data/local/tmp
+fi
 adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" /data/local/tmp
 
 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)"
index 1a5ccf9..b11fcac 100755 (executable)
@@ -161,7 +161,9 @@ setup_device() {
   DEFINES="${DEFINES} host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')"
   DEFINES="${DEFINES} skia_os=android"
   DEFINES="${DEFINES} android_base=${SCRIPT_DIR}/.."
-  DEFINES="${DEFINES} skia_shared_lib=1"
+  if [[ "$GYP_DEFINES" != *skia_shared_lib=* ]]; then
+      DEFINES="${DEFINES} skia_shared_lib=1"
+  fi
 
   # Setup the build variation depending on the target device
   TARGET_DEVICE="$1"
index d4f865a..270b934 100644 (file)
         # still build.
         {
           'destination': '<(PRODUCT_DIR)/android/libs/<(android_arch)',
-          'files': [
-            '<(SHARED_LIB_DIR)/libSampleApp.so',
-            '<(SHARED_LIB_DIR)/libskia_android.so',
+          'conditions': [
+            [ 'skia_shared_lib', {
+              'files': [
+                '<(SHARED_LIB_DIR)/libSampleApp.so',
+                '<(SHARED_LIB_DIR)/libskia_android.so',
+              ]}, {
+              'files': [
+                '<(SHARED_LIB_DIR)/libSampleApp.so',
+             ]}
+           ],
           ],
         },
       ],
index 718a717..746d470 100644 (file)
@@ -67,12 +67,16 @@ int main(int argc, const char** argv) {
         return -1;
     }
 
+    void* skiaLibrary;
+
+#if defined(SKIA_DLL)
     // load the local skia shared library
-    void* skiaLibrary = load_library(appLocation, "skia_android");
+    skiaLibrary = load_library(appLocation, "skia_android");
     if (NULL == skiaLibrary)
     {
         return -1;
     }
+#endif
 
     // load the appropriate library
     void* appLibrary = load_library(appLocation, argv[1]);
@@ -80,6 +84,10 @@ int main(int argc, const char** argv) {
         return -1;
     }
 
+#if !defined(SKIA_DLL)
+    skiaLibrary = appLibrary;
+#endif
+
     // find the address of the main function
     int (*app_main)(int, const char**);
     *(void **) (&app_main) = dlsym(appLibrary, "main");