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