Chromium Code Reviews| 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 def run(command): | 14 def run(command): |
| 15 print command | 15 print command |
| 16 return os.system(command) | 16 return os.system(command) |
| 17 | 17 |
| 18 def main(): | 18 def main(): |
| 19 parser = argparse.ArgumentParser() | 19 parser = argparse.ArgumentParser() |
| 20 parser.add_argument('command', | 20 parser.add_argument('command', |
| 21 choices=['init', | 21 choices=['gyp', |
| 22 'sync', | 22 'sync', |
| 23 'build', | 23 'build', |
| 24 'install', | 24 'install', |
| 25 'test', | 25 'test', |
| 26 'debug']) | 26 'debug']) |
| 27 parser.add_argument('-r', '--release', action='store_true', | |
| 28 help='use release configuration') | |
| 27 | 29 |
| 28 options = parser.parse_args() | 30 options = parser.parse_args() |
| 29 print options | 31 print options |
| 30 print options.command | |
| 31 gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \ | 32 gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \ |
| 32 'disable_file_support=1 disable_ftp_support=1 '+ \ | 33 'disable_file_support=1 disable_ftp_support=1 '+ \ |
| 33 'use_icu_alternatives_on_android=1" ' | 34 'use_icu_alternatives_on_android=1" ' |
| 35 out = 'out/Debug' | |
|
xunjieli
2014/08/28 15:35:04
nit: can this variable be sth like "out_dir" ?
mef
2014/08/31 21:34:39
Done.
| |
| 36 release_arg = '' | |
| 37 if options.release: | |
| 38 out = 'out/Release' | |
| 39 release_arg = ' --release ' | |
| 34 | 40 |
| 35 if (options.command=='init'): | 41 if (options.command=='gyp'): |
| 36 return run (gyp_defines + ' gclient runhooks') | 42 return run (gyp_defines + ' gclient runhooks') |
| 37 if (options.command=='sync'): | 43 if (options.command=='sync'): |
| 38 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') | 44 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') |
| 39 if (options.command=='build'): | 45 if (options.command=='build'): |
| 40 return run ('ninja -C out/Debug cronet_sample_test_apk') | 46 return run ('ninja -C ' + out + ' cronet_sample_test_apk') |
| 41 if (options.command=='install'): | 47 if (options.command=='install'): |
| 42 return run ('build/android/adb_install_apk.py --apk=CronetSample.apk') | 48 return run ('build/android/adb_install_apk.py ' + release_arg + \ |
| 49 '--apk=CronetSample.apk') | |
|
mmenke
2014/08/28 17:26:36
Should these args have leading spaces? release_ar
mef
2014/08/31 21:34:39
Done.
| |
| 43 if (options.command=='test'): | 50 if (options.command=='test'): |
| 44 return run ('build/android/test_runner.py instrumentation '+ \ | 51 return run ('build/android/test_runner.py instrumentation '+ \ |
| 45 '--test-apk=CronetSampleTest') | 52 release_arg + '--test-apk=CronetSampleTest') |
| 46 | 53 |
| 47 parser.print_help() | 54 parser.print_help() |
| 48 return 1 | 55 return 1 |
| 49 | 56 |
| 50 | 57 |
| 51 if __name__ == '__main__': | 58 if __name__ == '__main__': |
| 52 sys.exit(main()) | 59 sys.exit(main()) |
| OLD | NEW |