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, extra_options=''): | 14 def run(command, extra_options=''): |
| 15 command = command + ' ' + extra_options | 15 command = command + ' ' + extra_options |
| 16 print command | 16 print command |
| 17 return os.system(command) | 17 return os.system(command) |
| 18 | 18 |
| 19 | 19 |
| 20 def build(out_dir, test_target, extra_options=''): | 20 def build(out_dir, test_target, extra_options=''): |
| 21 return run('ninja -C ' + out_dir + ' ' + test_target, | 21 return run('ninja -C ' + out_dir + ' ' + test_target, |
| 22 extra_options) | 22 extra_options) |
| 23 | 23 |
| 24 | 24 |
| 25 def install(release_arg): | 25 def install(out_dir, release_arg): |
| 26 return run('build/android/adb_install_apk.py ' + release_arg + \ | 26 cmd = 'BUILDTYPE={0} build/android/adb_install_apk.py {1} --apk={2}' |
| 27 ' --apk=CronetTest.apk') or \ | 27 build_dir = out_dir.split('/', 1)[1] # the 'Foo' part of 'out/Foo' |
| 28 run('build/android/adb_install_apk.py ' + release_arg + \ | 28 return run(cmd.format(build_dir, release_arg, 'CronetTest.apk')) or \ |
| 29 ' --apk=ChromiumNetTestSupport.apk') | 29 run(cmd.format(build_dir, release_arg, 'ChromiumNetTestSupport.apk')) |
|
mef
2016/06/09 21:16:46
is this properly aligned?
mgersh
2016/06/10 15:45:20
The style guide just says to add a level of indent
| |
| 30 | 30 |
| 31 | 31 |
| 32 def test(out_dir, extra_options): | 32 def test(out_dir, extra_options): |
| 33 return run(out_dir + '/bin/run_cronet_test_instrumentation_apk ' + \ | 33 return run(out_dir + '/bin/run_cronet_test_instrumentation_apk ' + \ |
| 34 extra_options) | 34 extra_options) |
| 35 | 35 |
| 36 def test_ios(out_dir, extra_options): | 36 def test_ios(out_dir, extra_options): |
| 37 return run(out_dir + '/iossim ' + out_dir + '/cronet_test.app', extra_options) | 37 return run(out_dir + '/iossim ' + out_dir + '/cronet_test.app', extra_options) |
| 38 | 38 |
| 39 def debug(extra_options): | 39 def debug(extra_options): |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 if (options.command=='gyp'): | 109 if (options.command=='gyp'): |
| 110 return run (gyp_defines + ' gclient runhooks') | 110 return run (gyp_defines + ' gclient runhooks') |
| 111 if (options.command=='gn'): | 111 if (options.command=='gn'): |
| 112 return run ('gn gen ' + out_dir + ' --args=\'' + gn_args + '\'') | 112 return run ('gn gen ' + out_dir + ' --args=\'' + gn_args + '\'') |
| 113 if (options.command=='sync'): | 113 if (options.command=='sync'): |
| 114 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') | 114 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') |
| 115 if (options.command=='build'): | 115 if (options.command=='build'): |
| 116 return build(out_dir, test_target, extra_options) | 116 return build(out_dir, test_target, extra_options) |
| 117 if (not is_os): | 117 if (not is_os): |
| 118 if (options.command=='install'): | 118 if (options.command=='install'): |
| 119 return install(release_arg) | 119 return install(out_dir, release_arg) |
| 120 if (options.command=='proguard'): | 120 if (options.command=='proguard'): |
| 121 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk') | 121 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk') |
| 122 if (options.command=='test'): | 122 if (options.command=='test'): |
| 123 return install(release_arg) or test(out_dir, extra_options) | 123 return install(out_dir, release_arg) or test(out_dir, extra_options) |
| 124 if (options.command=='build-test'): | 124 if (options.command=='build-test'): |
| 125 return build(out_dir, test_target) or install(release_arg) or \ | 125 return build(out_dir, test_target) or install(out_dir, release_arg) or \ |
| 126 test(out_dir, extra_options) | 126 test(out_dir, extra_options) |
| 127 if (options.command=='stack'): | 127 if (options.command=='stack'): |
| 128 return stack(out_dir) | 128 return stack(out_dir) |
| 129 if (options.command=='debug'): | 129 if (options.command=='debug'): |
| 130 return install(release_arg) or debug(extra_options) | 130 return install(out_dir, release_arg) or debug(extra_options) |
| 131 if (options.command=='build-debug'): | 131 if (options.command=='build-debug'): |
| 132 return build(out_dir, test_target) or install(release_arg) or \ | 132 return build(out_dir, test_target) or install(out_dir, release_arg) or \ |
| 133 debug(extra_options) | 133 debug(extra_options) |
| 134 else: | 134 else: |
| 135 if (options.command=='test'): | 135 if (options.command=='test'): |
| 136 return test_ios(out_dir, extra_options) | 136 return test_ios(out_dir, extra_options) |
| 137 if (options.command=='build-test'): | 137 if (options.command=='build-test'): |
| 138 return build(out_dir, test_target) or test_ios(out_dir, extra_options) | 138 return build(out_dir, test_target) or test_ios(out_dir, extra_options) |
| 139 | 139 |
| 140 parser.print_help() | 140 parser.print_help() |
| 141 return 1 | 141 return 1 |
| 142 | 142 |
| 143 | 143 |
| 144 if __name__ == '__main__': | 144 if __name__ == '__main__': |
| 145 sys.exit(main()) | 145 sys.exit(main()) |
| OLD | NEW |