summaryrefslogtreecommitdiffstats
path: root/build/android/gyp
diff options
context:
space:
mode:
authorcjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 07:58:19 +0000
committercjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 07:58:19 +0000
commit7aea76b94b0fc1d7f0c65aa8da195852157d1bd7 (patch)
tree760117ea8d83c975cc32841b516f7015c99b3595 /build/android/gyp
parent30c98bbd310b123082954cc88955725c265517a6 (diff)
downloadchromium_src-7aea76b94b0fc1d7f0c65aa8da195852157d1bd7.zip
chromium_src-7aea76b94b0fc1d7f0c65aa8da195852157d1bd7.tar.gz
chromium_src-7aea76b94b0fc1d7f0c65aa8da195852157d1bd7.tar.bz2
[Android] Support building standalone APK in component build
Many people's workflows assume that they can install the APK created in out/Debug/apks. With the component build that APK is actually an "incomplete" APK that cannot be manually installed (or rather causes obscure errors when manually installed). This change does two things. First, it moves the "incomplete" APK output to out/Debug/<package_name>/<ApkName>.apk. This should prevent accidental installs of the "incomplete" APK. Second, it introduces an option (create_standalone_apk) that when doing a component build, if set, will merge the shared libraries into the "incomplete" APK to create a standalone APK. This standalone APK will be created in out/Debug/apks/. Review URL: https://chromiumcodereview.appspot.com/14843017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207345 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/android/gyp')
-rwxr-xr-xbuild/android/gyp/create_standalone_apk.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/build/android/gyp/create_standalone_apk.py b/build/android/gyp/create_standalone_apk.py
new file mode 100755
index 0000000..de541a6
--- /dev/null
+++ b/build/android/gyp/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))