diff options
author | lambroslambrou <lambroslambrou@chromium.org> | 2015-10-16 14:42:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-16 21:43:54 +0000 |
commit | e1172c5a03ed7546bc84282a72903952b15e4fd2 (patch) | |
tree | 1851b016deee21d3e3d42091d5f0d70b8473ba22 /remoting | |
parent | 31cac25752d71e57922d1f17a0e819faea3585a4 (diff) | |
download | chromium_src-e1172c5a03ed7546bc84282a72903952b15e4fd2.zip chromium_src-e1172c5a03ed7546bc84282a72903952b15e4fd2.tar.gz chromium_src-e1172c5a03ed7546bc84282a72903952b15e4fd2.tar.bz2 |
Android Chromoting: Include native Cardboard library in the app
Previously, only the Java code was being imported. This includes the
native code as well, on architectures where the Cardboard SDK provides
native code.
BUG=516871
Review URL: https://codereview.chromium.org/1391373005
Cr-Commit-Position: refs/heads/master@{#354610}
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/remoting_android.gypi | 32 | ||||
-rwxr-xr-x | remoting/tools/extract_android_native_lib.py | 33 |
2 files changed, 65 insertions, 0 deletions
diff --git a/remoting/remoting_android.gypi b/remoting/remoting_android.gypi index 861a94b..dbaad21 100644 --- a/remoting/remoting_android.gypi +++ b/remoting/remoting_android.gypi @@ -136,6 +136,30 @@ ], }, # end of target 'remoting_android_client_java' { + # TODO(lambroslambrou): Move some of this to third_party/cardboard-java/ in case it is + # useful to other clients. Also implement this for GN builds. + 'target_name': 'remoting_cardboard_extract_native_lib', + 'type': 'none', + 'actions': [ + { + 'action_name': 'extract_cardboard_native_lib', + 'inputs': [ + '../third_party/cardboard-java/src/CardboardSample/libs/cardboard.jar', + ], + 'outputs': [ + '<(SHARED_LIB_DIR)/libvrtoolkit.so', + ], + 'action': [ + 'python', + 'tools/extract_android_native_lib.py', + '<(android_app_abi)', + '<@(_inputs)', + '<@(_outputs)', + ], + }, + ], + }, # end of target 'remoting_cardboard_extract_native_lib' + { 'target_name': 'remoting_apk', 'type': 'none', 'dependencies': [ @@ -153,6 +177,14 @@ 'native_lib_target': 'libremoting_client_jni', }, 'includes': [ '../build/java_apk.gypi' ], + 'conditions': [ + ['target_arch == "arm"', { + 'dependencies': [ 'remoting_cardboard_extract_native_lib' ], + 'variables': { + 'extra_native_libs': [ '<(SHARED_LIB_DIR)/libvrtoolkit.so' ], + }, + }], + ], }, # end of target 'remoting_apk' { 'target_name': 'remoting_test_apk', diff --git a/remoting/tools/extract_android_native_lib.py b/remoting/tools/extract_android_native_lib.py new file mode 100755 index 0000000..6ef2023 --- /dev/null +++ b/remoting/tools/extract_android_native_lib.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Extracts a native library from an Android JAR.""" + +import os +import sys +import zipfile + + +def main(): + if len(sys.argv) != 4: + print 'Usage: %s <android_app_abi> <jar file> <output file>' % sys.argv[0] + sys.exit(1) + + android_app_abi = sys.argv[1] # e.g. armeabi-v7a + jar_file = sys.argv[2] # e.g. path/to/foo.jar + output_file = sys.argv[3] # e.g. path/to/libfoo.so + + library_filename = os.path.basename(output_file) + library_in_jar = os.path.join('lib', android_app_abi, library_filename) + + with zipfile.ZipFile(jar_file, 'r') as archive: + with open(output_file, 'wb') as target: + content = archive.read(library_in_jar) + target.write(content) + + +if __name__ == '__main__': + sys.exit(main()) |