Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / components / cronet / tools / cr_cronet.py
blobbdc7312aeaf70251205131d145105d87e041321a
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.cronet_test_apk ' + \
40 ' '.join(extra_options))
43 def main():
44 parser = argparse.ArgumentParser()
45 parser.add_argument('command',
46 choices=['gyp',
47 'sync',
48 'build',
49 'install',
50 'proguard',
51 'test',
52 'build-test',
53 'debug',
54 'build-debug'])
55 parser.add_argument('-r', '--release', action='store_true',
56 help='use release configuration')
58 options, extra_options_list = parser.parse_known_args()
59 print options
60 print extra_options_list
61 gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \
62 'disable_file_support=1 disable_ftp_support=1 '+ \
63 'use_icu_alternatives_on_android=1" '
64 out_dir = 'out/Debug'
65 release_arg = ''
66 extra_options = ' '.join(extra_options_list)
67 if options.release:
68 out_dir = 'out/Release'
69 release_arg = ' --release'
71 if (options.command=='gyp'):
72 return run (gyp_defines + ' gclient runhooks')
73 if (options.command=='sync'):
74 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync')
75 if (options.command=='build'):
76 return build(out_dir)
77 if (options.command=='install'):
78 return install(release_arg)
79 if (options.command=='proguard'):
80 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk')
81 if (options.command=='test'):
82 return install(release_arg) or test(release_arg, extra_options)
83 if (options.command=='build-test'):
84 return build(out_dir) or install(release_arg) or \
85 test(release_arg, extra_options)
86 if (options.command=='debug'):
87 return install(release_arg) or debug(extra_options)
88 if (options.command=='build-debug'):
89 return build(out_dir) or install(release_arg) or debug(extra_options)
91 parser.print_help()
92 return 1
95 if __name__ == '__main__':
96 sys.exit(main())