Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / build / android / gyp / apk_install.py
blobf8e7caab8d562ec2923e2071c995544307e6dd94
1 #!/usr/bin/env python
3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 """Installs an APK.
9 """
11 import optparse
12 import os
13 import subprocess
14 import sys
16 from util import build_utils
17 from util import md5_check
19 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..')
20 sys.path.append(BUILD_ANDROID_DIR)
22 from pylib import android_commands
24 def main(argv):
25 parser = optparse.OptionParser()
26 parser.add_option('--android-sdk-tools',
27 help='Path to Android SDK tools.')
28 parser.add_option('--apk-path',
29 help='Path to .apk to install.')
30 parser.add_option('--stamp',
31 help='Path to touch on success.')
32 options, _ = parser.parse_args()
34 # TODO(cjhopman): Should this install to all devices/be configurable?
35 install_cmd = [
36 os.path.join(options.android_sdk_tools, 'adb'),
37 'install', '-r',
38 options.apk_path]
40 serial_number = android_commands.AndroidCommands().Adb().GetSerialNumber()
41 md5_stamp = '%s.%s.md5' % (options.apk_path, serial_number)
43 md5_checker = md5_check.Md5Checker(
44 stamp=md5_stamp, inputs=[options.apk_path], command=install_cmd)
45 if md5_checker.IsStale():
46 build_utils.CheckCallDie(install_cmd)
47 md5_checker.Write()
49 if options.stamp:
50 build_utils.Touch(options.stamp)
53 if __name__ == '__main__':
54 sys.exit(main(sys.argv))