1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#!/usr/bin/python
# Copyright 2014 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.
"""
cr_cronet.py - cr - like helper tool for cronet developers
"""
import argparse
import os
import sys
def run(command):
print command
return os.system(command)
def build(out_dir):
return run ('ninja -C ' + out_dir + ' cronet_test_instrumentation_apk')
def install(release_arg):
return run ('build/android/adb_install_apk.py ' + release_arg + \
' --apk=CronetTest.apk')
def test(release_arg, extra_options):
return run ('build/android/test_runner.py instrumentation '+ \
release_arg + ' --test-apk=CronetTestInstrumentation ' + \
extra_options)
def debug(extra_options):
return run ('build/android/adb_gdb --start ' + \
'--activity=.CronetTestActivity ' + \
'--program-name=CronetTest ' + \
'--package-name=org.chromium.cronet_test_apk ' + \
' '.join(extra_options))
def main():
parser = argparse.ArgumentParser()
parser.add_argument('command',
choices=['gyp',
'sync',
'build',
'install',
'proguard',
'test',
'build-test',
'debug',
'build-debug'])
parser.add_argument('-r', '--release', action='store_true',
help='use release configuration')
options, extra_options_list = parser.parse_known_args()
print options
print extra_options_list
gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \
'disable_file_support=1 disable_ftp_support=1 '+ \
'use_icu_alternatives_on_android=1" '
out_dir = 'out/Debug'
release_arg = ''
extra_options = ' '.join(extra_options_list)
if options.release:
out_dir = 'out/Release'
release_arg = ' --release'
if (options.command=='gyp'):
return run (gyp_defines + ' gclient runhooks')
if (options.command=='sync'):
return run ('git pull --rebase && ' + gyp_defines + ' gclient sync')
if (options.command=='build'):
return build(out_dir)
if (options.command=='install'):
return install(release_arg)
if (options.command=='proguard'):
return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk')
if (options.command=='test'):
return install(release_arg) or test(release_arg, extra_options)
if (options.command=='build-test'):
return build(out_dir) or install(release_arg) or \
test(release_arg, extra_options)
if (options.command=='debug'):
return install(release_arg) or debug(extra_options)
if (options.command=='build-debug'):
return build(out_dir) or install(release_arg) or debug(extra_options)
parser.print_help()
return 1
if __name__ == '__main__':
sys.exit(main())
|