Clean up extension confirmation prompts and make them consistent between Views and...
[chromium-blink-merge.git] / components / cronet / tools / cr_cronet.py
blob921f32836d32ba29489413969af034f80a00bfa9
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
15 def run(command):
16 print command
17 return os.system(command)
20 def build(out_dir):
21 return run ('ninja -C ' + out_dir + ' cronet_test_instrumentation_apk')
24 def install(release_arg):
25 return run ('build/android/adb_install_apk.py ' + release_arg + \
26 ' --apk=CronetTest.apk')
29 def test(release_arg, extra_options):
30 return run ('build/android/test_runner.py instrumentation '+ \
31 release_arg + ' --test-apk=CronetTestInstrumentation ' + \
32 extra_options)
35 def debug(extra_options):
36 return run ('build/android/adb_gdb --start ' + \
37 '--activity=.CronetTestActivity ' + \
38 '--program-name=CronetTest ' + \
39 '--package-name=org.chromium.net ' + \
40 ' '.join(extra_options))
43 def stack(out_dir):
44 return run ('adb logcat -d | third_party/android_tools/ndk/ndk-stack ' + \
45 '-sym ' + out_dir + '/lib')
48 def main():
49 parser = argparse.ArgumentParser()
50 parser.add_argument('command',
51 choices=['gyp',
52 'sync',
53 'build',
54 'install',
55 'proguard',
56 'test',
57 'build-test',
58 'stack',
59 'debug',
60 'build-debug'])
61 parser.add_argument('-r', '--release', action='store_true',
62 help='use release configuration')
64 options, extra_options_list = parser.parse_known_args()
65 print options
66 print extra_options_list
67 gyp_defines = 'GYP_DEFINES="OS=android run_findbugs=1 enable_websockets=0 '+ \
68 'disable_file_support=1 disable_ftp_support=1 '+ \
69 'use_icu_alternatives_on_android=1" '
70 out_dir = 'out/Debug'
71 release_arg = ''
72 extra_options = ' '.join(extra_options_list)
73 if options.release:
74 out_dir = 'out/Release'
75 release_arg = ' --release'
77 if (options.command=='gyp'):
78 return run (gyp_defines + ' gclient runhooks')
79 if (options.command=='sync'):
80 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync')
81 if (options.command=='build'):
82 return build(out_dir)
83 if (options.command=='install'):
84 return install(release_arg)
85 if (options.command=='proguard'):
86 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk')
87 if (options.command=='test'):
88 return install(release_arg) or test(release_arg, extra_options)
89 if (options.command=='build-test'):
90 return build(out_dir) or install(release_arg) or \
91 test(release_arg, extra_options)
92 if (options.command=='stack'):
93 return stack(out_dir)
94 if (options.command=='debug'):
95 return install(release_arg) or debug(extra_options)
96 if (options.command=='build-debug'):
97 return build(out_dir) or install(release_arg) or debug(extra_options)
99 parser.print_help()
100 return 1
103 if __name__ == '__main__':
104 sys.exit(main())