ProjectingObserverChromeos: Drop DBusThreadManager dependency for better testing.
[chromium-blink-merge.git] / components / cronet / tools / cr_cronet.py
blob59a93511ca6bcac7d3d7f2c3d9da01c38bbc9d23
1 #!/usr/bin/python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """
7 cr_cronet.py - cr - like helper tool for cronet developers
8 """
10 import argparse
11 import os
12 import sys
14 def run(command):
15 print command
16 return os.system(command)
18 def main():
19 parser = argparse.ArgumentParser()
20 parser.add_argument('command',
21 choices=['gyp',
22 'sync',
23 'build',
24 'install',
25 'proguard',
26 'test',
27 'debug'])
28 parser.add_argument('-r', '--release', action='store_true',
29 help='use release configuration')
31 options, unknown_options = parser.parse_known_args()
32 print options
33 print unknown_options
34 gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \
35 'disable_file_support=1 disable_ftp_support=1 '+ \
36 'use_icu_alternatives_on_android=1" '
37 out_dir = 'out/Debug'
38 release_arg = ''
39 if options.release:
40 out_dir = 'out/Release'
41 release_arg = ' --release'
43 if (options.command=='gyp'):
44 return run (gyp_defines + ' gclient runhooks')
45 if (options.command=='sync'):
46 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync')
47 if (options.command=='build'):
48 return run ('ninja -C ' + out_dir + ' cronet_test_instrumentation_apk')
49 if (options.command=='install'):
50 return run ('build/android/adb_install_apk.py ' + release_arg + \
51 ' --apk=CronetTest.apk')
52 if (options.command=='proguard'):
53 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk')
54 if (options.command=='test'):
55 return run ('build/android/test_runner.py instrumentation '+ \
56 release_arg + ' --test-apk=CronetTestInstrumentation ' + \
57 ' '.join(unknown_options))
58 if (options.command=='debug'):
59 return run ('build/android/adb_gdb --start ' + \
60 '--activity=.CronetTestActivity ' + \
61 '--program-name=CronetTest ' + \
62 '--package-name=org.chromium.cronet_test_apk ' + \
63 ' '.join(unknown_options))
65 parser.print_help()
66 return 1
69 if __name__ == '__main__':
70 sys.exit(main())