Support using loadable module for libpeerconnection on Android.

Borrowed create_standalone_apk_action.gypi, create_standalone_apk.py and finalize_apk_action.gypi from https://codereview.chromium.org/14843017/ with some minor fix in create_standalone_apk_action.gypi.

For some cases where libpeerconnection needs to be a loadable module, we need to add libpeerconnection.so into Chrome_apk.
This patch takes 2 steps:
1. build chrome with libpeer_target_type=loadable_module.
2. add libpeerconnection.so into the apk file.

TEST=run gyp: GYP_DEFINES="$GYP_DEFINES libpeer_target_type=loadable_module" build/gyp_chromium
     build chrome
     re-run gyp: GYP_DEFINES="$GYP_DEFINES libpeer_target_type=loadable_module" CHROMIUM_GYP_FILE="build/android/chrome_with_libs.gyp" build/gyp_chromium
     build chrome_with_libs
     install Chrome-with-libs.apk and it works for https://apprtc.appspot.com

R=cjhopman@chromium.org, mallinath@chromium.org, tommi@chromium.org

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

git-svn-id: http://src.chromium.org/svn/trunk/src/build@208246 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
wjia@chromium.org 2013-06-24 18:54:11 +00:00
Родитель 51f3a9d7f6
Коммит e13c37b8d0
4 изменённых файлов: 230 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,82 @@
# Copyright 2013 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.
# This file is meant to add more loadable libs into Chrome_apk.
#
# This is useful when building Chrome_apk with some loadable modules which are
# not included in Chrome_apk.
# As an example, when building Chrome_apk with
# libpeer_target_type=loadable_module,
# the libpeerconnection.so is not included in Chrome_apk. To add the missing
# lib, follow the steps below:
# - Run gyp:
# GYP_DEFINES="$GYP_DEFINES libpeer_target_type=loadable_module" CHROMIUM_GYP_FILE="build/android/chrome_with_libs.gyp" build/gyp_chromium
# - Build chrome_with_libs:
# ninja (or make) chrome_with_libs
#
# This tool also allows replacing the loadable module with a new one via the
# following steps:
# - Build Chrome_apk with the gyp define:
# GYP_DEFINES="$GYP_DEFINES libpeer_target_type=loadable_module" build/gyp_chromium
# ninja (or make) Chrome_apk
# - Replace libpeerconnection.so with a new one:
# cp the_new_one path/to/libpeerconnection.so
# - Run gyp:
# GYP_DEFINES="$GYP_DEFINES libpeer_target_type=loadable_module" CHROMIUM_GYP_FILE="build/android/chrome_with_libs.gyp" build/gyp_chromium
# - Build chrome_with_libs:
# ninja (or make) chrome_with_libs
{
'targets': [
{
# An "All" target is required for a top-level gyp-file.
'target_name': 'All',
'type': 'none',
'dependencies': [
'chrome_with_libs',
],
},
{
'target_name': 'chrome_with_libs',
'type': 'none',
'variables': {
'intermediate_dir': '<(PRODUCT_DIR)/prebuilt_libs/',
'chrome_unsigned_path': '<(PRODUCT_DIR)/chrome_apk/Chrome-unsigned.apk',
'chrome_with_libs_unsigned': '<(intermediate_dir)/Chrome-with-libs-unsigned.apk',
'chrome_with_libs_final': '<(PRODUCT_DIR)/apks/Chrome-with-libs.apk',
},
'dependencies': [
'<(DEPTH)/clank/native/framework/clank.gyp:chrome_apk'
],
'copies': [
{
'destination': '<(intermediate_dir)/lib/<(android_app_abi)',
'files': [
'<(PRODUCT_DIR)/libpeerconnection.so',
],
},
],
'actions': [
{
'action_name': 'put_libs_in_chrome',
'variables': {
'inputs': [
'<(intermediate_dir)/lib/<(android_app_abi)/libpeerconnection.so',
],
'input_apk_path': '<(chrome_unsigned_path)',
'output_apk_path': '<(chrome_with_libs_unsigned)',
'libraries_top_dir%': '<(intermediate_dir)',
},
'includes': [ 'create_standalone_apk_action.gypi' ],
},
{
'action_name': 'finalize_chrome_with_libs',
'variables': {
'input_apk_path': '<(chrome_with_libs_unsigned)',
'output_apk_path': '<(chrome_with_libs_final)',
},
'includes': [ 'finalize_apk_action.gypi'],
},
],
}],
}

Просмотреть файл

@ -0,0 +1,61 @@
#!/usr/bin/env python
#
# Copyright 2013 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.
"""Combines stripped libraries and incomplete APK into single standalone APK.
"""
import optparse
import os
import shutil
import sys
import tempfile
from util import build_utils
from util import md5_check
def CreateStandaloneApk(options):
def DoZip():
with tempfile.NamedTemporaryFile(suffix='.zip') as intermediate_file:
intermediate_path = intermediate_file.name
shutil.copy(options.input_apk_path, intermediate_path)
apk_path_abs = os.path.abspath(intermediate_path)
build_utils.CheckCallDie(
['zip', '-r', '-1', apk_path_abs, 'lib'],
cwd=options.libraries_top_dir,
suppress_output=True)
shutil.copy(intermediate_path, options.output_apk_path)
input_paths = [options.input_apk_path, options.libraries_top_dir]
record_path = '%s.standalone.stamp' % options.input_apk_path
md5_check.CallAndRecordIfStale(
DoZip,
record_path=record_path,
input_paths=input_paths)
def main(argv):
parser = optparse.OptionParser()
parser.add_option('--libraries-top-dir',
help='Top directory that contains libraries '
'(i.e. library paths are like '
'libraries_top_dir/lib/android_app_abi/foo.so).')
parser.add_option('--input-apk-path', help='Path to incomplete APK.')
parser.add_option('--output-apk-path', help='Path for standalone APK.')
parser.add_option('--stamp', help='Path to touch on success.')
options, _ = parser.parse_args()
required_options = ['libraries_top_dir', 'input_apk_path', 'output_apk_path']
build_utils.CheckOptions(options, parser, required=required_options)
CreateStandaloneApk(options)
if options.stamp:
build_utils.Touch(options.stamp)
if __name__ == '__main__':
sys.exit(main(sys.argv))

Просмотреть файл

@ -0,0 +1,41 @@
# Copyright 2013 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.
# This file is meant to be included into an action to provide an action that
# combines a directory of shared libraries and an incomplete APK into a
# standalone APK.
#
# To use this, create a gyp action with the following form:
# {
# 'action_name': 'some descriptive action name',
# 'variables': {
# 'inputs': [ 'input_path1', 'input_path2' ],
# 'input_apk_path': '<(unsigned_apk_path)',
# 'output_apk_path': '<(unsigned_standalone_apk_path)',
# 'libraries_top_dir': '<(libraries_top_dir)',
# },
# 'includes': [ 'relative/path/to/create_standalone_apk_action.gypi' ],
# },
{
'message': 'Creating standalone APK: <(output_apk_path)',
'variables': {
'inputs': [],
},
'inputs': [
'<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(DEPTH)/build/android/gyp/create_standalone_apk.py',
'<(input_apk_path)',
'>@(inputs)',
],
'outputs': [
'<(output_apk_path)',
],
'action': [
'python', '<(DEPTH)/build/android/gyp/create_standalone_apk.py',
'--libraries-top-dir=<(libraries_top_dir)',
'--input-apk-path=<(input_apk_path)',
'--output-apk-path=<(output_apk_path)',
],
}

Просмотреть файл

@ -0,0 +1,46 @@
# Copyright 2013 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.
# This file is meant to be included into an action to provide an action that
# signs and zipaligns an APK.
#
# To use this, create a gyp action with the following form:
# {
# 'action_name': 'some descriptive action name',
# 'variables': {
# 'inputs': [ 'input_path1', 'input_path2' ],
# 'input_apk_path': 'relative/path/to/input.apk',
# 'output_apk_path': 'relative/path/to/output.apk',
# },
# 'includes': [ '../../build/android/finalize_apk.gypi' ],
# },
#
{
'message': 'Signing/aligning <(_target_name) APK: <(input_apk_path).',
'variables': {
'inputs': [],
'keystore_path%': '<(DEPTH)/build/android/ant/chromium-debug.keystore',
},
'inputs': [
'<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(DEPTH)/build/android/gyp/finalize_apk.py',
'<(keystore_path)',
'<(input_apk_path)',
'>@(inputs)',
],
'outputs': [
'<(output_apk_path)',
],
'action': [
'python', '<(DEPTH)/build/android/gyp/finalize_apk.py',
'--android-sdk-root=<(android_sdk_root)',
'--unsigned-apk-path=<(input_apk_path)',
'--final-apk-path=<(output_apk_path)',
'--keystore-path=<(keystore_path)',
# TODO(newt): remove this once crbug.com/177552 is fixed in ninja.
'--ignore=>!(echo \'>(_inputs)\' | md5sum)',
],
}