diff options
-rw-r--r-- | build/android/chrome_with_libs.gyp | 82 | ||||
-rw-r--r-- | build/android/create_standalone_apk.py | 61 | ||||
-rw-r--r-- | build/android/create_standalone_apk_action.gypi | 41 | ||||
-rw-r--r-- | build/android/finalize_apk_action.gypi | 46 | ||||
-rw-r--r-- | third_party/libjingle/libjingle.gyp | 7 | ||||
-rw-r--r-- | third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc | 4 | ||||
-rw-r--r-- | third_party/libjingle/overrides/allocator_shim/allocator_stub.cc | 4 | ||||
-rw-r--r-- | third_party/libjingle/overrides/allocator_shim/allocator_stub.h | 4 | ||||
-rw-r--r-- | third_party/libjingle/overrides/init_webrtc.cc | 6 | ||||
-rw-r--r-- | third_party/libjingle/overrides/init_webrtc.h | 2 | ||||
-rw-r--r-- | third_party/libjingle/overrides/initialize_module.cc | 6 |
11 files changed, 248 insertions, 15 deletions
diff --git a/build/android/chrome_with_libs.gyp b/build/android/chrome_with_libs.gyp new file mode 100644 index 0000000..690be88 --- /dev/null +++ b/build/android/chrome_with_libs.gyp @@ -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'], + }, + ], + }], +} diff --git a/build/android/create_standalone_apk.py b/build/android/create_standalone_apk.py new file mode 100644 index 0000000..de541a6 --- /dev/null +++ b/build/android/create_standalone_apk.py @@ -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)) diff --git a/build/android/create_standalone_apk_action.gypi b/build/android/create_standalone_apk_action.gypi new file mode 100644 index 0000000..d17af7c --- /dev/null +++ b/build/android/create_standalone_apk_action.gypi @@ -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)', + ], +} diff --git a/build/android/finalize_apk_action.gypi b/build/android/finalize_apk_action.gypi new file mode 100644 index 0000000..5ee6043 --- /dev/null +++ b/build/android/finalize_apk_action.gypi @@ -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)', + ], +} diff --git a/third_party/libjingle/libjingle.gyp b/third_party/libjingle/libjingle.gyp index 6bd91ba..45d5fd9 100644 --- a/third_party/libjingle/libjingle.gyp +++ b/third_party/libjingle/libjingle.gyp @@ -898,13 +898,12 @@ 'libjingle_webrtc_common', ], 'conditions': [ - ['libpeer_allocator_shim==1 and ' - 'libpeer_target_type!="static_library"', { + ['libpeer_target_type!="static_library"', { 'sources': [ 'overrides/initialize_module.cc', ], 'conditions': [ - ['OS!="mac"', { + ['OS!="mac" and OS!="android"', { 'sources': [ 'overrides/allocator_shim/allocator_proxy.cc', ], @@ -936,7 +935,7 @@ ['OS=="mac" and libpeer_target_type!="static_library"', { 'product_name': 'libpeerconnection', }], - ['OS=="android"', { + ['OS=="android" and "<(libpeer_target_type)"=="static_library"', { 'standalone_static_library': 1, }], ['OS=="linux" and libpeer_target_type!="static_library"', { diff --git a/third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc b/third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc index d3f24e0..515cad4 100644 --- a/third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc +++ b/third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc @@ -8,8 +8,8 @@ #error "Only compile the allocator proxy with the shared_library implementation" #endif -#if defined(OS_MACOSX) -#error "The allocator proxy isn't supported (or needed) on mac." +#if defined(OS_MACOSX) || defined(OS_ANDROID) +#error "The allocator proxy isn't supported (or needed) on mac or android." #endif extern AllocateFunction g_alloc; diff --git a/third_party/libjingle/overrides/allocator_shim/allocator_stub.cc b/third_party/libjingle/overrides/allocator_shim/allocator_stub.cc index 28ea658..77caee4 100644 --- a/third_party/libjingle/overrides/allocator_shim/allocator_stub.cc +++ b/third_party/libjingle/overrides/allocator_shim/allocator_stub.cc @@ -4,8 +4,8 @@ #include "allocator_shim/allocator_stub.h" -#if defined(OS_MACOSX) -#error "The allocator stub isn't supported (or needed) on mac." +#if defined(OS_MACOSX) || defined(OS_ANDROID) +#error "The allocator stub isn't supported (or needed) on mac or android." #endif void* Allocate(std::size_t n) { diff --git a/third_party/libjingle/overrides/allocator_shim/allocator_stub.h b/third_party/libjingle/overrides/allocator_shim/allocator_stub.h index 9e0fc2f..20b9c7d 100644 --- a/third_party/libjingle/overrides/allocator_shim/allocator_stub.h +++ b/third_party/libjingle/overrides/allocator_shim/allocator_stub.h @@ -9,7 +9,7 @@ #include "base/basictypes.h" -#if !defined(OS_MACOSX) +#if !defined(OS_MACOSX) && !defined(OS_ANDROID) typedef void* (*AllocateFunction)(std::size_t); typedef void (*DellocateFunction)(void*); @@ -19,6 +19,6 @@ typedef void (*DellocateFunction)(void*); void* Allocate(std::size_t n); void Dellocate(void* p); -#endif // OS_MACOSX +#endif // OS_MACOSX && OS_ANDROID #endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_ALLOCATOR_SHIM_ALLOCATOR_STUB_H_ diff --git a/third_party/libjingle/overrides/init_webrtc.cc b/third_party/libjingle/overrides/init_webrtc.cc index ba28478..5436345 100644 --- a/third_party/libjingle/overrides/init_webrtc.cc +++ b/third_party/libjingle/overrides/init_webrtc.cc @@ -61,6 +61,10 @@ static base::FilePath GetLibPeerConnectionPath() { CHECK(PathService::Get(base::DIR_MODULE, &path)); path = path.Append(FILE_PATH_LITERAL("Libraries")) .Append(FILE_PATH_LITERAL("libpeerconnection.so")); +#elif defined(OS_ANDROID) + base::FilePath path; + CHECK(PathService::Get(base::DIR_MODULE, &path)); + path = path.Append(FILE_PATH_LITERAL("libpeerconnection.so")); #else base::FilePath path; CHECK(PathService::Get(base::DIR_MODULE, &path)); @@ -94,7 +98,7 @@ bool InitializeWebRtcModule() { // PS: This function is actually implemented in allocator_proxy.cc with the // new/delete overrides. return initialize_module(*CommandLine::ForCurrentProcess(), -#if !defined(OS_MACOSX) +#if !defined(OS_MACOSX) && !defined(OS_ANDROID) &Allocate, &Dellocate, #endif logging::GetLogMessageHandler(), diff --git a/third_party/libjingle/overrides/init_webrtc.h b/third_party/libjingle/overrides/init_webrtc.h index 78fb4de..e277783 100644 --- a/third_party/libjingle/overrides/init_webrtc.h +++ b/third_party/libjingle/overrides/init_webrtc.h @@ -40,7 +40,7 @@ typedef void (*DestroyWebRtcMediaEngineFunction)( // to go through GetProcAddress et al and rely on specific name mangling. typedef bool (*InitializeModuleFunction)( const CommandLine& command_line, -#if !defined(OS_MACOSX) +#if !defined(OS_MACOSX) && !defined(OS_ANDROID) AllocateFunction alloc, DellocateFunction dealloc, #endif diff --git a/third_party/libjingle/overrides/initialize_module.cc b/third_party/libjingle/overrides/initialize_module.cc index c54ae56..a2528b8 100644 --- a/third_party/libjingle/overrides/initialize_module.cc +++ b/third_party/libjingle/overrides/initialize_module.cc @@ -20,7 +20,7 @@ #define ALLOC_EXPORT __attribute__((visibility("default"))) #endif -#if !defined(OS_MACOSX) +#if !defined(OS_MACOSX) && !defined(OS_ANDROID) // These are used by our new/delete overrides in // allocator_shim/allocator_proxy.cc AllocateFunction g_alloc = NULL; @@ -44,7 +44,7 @@ extern "C" { // Called from init_webrtc.cc. ALLOC_EXPORT bool InitializeModule(const CommandLine& command_line, -#if !defined(OS_MACOSX) +#if !defined(OS_MACOSX) && !defined(OS_ANDROID) AllocateFunction alloc, DellocateFunction dealloc, #endif @@ -53,7 +53,7 @@ bool InitializeModule(const CommandLine& command_line, webrtc::AddTraceEventPtr trace_add_trace_event, CreateWebRtcMediaEngineFunction* create_media_engine, DestroyWebRtcMediaEngineFunction* destroy_media_engine) { -#if !defined(OS_MACOSX) +#if !defined(OS_MACOSX) && !defined(OS_ANDROID) g_alloc = alloc; g_dealloc = dealloc; #endif |