| 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 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 options, extra_options_list = parser.parse_known_args() | 74 options, extra_options_list = parser.parse_known_args() |
| 75 print options | 75 print options |
| 76 print extra_options_list | 76 print extra_options_list |
| 77 | 77 |
| 78 is_os = (sys.platform == 'darwin') | 78 is_os = (sys.platform == 'darwin') |
| 79 if is_os: | 79 if is_os: |
| 80 target_os = 'ios' | 80 target_os = 'ios' |
| 81 test_target = 'cronet_test' | 81 test_target = 'cronet_test' |
| 82 gn_args = 'target_cpu = "x64" ' | 82 gn_args = 'target_cpu = "x64" ' |
| 83 gn_extra = '--ide=xcode' |
| 83 out_dir_suffix = '-iphonesimulator' | 84 out_dir_suffix = '-iphonesimulator' |
| 84 if options.iphoneos: | 85 if options.iphoneos: |
| 85 gn_args = 'target_cpu = "arm64" ' | 86 gn_args = 'target_cpu = "arm64" ' |
| 86 out_dir_suffix = '-iphoneos' | 87 out_dir_suffix = '-iphoneos' |
| 87 else: | 88 else: |
| 88 target_os = 'android' | 89 target_os = 'android' |
| 89 test_target = 'cronet_test_instrumentation_apk' | 90 test_target = 'cronet_test_instrumentation_apk' |
| 90 gn_args = 'use_errorprone_java_compiler=true ' | 91 gn_args = 'use_errorprone_java_compiler=true ' |
| 92 gn_extra = '' |
| 91 out_dir_suffix = '' | 93 out_dir_suffix = '' |
| 92 | 94 |
| 93 gyp_defines = 'GYP_DEFINES="OS=' + target_os + ' enable_websockets=0 '+ \ | 95 gyp_defines = 'GYP_DEFINES="OS=' + target_os + ' enable_websockets=0 '+ \ |
| 94 'disable_file_support=1 disable_ftp_support=1 '+ \ | 96 'disable_file_support=1 disable_ftp_support=1 '+ \ |
| 95 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ | 97 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ |
| 96 'disable_brotli_filter=1"' | 98 'disable_brotli_filter=1"' |
| 97 gn_args += 'target_os="' + target_os + '" enable_websockets=false '+ \ | 99 gn_args += 'target_os="' + target_os + '" enable_websockets=false '+ \ |
| 98 'disable_file_support=true disable_ftp_support=true '+ \ | 100 'disable_file_support=true disable_ftp_support=true '+ \ |
| 99 'use_platform_icu_alternatives=true '+ \ | 101 'use_platform_icu_alternatives=true '+ \ |
| 100 'disable_brotli_filter=true' | 102 'disable_brotli_filter=true' |
| 101 | 103 |
| 102 extra_options = ' '.join(extra_options_list) | 104 extra_options = ' '.join(extra_options_list) |
| 103 if options.gn: | 105 if options.gn: |
| 104 out_dir_suffix += "-gn" | 106 out_dir_suffix += "-gn" |
| 105 | 107 |
| 106 if options.release: | 108 if options.release: |
| 107 out_dir = 'out/Release' + out_dir_suffix | 109 out_dir = 'out/Release' + out_dir_suffix |
| 108 release_arg = ' --release' | 110 release_arg = ' --release' |
| 109 gn_args += ' is_debug=false ' | 111 gn_args += ' is_debug=false ' |
| 110 else: | 112 else: |
| 111 out_dir = 'out/Debug' + out_dir_suffix | 113 out_dir = 'out/Debug' + out_dir_suffix |
| 112 release_arg = '' | 114 release_arg = '' |
| 113 | 115 |
| 114 if options.out_dir: | 116 if options.out_dir: |
| 115 out_dir = options.out_dir | 117 out_dir = options.out_dir |
| 116 | 118 |
| 117 if (options.command=='gyp'): | 119 if (options.command=='gyp'): |
| 118 return run (gyp_defines + ' gclient runhooks') | 120 return run (gyp_defines + ' gclient runhooks') |
| 119 if (options.command=='gn'): | 121 if (options.command=='gn'): |
| 120 return run ('gn gen ' + out_dir + ' --args=\'' + gn_args + '\'') | 122 return run ('gn gen %s --args=\'%s\' %s' % (out_dir, gn_args, gn_extra)) |
| 121 if (options.command=='sync'): | 123 if (options.command=='sync'): |
| 122 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') | 124 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') |
| 123 if (options.command=='build'): | 125 if (options.command=='build'): |
| 124 return build(out_dir, test_target, extra_options) | 126 return build(out_dir, test_target, extra_options) |
| 125 if (not is_os): | 127 if (not is_os): |
| 126 if (options.command=='install'): | 128 if (options.command=='install'): |
| 127 return install(out_dir, release_arg) | 129 return install(out_dir, release_arg) |
| 128 if (options.command=='proguard'): | 130 if (options.command=='proguard'): |
| 129 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk') | 131 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk') |
| 130 if (options.command=='test'): | 132 if (options.command=='test'): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 144 return test_ios(out_dir, extra_options) | 146 return test_ios(out_dir, extra_options) |
| 145 if (options.command=='build-test'): | 147 if (options.command=='build-test'): |
| 146 return build(out_dir, test_target) or test_ios(out_dir, extra_options) | 148 return build(out_dir, test_target) or test_ios(out_dir, extra_options) |
| 147 | 149 |
| 148 parser.print_help() | 150 parser.print_help() |
| 149 return 1 | 151 return 1 |
| 150 | 152 |
| 151 | 153 |
| 152 if __name__ == '__main__': | 154 if __name__ == '__main__': |
| 153 sys.exit(main()) | 155 sys.exit(main()) |
| OLD | NEW |